]> arthur.barton.de Git - ax-zsh.git/commitdiff
Implement axzshctl function, restarting the current shell
authorAlexander Barton <alex@barton.de>
Sun, 3 Feb 2019 15:39:25 +0000 (16:39 +0100)
committerAlexander Barton <alex@barton.de>
Sun, 3 Feb 2019 15:39:25 +0000 (16:39 +0100)
The new axzshctl function, which shadows the axzshctl shell script,
tries to detect when there potentially were changes to the setup and
restarts the running shell in that case, bringing the new configuration
in effect immediately.

Now the user doesn't have to restart his shell manually any more.

core/50_axzsh/50_axzsh.zshrc

index c22f4c6f88f4a5f307048a627e48da48c0f81aed..be6f0b82c15c6e2ee56bee9072b50a88ffd77831 100644 (file)
@@ -1,4 +1,20 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # 50_axzsh.zshrc: Initialize AX-ZSH
 
-alias axzshctl="nocorrect zsh $AXZSH/bin/axzshctl"
+function axzshctl() {
+       zsh "$AXZSH/bin/axzshctl" "$@" || return $?
+
+       case "$1" in
+               "disable"*|"enable"*|"reset"*|"set"*|"up"*)
+                       # Command which potentially "changed state".
+                       if [[ -o login ]]; then
+                               echo "Restarting login shell ..."
+                               exec -l "$SHELL"
+                       else
+                               echo "Restarting shell ..."
+                               exec "$SHELL"
+                       fi
+                       ;;
+       esac
+       return 0
+}