-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.aliases
More file actions
204 lines (174 loc) · 6.46 KB
/
.aliases
File metadata and controls
204 lines (174 loc) · 6.46 KB
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
#!/usr/bin/env bash
# Update and set shortcuts
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Easier navigation
alias 1="cd .."
alias 2="cd ../.."
alias 3="cd ../../.."
alias 4="cd ../../../.."
alias -- -="cd -"
# Shortcuts
alias cda="cd ~/app"
alias cdc="cd ~/code"
alias cdw="cd ~/work"
alias cdl="cd ~/learn"
alias cde="cd ~/exercism"
alias cdf="cd ~/dotfiles"
alias cdp="cd ~/projects"
alias cdoc="cd ~/Documents"
alias cdow="cd ~/Downloads"
alias cdv="cd ~/.config/nvim"
alias cdswap="cd ~/.local/state/nvim/swap/"
# better default
alias mkdir="mkdir -p"
alias mv="mv -i"
alias df="df -h"
alias nv="nvim"
alias v="nvim"
alias t="tmux"
alias z="lazygit"
alias zz="lazydocker"
alias y="yazi"
alias ve="nvim ~/.extra"
alias bat="batcat" # bat on ubuntu is batcat
alias fd=fdfind # fd on ubuntu is fdfind
alias bundletool="~/app/bundletool.jar"
alias cu="~/app/Cursor-*-x86_64.AppImage --no-sandbox > /dev/null 2>&1"
# alias gcc="gcc -lcs50" # auto include CS50 library
# basic
alias so='source ~/dotfiles/bootstrap.sh -f'
alias c="clear"
alias l="ls -Ghal --color=auto"
alias off="poweroff"
# update system packages (or pacman -Syu)
alias asd="sudo nala update && sudo nala upgrade -y && flatpak update && bun upgrade --stable"
alias sni="sudo nala install -y"
alias snr="sudo nala remove -y"
alias snl="sudo nala list --upgradable"
# Golang related
# go test will output colors for PASS, FAIL and RUN
alias gt="go test -v --bench . --benchmem | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | sed ''/RUN/s//$(printf "\033[33mRUN\033[0m")/''"
# FVM, Flutter, and Dark related
# activate FVM with:
# dart pub global activate fvm
alias d="fvm dart"
alias f="fvm flutter"
alias fr="f run"
alias fdo="f doctor -v"
alias ep="f emulator --launch phone"
alias es="f emulator --launch small"
alias em="f emulator --launch medium"
alias el="f emulator --launch large"
alias et="f emulator --launch tablet"
# ~/shell/flutter_completion.bash
complete -F __flutter_completion f
# NOTE: git related
alias log="git log --all --oneline --graph"
alias gc="git commit -m"
alias gs="git status"
alias gf="git fetch --prune"
alias ga="git add ."
# git related
get_git_branch() {
git branch 2>/dev/null | grep "^*" | colrm 1 2
}
# example: "mhc ~/dotfiles main> "
# PS1="mhc \w $(get_git_branch)> "
# PS1="\w $(get_git_branch)> " # set in .bash_prompt
# NOTE:
# those dynamic get git branch must be use with single quote (') to preserve
# the string so that the function get_git_branch() will be called at runtime
# (when the alias is used) and we can get the branch name instead of calling
# the function at compile time (when the alias is defined) and the branch name
# won't change after we checkout to another branch
alias gp='git push origin $(get_git_branch)'
alias gpf='git push origin $(get_git_branch) --force'
alias gpl='git pull origin $(get_git_branch)'
alias gplf='git pull origin $(get_git_branch) --rebase --force'
# https://askubuntu.com/questions/62095/how-to-alias-git-to-g-so-that-bash-completion-rules-are-preserved
alias g='git'
source /usr/share/bash-completion/completions/git
__git_complete g __git_main # auto completion for 'g'
# Makefile related
alias ma="make all"
alias mr="make run"
alias mb="make build"
alias mc="make clean"
alias mt="make test"
# npm related
alias nsv="npm run server"
alias nw="npm run watch"
alias nb="npm run build"
alias nt="npm run test"
alias nd="npm run dev"
alias ni="npm install"
alias ns="npm start"
# yarn related
alias ysv="yarn run server"
alias yw="yarn run watch"
alias yb="yarn run build"
alias yt="yarn run test"
alias yd="yarn run dev"
alias yi="yarn install"
alias ys="yarn start"
# bun related
alias bsv="bun run server"
alias bw="bun run watch"
alias bb="bun run build"
alias bt="bun run test"
alias bd="bun run dev"
alias bi="bun install"
alias bs="bun start"
# dotnet related
alias dw="dotnet watch"
alias db="dotnet build"
alias dt="dotnet test"
alias dr="dotnet run"
alias dn="dotnet new"
alias di="dotnet restore"
alias deu="dotnet ef database update"
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Detect which `ls` flavor is in use
if ls --color >/dev/null 2>&1; then # GNU `ls`
colorflag="--color"
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
fi
# # List all files colorized in long format
# alias l="ls -lF ${colorflag}"
# # List all files colorized in long format, excluding . and ..
# alias la="ls -lAF ${colorflag}"
# # List only directories
# alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Get week number
alias week='date +%V'
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Merge PDF files, preserving hyperlinks
# Usage: `mergepdf input{1,2,3}.pdf`
# use '/usr/bin/gs' because 'gs' is 'git status' alias
alias mergepdf='/usr/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf'
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
# One of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "${method}"="lwp-request -m '${method}'"
done
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec ${SHELL} -l"
# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'