From: Alexander Barton Date: Sun, 27 Sep 2015 18:27:53 +0000 (+0200) Subject: Initial theming support X-Git-Url: https://arthur.barton.de/gitweb/?p=ax-zsh.git;a=commitdiff_plain;h=f59153717abf80de1ceeca9687d4aff83b017559 Initial theming support --- diff --git a/.gitignore b/.gitignore index 0e54b51..a9813ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ active_plugins/ custom_plugins/ +active_theme +custom_themes/ diff --git a/bin/axzshctl b/bin/axzshctl index 0e310a4..b425679 100755 --- a/bin/axzshctl +++ b/bin/axzshctl @@ -37,6 +37,9 @@ function Usage { echo " enable-default-plugins" echo " Enable all default plugins." echo + echo " set-theme |-" + echo " Set active theme to , or to the default." + echo echo " upgrade" echo " Upgrade AX-ZSH installation (requires Git)." echo @@ -107,6 +110,35 @@ function EnableDefaultPlugins { return $? } +function SetTheme { + local link_name="$AXZSH/active_theme" + + if [ $# -ne 1 ]; then + echo "Usage: axzsh_set_theme " + return 1 + fi + + rm -f "$link_name" || return 1 + + if [ "$1" = "-" ]; then + echo "Theme settings have been reset." + return 0 + fi + + if [ -r "$1" ]; then + theme="$1" + elif [ -r "$AXZSH/custom_themes/$1.axzshtheme" ]; then + theme="$AXZSH/custom_themes/$1.axzshtheme" + elif [ -r "$AXZSH/themes/$1.axzshtheme" ]; then + theme="$AXZSH/themes/$1.axzshtheme" + else + echo "Theme \"$1\" not found!" + return 1 + fi + ln -sv "$theme" "$link_name" || return 1 + return $? +} + function UpgradeAXZSH { if [[ $+commands[git] -eq 0 ]]; then ax_msg 2 "The git(1) command is not available!" @@ -155,6 +187,10 @@ case "$cmd" in [[ $# -eq 0 ]] || Usage EnableDefaultPlugins ;; + "set-theme") + [[ $# -eq 1 ]] || Usage + SetTheme "$1" + ;; "upgrade") [[ $# -eq 0 ]] || Usage UpgradeAXZSH diff --git a/default_plugins/prompt/prompt.zlogin b/default_plugins/prompt/prompt.zlogin index 862366f..5911418 100644 --- a/default_plugins/prompt/prompt.zlogin +++ b/default_plugins/prompt/prompt.zlogin @@ -1,8 +1,6 @@ # AX-ZSH: Alex' Modular ZSH Configuration # prompt.zlogin: Setup default prompts -# Default prompt -PS1="$(ax_logname_prompt_yn)$(ax_hostname_prompt_yn)%B%2~%b "'$(ax_vcs_prompt)'"%{$fg_no_bold[green]%}%B\$%b%{$reset_color%} " - -# Prompt on right side -RPS1="%(?..%{$fg_no_bold[red]%}%? ↵%{$reset_color%})" +[[ -r "$AXZSH/active_theme" ]] \ + && source "$AXZSH/active_theme" \ + || source "$AXZSH/themes/ax.axzshtheme" diff --git a/install.sh b/install.sh index 923ab86..922f1a9 100755 --- a/install.sh +++ b/install.sh @@ -67,6 +67,7 @@ else fi mkdir -p "$AXZSH/custom_plugins" || abort +mkdir -p "$AXZSH/custom_themes" || abort ax_msg - "Linking ZSH startup files ..." diff --git a/themes/ax.axzshtheme b/themes/ax.axzshtheme new file mode 100644 index 0000000..d0363b4 --- /dev/null +++ b/themes/ax.axzshtheme @@ -0,0 +1,11 @@ +# AX-ZSH: Alex' Modular ZSH Configuration +# ax.axzshtheme: Default AX-ZSH Theme + +ax_logname_prompt_functions=($ax_logname_prompt_functions ax_logname_prompt_root) +ax_hostname_prompt_functions=($ax_hostname_prompt_functions ax_hostname_prompt_root) + +# Default prompt +PS1="$(ax_logname_prompt_yn)$(ax_hostname_prompt_yn)%B%2~%b "'$(ax_vcs_prompt)'"%{$fg_no_bold[green]%}%B\$%b%{$reset_color%} " + +# Prompt on right side +RPS1="%(?..%{$fg_no_bold[red]%}%? ↵%{$reset_color%})"