diff options
author | self <george@gabbott.dev> | 2022-09-23 22:54:47 +0100 |
---|---|---|
committer | self <george@gabbott.dev> | 2022-09-23 22:54:47 +0100 |
commit | 7602e70ac45fb757acbc9c6e54af48828f6edbc9 (patch) | |
tree | 98524e05075c5d90a02efa949a0e9212cad178a5 /zsh/.zshrc-abbrev | |
parent | a8fce0f82a19527a25734c317d2ef9a490a200a7 (diff) |
Split out zshrc into several files for cleanliness
Diffstat (limited to 'zsh/.zshrc-abbrev')
-rw-r--r-- | zsh/.zshrc-abbrev | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/zsh/.zshrc-abbrev b/zsh/.zshrc-abbrev new file mode 100644 index 0000000..d6214d5 --- /dev/null +++ b/zsh/.zshrc-abbrev @@ -0,0 +1,33 @@ +# Allows declaring abbreviations: +# declare a list of expandable aliases to fill up later +typeset -a ealiases +ealiases=() + +# write a function for adding an alias to the list mentioned above +function abbrev-alias() { + alias $1 + ealiases+=(${1%%\=*}) +} + +# expand any aliases in the current line buffer +function expand-ealias() { + if [[ $LBUFFER =~ "\<(${(j:|:)ealiases})\$" ]]; then + zle _expand_alias + zle expand-word + fi + zle magic-space +} +zle -N expand-ealias + +# Bind the space key to the expand-alias function above, so that space will expand any expandable aliases +bindkey ' ' expand-ealias +bindkey '^ ' magic-space # control-space to bypass completion +bindkey -M isearch " " magic-space # normal space during searches + +# A function for expanding any aliases before accepting the line as is and executing the entered command +expand-alias-and-accept-line() { + expand-ealias + zle .backward-delete-char + zle .accept-line +} +zle -N accept-line expand-alias-and-accept-line |