]> arthur.barton.de Git - ax-zsh.git/commitdiff
Initial theming support
authorAlexander Barton <alex@barton.de>
Sun, 27 Sep 2015 18:27:53 +0000 (20:27 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 27 Sep 2015 18:27:53 +0000 (20:27 +0200)
.gitignore
bin/axzshctl
default_plugins/prompt/prompt.zlogin
install.sh
themes/ax.axzshtheme [new file with mode: 0644]

index 0e54b5134dde8339c8751ad36310b347918d9706..a9813ace5b330fff368281daf5bda3cf8e061e1b 100644 (file)
@@ -1,2 +1,4 @@
 active_plugins/
 custom_plugins/
+active_theme
+custom_themes/
index 0e310a4244cbb6c16d94a43002f19b330f42d13e..b425679aecdf4513687a31f71fc1ac50afddcf4a 100755 (executable)
@@ -37,6 +37,9 @@ function Usage {
        echo "  enable-default-plugins"
        echo "    Enable all default plugins."
        echo
+       echo "  set-theme <name>|-"
+       echo "    Set active theme to <name>, 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 <name|->"
+               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
index 862366f7ea29b47083180f7943b88f06f27b492c..591141897026fc7faf55a3c92834ac3cc27f71a0 100644 (file)
@@ -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"
index 923ab8694213eedcbf80878e0c1c09cb6edfcb57..922f1a98c2b8bfd0391bf3e41949d31246a37e6f 100755 (executable)
@@ -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 (file)
index 0000000..d0363b4
--- /dev/null
@@ -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%})"