From: Alexander Barton Date: Sat, 14 Nov 2015 23:41:33 +0000 (+0100) Subject: Don't call external tools, use variable modifiers X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ax-zsh.git;a=commitdiff_plain;h=062ed4a6b1dbb6bb7cd92d05cc4e7155086f96f7 Don't call external tools, use variable modifiers Not calling external tools like basename(1) and readlink(1) but ZSH variable modifiers greatly enhances startup performance, especially on slow machines. --- diff --git a/ax.zsh b/ax.zsh index ee376ea..a3c66c7 100644 --- a/ax.zsh +++ b/ax.zsh @@ -1,7 +1,7 @@ # AX-ZSH: Alex' Modular ZSH Configuration # Copyright (c) 2015 Alexander Barton -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" diff --git a/bin/axzshctl b/bin/axzshctl index b425679..eb56c81 100755 --- a/bin/axzshctl +++ b/bin/axzshctl @@ -153,7 +153,7 @@ function UpgradeAXZSH { ( cd "$AXZSH" && git pull --ff-only ) } -NAME="$(basename "$0")" +NAME="$0:t" [[ $# -gt 0 ]] || Usage diff --git a/plugins/editor_select/editor_select.zprofile b/plugins/editor_select/editor_select.zprofile index 08a0cf0..a5c3173 100644 --- a/plugins/editor_select/editor_select.zprofile +++ b/plugins/editor_select/editor_select.zprofile @@ -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" ;;