]> arthur.barton.de Git - ax-zsh.git/commitdiff
Don't call external tools, use variable modifiers
authorAlexander Barton <alex@barton.de>
Sat, 14 Nov 2015 23:41:33 +0000 (00:41 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 14 Nov 2015 23:41:33 +0000 (00:41 +0100)
Not calling external tools like basename(1) and readlink(1) but ZSH
variable modifiers greatly enhances startup performance, especially on
slow machines.

ax.zsh
bin/axzshctl
plugins/editor_select/editor_select.zprofile

diff --git a/ax.zsh b/ax.zsh
index ee376eac5e45cea319e9678ad9bf3b924baeba1d..a3c66c768c1f828a572cd4994c7bfc59d3fdd837 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -1,7 +1,7 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # Copyright (c) 2015 Alexander Barton <alex@barton.de>
 
-script_name="$(basename -- "${(%):-%N}")"
+script_name="${${(%):-%N}:t}"
 script_type="$script_name[2,-1]"
 
 [[ -f "$HOME/.axzsh.debug" ]] && echo "ยป $script_name:"
@@ -10,8 +10,8 @@ script_type="$script_name[2,-1]"
 # - $1: plugin name
 # - $2: plugin type (optional; defaults to "zshrc")
 function axzsh_load_plugin {
-       dname="$(readlink "$1")" || dname="$1"
-       plugin="$(basename "$dname")"
+       dname="$1:A"
+       plugin="$dname:t"
        [[ -z "$2" ]] && type="zshrc" || type="$2"
        fname="$dname/$plugin.$type"
 
index b425679aecdf4513687a31f71fc1ac50afddcf4a..eb56c812d2cfcc0f24e144b61d623de606c9940d 100755 (executable)
@@ -153,7 +153,7 @@ function UpgradeAXZSH {
        ( cd "$AXZSH" && git pull --ff-only )
 }
 
-NAME="$(basename "$0")"
+NAME="$0:t"
 
 [[ $# -gt 0 ]] || Usage
 
index 08a0cf0581b5e751b41ae30b01f9e9d4b076076f..a5c3173d49531b6d11538c14ac1bf324238fa4e2 100644 (file)
@@ -11,7 +11,7 @@ if [[ -z "$EDITOR" ]]; then
        unset editor
 fi
 
-case "$(basename "$EDITOR")" in
+case "$EDITOR:t" in
        "atom"|"mate"|"subl")
                EDITOR="$EDITOR --wait"
                ;;