Skip to content

Instantly share code, notes, and snippets.

@astrsk-hori
Created November 14, 2017 01:01
Show Gist options
  • Save astrsk-hori/43babb832a99b350fc97981a6473e730 to your computer and use it in GitHub Desktop.
Save astrsk-hori/43babb832a99b350fc97981a6473e730 to your computer and use it in GitHub Desktop.
aliasを展開するzshコマンド
my-open-alias() {
if [ -z "$RBUFFER" ] ; then
my-open-alias-aux
else
zle end-of-line
fi
}
my-open-alias-aux() {
str=${LBUFFER%% }
bp=$str
str=${str##* }
bp=${bp%%${str}}
targets=`alias ${str}`
if [ $targets ]; then
cmd=`echo $targets|cut -d"=" -f2`
LBUFFER=$bp${cmd//\'/}
fi
}
zle -N my-open-alias
bindkey "^ " my-open-alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment