-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh_aliases
147 lines (125 loc) · 4 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
146
147
# ~/.zsh_aliases: sourced by ~/.shrc
# echo "### .zsh_aliases at `date`"
# Shortcut commands
alias catc='grep -h -e "^[[:space:]]*#" -e ^\;'
alias catn='grep -hv -e ^$ -e "^[[:space:]]*#" -e ^\;'
alias cls='clear'
alias cpr='cp -Rp'
alias df='df -Hl'
alias du='du -sh'
alias hexd="od -a -t x1"
alias hgr='fc -lI 1 -1 | egrep'
alias hgrt='_hgrt' # Search recent history, return last 20 matches
alias hgrz='_hgrz' # Search all history, sort -u matches
alias ht='fc -l' # Tail history
alias more='less'
alias od="od -ab"
alias psx='ps -ef | head -1; ps -ef | egrep'
alias sttysane='stty sane; stty iexten erase "^?" kill ^U intr ^C susp ^Z'
if type -p shfmt >/dev/null; then
alias shf='shfmt -i 4 -s' # Default shell format
alias shfl='shfmt -i 4 -s -l' # List files whose formatting would change
alias shfd='shfmt -d -i 4 -s' # Shell format with diff if file would change
alias shff='shfmt -f' # Recursively find all shell files and print the paths
fi
# If rualdi exists, create a command to both add a rualdi alias and export it
[ -x ~/.cargo/bin/rualdi ] && alias radx='_radx'
# TERM number of color settings
alias xt-16='export TERM=xterm'
alias xt-88='export TERM=xterm-88color'
alias xt-256='export TERM=xterm-256color'
# Directory listings
# normal
alias ls='ls $COLOR_AUTO'
alias lsa='ls -A $COLOR_AUTO'
# with special chars to indicate file type
alias l='ls -CF'
alias la='ls -AF'
# If exa is installed
if type -p exa >/dev/null; then
alias ll='exa --git -s Name --colour=always -lg'
alias lla='exa --git -s Name --colour=always -lga'
alias llh='_lwh' # Most recent 20
alias llt='_lwt' # Today only
alias llr='exa --git -s Name --colour=always -lgR' # Recurse
alias lls='exa --git -s size -r --colour=always -lg' # size
# Dirs first, then by extension - both without & with gitignored files
alias lw='exa --git --git-ignore --group-directories-first -s ext --colour=always -lg'
alias lwg='exa --git --group-directories-first -s ext --colour=always -lg'
else
alias ll='ls -l $COLOR_AUTO'
alias lla='ls -lA $COLOR_AUTO'
alias llh='_llh' # Most recent 20
alias llt='_llt' # Today only
alias llr='ls -lR $COLOR_AUTO'
alias lls='_lls' # size
fi
# ssh shortcuts to various systems
# p m g -- see id_rsa
#
if [[ "$(uname -n)" == *[Ll]ocal ]]; then
ssh-ho='ssh monty@holmes.local $@'
ssh-ir='ssh monty@irene.local $@'
fi
# Functions
findf() { # Find file by name
find . -name $*
}
finds() { # Find file by initial string in name
find . -name $*\*
}
findw() { # Find words (case insensitive) in files - to check for capitalization typos
grep -h -o -E '\w+' $2 | sort -u | grep -i $1
}
_hgrt() {
fc -lI 1 -1 | egrep $@ | tail -20
}
_hgrz() {
fc -lLn 1 -1 | egrep $@ | sort -u
}
_llh() {
ls -lt $@ | head -20
}
_lwh() {
exa --git -s date -r --colour=always -lg $@ | head -20
}
_llt() {
today=$(date "+%b %e")
ls -lt $@ | grep " $today "
}
_lwt() {
today=$(date "+%e %b")
exa --git -s date -r --colour=always -lg $@ | grep "$today "
}
_lls() {
ls -l $@ | grep -v ^d | sort -nr --key=5
}
_radx() {
rualdi add $@
export $1=$(rualdi resolve $1)
}
# From various distros
colors() {
local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[43mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors
for fgc in {30..37}; do
# background colors
for bgc in {40..47}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done
echo
echo
done
}
# end of .zsh_aliases