-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
127 lines (108 loc) · 4.21 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
#!/usr/bin/env bash
# @see http://d.hatena.ne.jp/h_iijima/20110401/1301620545
alias e='emacsclient -n'
alias lr='ls -R' # recursive ls
alias ll='ls -l'
alias la='ll -lAB'
alias lx='ll -BX' # sort by extension
alias lz='ll -rS' # sort by size
alias lt='ll -rt' # sort by date
alias lm='la | more'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias cd..='cd ..'
alias rr='rm -rf'
alias grep='grep --color=auto'
alias mkdir='mkdir -p -v'
alias rmdir_r='find . -depth -type d | xargs rmdir 2> /dev/null'
alias rdom='echo `od -vAn -N4 -tu4 < /dev/urandom`'
alias da='date "+%A, %B %d, %Y [%T]"'
# http://www.reddit.com/r/commandline/comments/12g76v/how_to_automatically_source_zshrc_in_all_open/
trap "source ~/.bashrc" USR1
alias source-bashrc-all="pkill -usr1 bash"
alias updatedb='sudo /usr/libexec/locate.updatedb'
alias workmode='sudo workmode'
alias vaglogin='vagrant up && vagrant ssh'
alias vagssh='vagrant ssh'
alias be="bundle exec"
# git alias
if [ -e /usr/bin/git ]; then
alias ga='git add'
alias gal='git add --all'
alias gc='git commit'
alias gcm='git commit -m'
alias gs='git status'
alias gsb='git status -sb'
alias gps='git push'
alias gpl='git pull'
alias gch='git checkout'
alias gb='git branch'
alias gf='git diff'
alias gm='git merge'
alias gl='git log'
git config --global alias.co checkout
git config --global alias.st 'status'
git config --global alias.ci 'commit -a'
git config --global alias.di 'diff'
git config --global alias.br 'branch'
fi
# privileged access
if [ $UID -ne 0 ]; then
alias sudo='sudo '
alias scat='sudo cat'
alias svim='sudo vim'
alias root='sudo su'
alias reboot='sudo reboot'
alias halt='sudo halt'
# alias update='sudo pacman -Su'
alias netcfg='sudo netcfg2'
fi
if [[ $(uname) = 'Darwin' ]];then
alias chrome='open -a "Google Chrome"'
alias firefox='open -a Firefox'
alias safari='open -a Safari'
alias itunes='open -a iTunes'
alias show-hidefiles="defaults write com.apple.finder AppleShowAllFiles TRUE & killall Finder"
cpuinfo() {
"awk -F: ' {if(\$1 ~/^model name/){ model[\$2]=+1}} END{for(k in model) { print model[k], k}}' /proc/cpuinfo"
}
alias openports='netstat --all --numeric --programs --inet --inet6'
fi
# pacman aliases (if applicable, replace 'pacman' with 'yaourt'/'pacaur'/whatever)
if [[ $(uname -r) =~ ARCH$ ]]; then
alias pac="pacman -S" # default action - install one or more packages
alias pacu="pacman -Syu" # '[u]pdate' - upgrade all packages to their newest version
alias pacs="pacman -Ss" # '[s]earch' - search for a package using one or more keywords
alias paci="pacman -Si" # '[i]nfo' - show information about a package
alias pacr="pacman -R" # '[r]emove' - uninstall one or more packages
alias pacl="pacman -Sl" # '[l]ist' - list all packages of a repository
alias pacll="pacman -Qqm" # '[l]ist [l]ocal' - list all packages which were locally installed (e.g. AUR packages)
alias paclo="pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned
alias paco="pacman -Qo" # '[o]wner' - determine which package owns a given file
alias pacf="pacman -Ql" # '[f]iles' - list all files installed by a given package
alias pacc="pacman -Sc" # '[c]lean cache' - delete all not currently installed package files
alias pacm="makepkg -fci" # '[m]ake' - make package from PKGBUILD file in current directory
# @see https://wiki.archlinux.org/index.php/Bashrc#Aliases
alias yaupdate="yaourt -Syua --devel"
fi
# http://dharry.hatenablog.com/entry/2012/09/17/031850
function backup(){
cp -pr "$1{,.$(date +%Y-%m-%dT%H:%M:%S)";
}
# ex. $ pscan 192.168.0.0/24
function pscan(){
nmap -nsP "$1" | awk '{if($1=="Host") print $2 }';
}
function hist() {
history | grep "$1"
}
function show-hide-file (){
defaults write com.apple.finder AppleShowAllFiles -boolean "$1" && killall Finder
}
function dbash() {
command docker exec -it "$1" bash
}
function kbash() {
command kubectl exec -it "$1" bash
}