-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aliases
156 lines (125 loc) · 3.72 KB
/
.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
148
149
150
151
152
153
154
155
156
# Source 'before' file (if any).
if test -f "$HOME/.aliases.before" -a -r "$HOME/.aliases.before"; then
. "$HOME/.aliases.before"
fi
alias l='ls -lFh'
alias la='ls -lAFh'
alias ll='ls -l'
alias lt='ls -ltFh'
alias ldot='ls -ld .*'
alias grep='grep --color'
alias nt='nvim +term'
alias s=vimpager
alias rg='rg --smart-case'
alias tj='kill -TERM %1'
alias kj='kill -KILL %1'
# The global ignore file should contain uninteresting things (e.g. ctags).
alias ag='ag --path-to-ignore ~/.ignore'
# Skip annoying intro banner.
alias gdb='gdb -q'
# Very succint pylint output (only errors, warnings and grade).
alias pyl='pylint --disable=RP0001 --disable=RP0002 --disable=RP0003 --disable=RP0101 --disable=RP0401 --disable=RP0701 --disable=RP0801'
# This comes up often enough to warrant the alias
alias smi='sudo make install'
remake() {
make clean || return $?
if test $# -eq 0; then
make
else
make $@
fi
}
_current_city=$(curl ipinfo.io/city 2>/dev/null)
weather() {
if [ $# = 0 ]; then
location="$_current_city"
else
location=$1
fi
curl -4 "https://wttr.in/${location}"
}
# Ideally, whenver an interactive python session is wanted, this should invoke
# bpython and the regular interpreter otherwise (bpython seems to sometimes
# break when non-interactive).
_py() {
suffix=$1
if test $# -ne 0; then
shift
fi
# Consider all invocations with no arguments as interactive.
if test $# -eq 0; then
python$suffix -m bpython
else
python$suffix $@
fi
}
# An array would be nice.
set "" 2 3
for suffix; do
if python$suffix -m bpython -c "" &>/dev/null; then
alias py$suffix="_py \"$suffix\""
else
if command -v python$suffix > /dev/null; then
alias py$suffix=python$suffix
fi
fi
done
set --
# Interaction with neovim when running from its guest terminal.
if test -n "$NVIM_LISTEN_ADDRESS" -a -w "$NVIM_LISTEN_ADDRESS" \
-o "$NVIM" -a -w "$NVIM"; then
# vim's cwd might differ from the shell's, so we manually match it
alias v=nvim-host-cmd
alias e='nvim-host-cmd edit'
alias tabe='nvim-host-cmd tabedit'
alias sp='nvim-host-cmd split'
alias vsp='nvim-host-cmd vsplit'
alias bo='nvim-host-cmd botright'
alias to='nvim-host-cmd topleft'
vd() {
if [ $# != 2 ]; then
echo "Usage: vd <file1> <file2>" >&2
return
fi
nvim-host-cmd "e $1 | vert diffsplit $2"
}
# neovim messes with this and vim has issues because of it
# monitor: https://github.com/neovim/neovim/issues/9960#issuecomment-488262473
# (we shove this here because this file is sourced by all shells and we
# don't want it in .profile because we want non-login shells to source it).
unset VIMRUNTIME
# Reclaim incremental forward history search (and get rid of the idiotic
# stop).
# This should only be executed once, by a login shell; but it needs to be
# executed once for every instance of a neovim terminal, which don't start
# login shells.
stty stop undef && stty start undef || true
nvim_cd() {
nvim-host-cmd "execute \"lcd\" fnameescape(\"$(pwd)\") | file $$:$(pwd)/$(basename $SHELL)"
}
fi
# OS detection
OSTYPE=$(uname -s)
islinux() {
test $OSTYPE = "Linux"
}
isdarwin() {
test $OSTYPE = "Darwin"
}
isfreebsd() {
test $OSTYPE = "FreeBSD"
}
isopenbsd() {
test $OSTYPE = "OpenBSD"
}
issolaris() {
test $OSTYPE = "SunOS"
}
# Copies the "latest" screenshot to the current directory
cpss() {
cp $(readlink -f "$HOME/pictures/screenshots/latest") "$1"
}
# Source 'after' file (if any).
if test -f "$HOME/.aliases.after" -a -r "$HOME/.aliases.after"; then
. "$HOME/.aliases.after"
fi