-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
125 lines (112 loc) · 4.14 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
# 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;34: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:'
else # OS X `ls`
colorflag="-G"
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
fi
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# List all files colorized in long format
alias ll='ls -lh'
# List all files colorized in long format, including dot files
alias la="ls -lhaF"
# List only directories
alias lsd='ls -l | grep "^d"'
# Homebrew stuffs or apt-get
if [[ "$(uname)" == "Darwin" ]]; then
alias update="brew update"
alias upgrade="brew upgrade"
alias cleanup="brew cleanup"
alias install="brew install"
alias doctor="echo '\nDoctor? Doctor who?\n' && brew doctor"
alias uud="update; upgrade; cleanup; doctor; brew doctor --verbose"
else
alias update="sudo apt update"
alias upgrade="sudo apt upgrade"
alias cleanup="sudo apt autoremove"
alias install="sudo apt install"
alias uud="sudo apt update && sudo apt upgrade && sudo apt autoremove && sudo apt clean && sudo apt --fix-broken install"
fi
alias ood="uud"
# Httpie
alias https='http --default-scheme=https'
# Activate a virtual environment in venv/ or .venv/ folder
alias activate='source "$( [ -d "venv" ] && echo "venv" || echo ".venv" )/bin/activate"'
# Re-establish venv python symlinks after homebrew breaks (upgrades) them
alias venvfix="gfind ./venv -type l -xtype l -delete && virtualenv venv"
# Python
alias venv='python -m venv .venv'
alias venv3='python3 -m venv .venv'
alias virtualenv3='virtualenv -p python3'
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
# Git related stuff
alias master='git checkout master'
alias main='git checkout main'
alias branches='git branches'
alias co='git checkout'
alias cob='git checkout -b'
function cobu() {
git checkout -b $1
git push -u origin $1
}
alias remote='git remote -v'
alias pull='git pull'
alias push='git push'
alias fetch='git fetch -p'
alias branch='git branch'
alias commit='git commit'
alias merge='git merge'
alias fp='fetch && pull'
# Docker
alias docker='nocorrect docker'
alias dcomp='docker-compose'
alias dmstp='docker-machine stop default'
# Remove dangling <none> images in docker - see http://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/
alias dclean='docker rm `docker ps -aq`; docker rmi $(docker images -f "dangling=true" -q); echo "\ndone!"'
alias dcdu='dcomp down; dclean; dcomp up'
alias dmed='eval $(docker-machine env default)'
# Node
alias ys='yarn start'
alias ns='node start'
# Wireguard
alias wgu='wg-quick up ~/.config/wireguard/wg0.conf'
alias wgd='wg-quick down ~/.config/wireguard/wg0.conf'
# Utility commands (mostly from https://news.ycombinator.com/item?id=9869231)
if [[ "$(uname)" == "Darwin" ]]; then
alias o='open'
else
alias o='xdg-open'
fi
alias q='exit'
alias c='clear'
alias mem='top -l1 | grep PhysMem'
alias cpu='top -l1 | grep CPU\ usage'
# Search process by name and highlight
function psgrep() { ps axu | grep -v grep | grep "$@" -i --color=auto; }
# Search for files and page it
function search() { find . -iname "*$@*" | less; }
# just run "up" to "cd ..", or run "up 6" to "cd ../../../../../.."
function up {
if [[ "$#" < 1 ]] ; then
cd ..
else
CDSTR=""
for i in {1..$1} ; do
CDSTR="../$CDSTR"
done
cd $CDSTR
fi
}
# cd commands followed by ls
alias ..='cd .. && ls'
alias ...='cd ../.. && ls'
alias ....='cd ../../.. && ls'
alias .....='cd ../../../.. && ls'
alias ......='cd ../../../../.. && ls'
alias -- -='cd - && ls'
# Fun commands :3
alias please='sudo '
alias rip='sudo pkill '