-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.zsh_aliases
146 lines (127 loc) · 3.93 KB
/
.zsh_aliases
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# vim: ft=zsh
# Zsh suffix aliases
local _text_fts=(log conf md yaml inl asc txt TXT tex)
local _source_fts=(cpp cxx cc c hh hpp h java pde)
local _web_source_fts=(htm html xhtml xml json js jsx css scss)
local _editor_fts=($_text_fts $_source_fts $_web_source_fts)
for ft in $_editor_fts; do
alias -s $ft=$EDITOR
done
alias -s com="w3m"
alias -s org="w3m"
alias -s net="w3m"
# open aliases, see .zsh_functions
alias -s xcodeproj="o"
alias -s pdf="o"
alias -s zip="als"
alias -s tar="als"
alias -s rar="als"
alias -s 7z="als"
alias -s git="clo"
alias -s exe="mono"
# Sound bell after these commands
alias m="bo make"
alias zou="bo zou"
alias ssh="bo ssh"
alias brew="bo brew"
alias hub="bo hub"
# Automatically Expanding Global Aliases (tab key to expand)
# references: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() {
if [[ $LBUFFER =~ '[A-Z0-9]+$' ]]; then
zle _expand_alias
zle expand-word
fi
zle expand-or-complete
}
zle -N globalias
bindkey "^I" globalias # tab key to expand globalalias
setopt extendedglob
typeset -Ag abbreviations
abbreviations=(
'cm' 'git commit -m "__CURSOR__"'
'a' 'git add'
'co' 'git checkout'
'cob' 'git checkout -b'
'com' 'git checkout master'
'gm' 'git merge'
'grs' 'git reset'
'gca' 'git commit --amend'
'gcv' 'git commit -v'
'gd' 'git diff'
'gdc' 'git diff --cached'
'lg' 'git lg'
'pu' 'git push'
'nt' 'n test'
'ntw' 'n test --watch'
'na' 'n add'
'nu' 'n uninstall'
'lgh' 'git lg -n10'
'gdmb' 'git diff master...HEAD'
'stash' 'git stash push -m "__CURSOR__"'
'show' 'git show'
)
magic-abbrev-expand() {
local MATCH
LBUFFER=${LBUFFER%%(^| )(#m)[_a-zA-Z0-9]#}
command=${abbreviations[$MATCH]}
LBUFFER+=${command:-$MATCH}
if [[ "${command}" =~ "__CURSOR__" ]]; then
RBUFFER=${LBUFFER[(ws:__CURSOR__:)2]}
LBUFFER=${LBUFFER[(ws:__CURSOR__:)1]}
else
zle self-insert
fi
BUFFER=${BUFFER%%}
zle reset-prompt
}
no-magic-abbrev-expand() {
LBUFFER+=' '
}
accept-line() {
zle magic-abbrev-expand
zle .accept-line
}
zle -N magic-abbrev-expand
zle -N no-magic-abbrev-expand
# zle -N accept-line
bindkey " " magic-abbrev-expand
bindkey "^x " no-magic-abbrev-expand
bindkey -M isearch " " self-insert
# http://www.zzapper.co.uk/zshtips.html
alias -g ND='*(/om[1])' # newest directory
alias -g NF='*(.om[1])' # newest file
#alias -g V='| vim -R -'
alias -g V='--version'
#alias -g L='| $PAGER'
alias -g WC='| wc -l'
alias -g H='| head'
alias -g H1='| head -1' # first line only
alias -g 1H='| tail -n +2' # omit first line
alias -g 1T='| sed \$d' # omit last line
alias -g FZ='| fzf | pbcopy'
alias -g TL='| tail'
alias -g 2L='| tr "\n" " "'
alias -g 2R='| tr " " "\n"'
alias -g G='| egrep'
alias -g GM='`sb . | tail -n +2 | egrep "^\s[MD]" | cut -c 4- | tr "\n" " "`'
alias -g GU='`sb . | tail -n +2 | egrep "^\s?U" | cut -c 4- | tr "\n" " "`'
alias -g GQ='`sb . | tail -n +2 | egrep "^\s?\?" | cut -c 4- | tr "\n" " "`'
alias -g P='| pbcopy'
alias -g FZ='| fzf -m'
alias -g FZP='| fzf -m | pbcopy'
alias -g NE='2> /dev/null'
alias -g NO='&>|/dev/null'
alias -g DN='> /dev/null 2>&1'
alias -g DNA='> /dev/null 2>&1 &'
alias -g MD='mv ~/Downloads/*(.om[1]) .; ls'
alias -g NO='--name-only'
alias -g BF='`ba | fzf -m | tr "\n" " "`'
alias -g GF='`git -c color.status=always status -s | fzf -m --ansi --preview "echo {} | cut -c4- | xargs git diff --color=always" | cut -c4- | tr "\n" " "`'
alias -g SL='git stash apply `git -c color.status=always sl | fzf --ansi --preview "echo {} | cut -c 1-10 | xargs git show --color=always" | cut -c 1-10 | tr "\n" " "`'
alias -g SR='| sort -nr'
alias -g CC='gcc -Wall -Werror -std=c11 -g -o *.c(.om[1]:r) *.c(.om[1])'
alias -g CPP='g++ -Wall -Wextra -pedantic -std=c++1z -g -o *.cpp(.om[1]:r) *.cpp(.om[1])'
alias -g CT='clang-tidy -checks=\* -extra-arg=-std=c++17 *.cpp(.om[1])'
alias -g A='./*(.om[1])'