-
Notifications
You must be signed in to change notification settings - Fork 1
/
aliases
292 lines (245 loc) · 10.1 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/usr/bin/env zsh
# _ _
# __ _ | |(_) __ _ ___ ___ ___
# / _` || || | / _` |/ __| / _ \/ __|
# | (_| || || || (_| |\__ \| __/\__ \
# \__,_||_||_| \__,_||___/ \___||___/
#
# =================================================================
# Navigation
# =================================================================
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ~="cd ~"
alias -- -="cd -"
# =================================================================
# Environment
# =================================================================
alias path='echo $PATH | tr -s ":" "\n"'
# =================================================================
# Hardware
# =================================================================
# not used on PopOS
# alias notebook="xrandr --output eDP1 --auto --output DP2 --off"
# alias monitor="xrandr --output eDP1 --off --output DP2 --auto"
# alias dual="xrandr --output eDP1 --auto --left-of DP2 --output DP2 --auto"
# alias mirror="xrandr --output eDP1 --auto --same-as DP2 --output DP2 --auto"
# =================================================================
# Listing
# =================================================================
alias l="LC_COLLATE=c ls -F -1 --show-control-chars --color --group-directories-first"
alias ls="LC_COLLATE=c ls -F -1 --show-control-chars --color --group-directories-first"
alias ll="LC_COLLATE=c ls -lhF --show-control-chars --color --group-directories-first --time-style='+%d.%m.%Y %H:%M'"
alias la="LC_COLLATE=c ls -lhFA --show-control-chars --color --group-directories-first --time-style='+%d.%m.%Y %H:%M'"
alias le="less -FiMRX"
alias lesf="less +F"
alias bat="batcat"
alias df="df -h /"
alias tree="tree -I 'node_modules|.git'"
# =================================================================
# Editing
# =================================================================
alias e="nvim --listen /tmp/nvimsocket"
alias evimrc="$EDITOR ~/dotfiles/vimrc"
alias ezsh="$EDITOR ~/dotfiles/zshrc"
alias eenv="$EDITOR ~/dotfiles/zshenv"
alias ealias="$EDITOR ~/dotfiles/aliases"
alias efunc="$EDITOR ~/dotfiles/functions"
alias eterm="$EDITOR ~/dotfiles/kitty.conf"
alias ,fe="nvim -c \"lua require('telescope.builtin').oldfiles({ previewer = false })\""
# =================================================================
# Scripts
# =================================================================
alias p="project"
alias ias="ia-search"
alias iaf="ia-file"
# =================================================================
# Directories
# =================================================================
alias home="cd ~"
alias repo="cd ~/code"
alias lutr="cd ~/code/lukastrumm"
alias learn="cd ~/code/learning-progress"
alias dotf="cd ~/dotfiles"
alias down="cd ~/Downloads"
alias drop="cd ~/Dropbox"
alias sand="cd ~/sandbox"
alias iad="cd ~/ia"
# =================================================================
# npm, node, deno
# =================================================================
# 'nr' comes from @antfu/ni
alias nb="nr build"
alias np="nr preview"
alias nd="nr dev"
alias nl="nr lint"
alias ns="nr start"
alias nse="nr serve"
alias nt="nr --silent test"
alias nk="nr typecheck"
alias nv="nr validate"
alias nw="nr watch"
alias pn="pnpm"
alias pdx="pnpm dlx"
alias pex="pnpm exec"
alias pi="pnpm install"
alias pnu="pnpm add -g pnpm"
alias dt="deno task"
alias deps="cat package.json | json dependencies | json --items -a key value | sed 's/ /|/' | column -s '|' -t"
alias devdeps="cat package.json | json devDependencies | json --items -a key value | sed 's/ /|/' | column -s '|' -t"
alias scripts="cat package.json | json scripts | json --items -a key value | sed 's/ /|/' | column -s '|' -t"
alias mit="npx mit-license --name 'Lukas Trumm'"
# =================================================================
# Other programs
# =================================================================
alias apti="sudo apt-get install -y"
alias apts="apt search"
alias aptu="sudo apt-get update"
alias bsync="browser-sync start --server --files . --no-notify --open ."
alias cal="LC_TIME=cs_CZ.UTF-8 ncal -MC" # Show czech calendar with Monday as the first day of a week
alias copy="xsel -b"
alias d="docker"
alias dc="docker-compose"
alias ht="http --verify=no"
alias ipy="ipython"
alias md="cli-md"
alias py="python3"
alias python="python3"
alias tp="trash-put"
alias vag="vagrant"
alias xmlstar="xmlstarlet"
# =================================================================
# Git
# =================================================================
git_default_branch() {
local branch
# First look for my custom file named 'deafult_branch' in the git repo,
# where the name of the default branch should be specified
for dir in "." ".." "../.." "../../.."; do
key_file=$dir/.git/default_branch
if [ -f "$key_file" ]; then
branch=`cat "$key_file"`
break
fi
done
if [ -z "$branch" ]; then
branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's#^refs/remotes/origin/##')
elif [ -z "$branch" ]; then
branch=$(git remote show origin 2>/dev/null | grep "HEAD branch" | cut -d ":" -f 2)
elif [ -z "$branch" ]; then
branch="master"
fi
echo $branch
}
gcom() {
git switch $(git_default_branch)
}
alias ga="git add"
alias gaa="git add --all"
alias gco="git switch"
alias gcob="git switchit"
alias gcan="git commit --amend --no-edit"
alias wip="git commit --no-verify -m 'wip'"
alias galiases="git config --global --includes --get-regexp alias"
alias gd="git diff -- . ':!package-lock.json' ':!yarn.lock' ':!pnpm-lock.yaml'"
alias gds="git diff --staged -- . ':!package-lock.json' ':!yarn.lock' ':!pnpm-lock.yaml'"
alias gdw="git diff --color-words"
alias gcf="git clean -f"
alias gcd="git clean -d"
alias gchanged="git update-index --no-assume-unchanged"
alias gunchanged="git update-index --assume-unchanged"
alias glistunchanged="git ls-files -v|grep '^[[:lower:]]'"
alias gignored="git ls-files --other --ignored --exclude-standard"
logformat='log --graph --abbrev-commit --decorate --format=format:"%C(yellow)%h%C(reset) %C(cyan)%ci%x08%x08%x08%x08%x08%x08%x08%x08%x08%C(reset) %s %C(green)(%an)%C(reset)%C(bold green)%d%C(reset)"'
alias gl="git log --graph --decorate --oneline -n15"
alias gla="git log --graph --decorate --oneline"
alias gle="git log --graph --decorate --oneline --all -n15"
alias glea="git log --graph --decorate --oneline --all"
alias glmy="git log --graph --decorate --oneline --all -n15 --author=\"Lukas Trumm\""
alias glf="git $logformat -n8 --name-status"
alias gm="git $logformat -n15"
alias gma="git $logformat"
alias gme="git $logformat --all -n15"
alias gmea="git $logformat --all"
alias gmmy="git $logformat --all -n15 --author=\"Lukas Trumm\""
alias gfh="git $logformat --all --follow" # file history
alias gsf="git show --name-status"
alias gfe="git fetch"
alias gup="git stash save -u && git pull && git stash pop"
alias gre="git restore"
alias gre.="git restore ."
alias gres='git restore --staged'
alias greb="git rebase"
git-rem() { git rebase `git_default_branch` }
alias grem="git-rem"
alias grec="git rebase --continue"
git-fem() { git fetch origin `git_default_branch`:`git_default_branch`; git log --oneline `git_default_branch` @{1}..`git_default_branch` }
alias gfem="git-fem"
alias gst="git status"
alias gs="git status -s"
alias grs="git recursive-status"
alias gpu='[[ -z $(git config "branch.$(git symbolic-ref --short HEAD).merge") ]] && git push -u origin $(git symbolic-ref --short HEAD) || git push'
alias gul='git pull'
alias gundo='git reset --mixed HEAD~'
alias standup="git-standup"
alias myweek="git standup -d 8 -D 'short'"
git-gogo() { git checkout `git_default_branch` && git pull && git gone }
alias gogo="git-gogo"
alias i="issue"
alias il="gh issue list"
alias ila="gh issue list --state all"
alias gmt="git mergetool"
alias gsu="git submodule update"
alias gsur="git submodule update --remote"
alias chore="git commit -m 'chore'"
# =================================================================
# Lists
# =================================================================
alias zshkeys="cat ~/.zshrc | rg '# Alt' | sed 's/^# //'"
targets() {
make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' | sort -u | grep -v "Makefile\|Linux\|Darwin"
}
alias mak="targets"
# =================================================================
# Search
# =================================================================
# alias rg='rg ...'
# =================================================================
# Magic
# =================================================================
# Credit:
# - https://twitter.com/thingskatedid/status/1316075850580652032
# - https://www.benweintraub.com/2022/11/12/graphviz-in-the-terminal/
alias icat='kitty icat --align=left'
alias idot='dot -Efontsize=18 -Efontname=sans -Nfontname=sans -Tpng \
-Gbgcolor=black -Gcolor=#eee -Ecolor=#eee -Efontcolor=#eee -Ncolor=#eee -Nfontcolor=#eee \
| convert -trim -bordercolor black -border 20 -transparent black -resize '80%' - - \
| icat'
alias isvg='sed "s/currentColor/#eee/" | icat'
# =================================================================
# Zsh aliases
# =================================================================
if [[ $(echo $0) =~ "zsh" ]]; then
alias -g G="| grep -i"
alias -g H="| head"
alias -g T="| tail"
alias -g L="| less -FiMRX"
alias -g R="| rg"
alias -g C="| wc -l"
alias -g F="| fpp"
alias -g IN="..@{u}"
alias -g OUT="@{u}.."
alias -g UP="@{u}"
# Images
alias -s gif=gthumb
alias -s jpg=gthumb
alias -s png=gthumb
# Text
alias -s css=$EDITOR
alias -s java=$EDITOR
alias -s js=$EDITOR
alias -s md=$EDITOR
alias -s php=$EDITOR
alias -s txt=$EDITOR
fi