blob: 0539b2f84c51b71f055cb5363eed42c7c555c5f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
if [ -n '$TMUX' ]; then
function refresh {
export SSH_AUTH_SOCK="$(tmux show-environment | grep '^SSH_AUTH_SOCK' | cut -d '=' -f 2)"
export SSH_AUTH_KEY="$(tmux show-environment | grep '^SSH_AUTH_KEY' | cut -d '=' -f 2)"
export SSH_CONNECTION="$(tmux show-environment | grep '^SSH_CONNECTION' | cut -d '=' -f 2)"
export DISPLAY="$(tmux show-environment | grep '^DISPLAY' | cut -d '=' -f 2)"
}
else
function refresh { }
fi
# 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
abbrev-alias g="git"
abbrev-alias gst="git status"
abbrev-alias gcb="git checkout --branch"
abbrev-alias ll="ls -l"
|