-
Notifications
You must be signed in to change notification settings - Fork 0
/
.sh_profile
145 lines (134 loc) · 4.06 KB
/
.sh_profile
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
export CLICOLOR=1
export EDITOR=/usr/bin/vim
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Set default blocksize for ls, df, du
export BLOCKSIZE=1k
# git commit for gpg
export GPG_TTY=$(tty)
# brew settings
export HOMEBREW_NO_ANALYTICS=1
unix_like () {
alias sudo='sudo '
}
macosx_only () {
alias ls='ls -GFh'
alias ll='ls -FGlhp'
alias la='ls -lAh'
alias which='type'
alias edit='subl'
alias dm='diffmerge'
alias flushDNS='dscacheutil -flushcache; sudo killall -HUP mDNSResponder'
alias redocker="test -z $(docker ps -q 2>/dev/null) && osascript -e 'quit app \"Docker\"' && open --background -a Docker"
alias brewery='brew update && brew upgrade && brew upgrade --cask && brew autoremove && brew cleanup && brew doctor'
alias brewdeps='brew deps --tree --installed'
brewrm () { brew rm $1 && brew rm $(join <(brew leaves) <(brew deps $1)); }
trash () { command mv "$@" ~/.Trash; }
alias fr='open -a Finder '
alias diff='colordiff'
alias down='sudo shutdown -r now'
alias update='omz update; mas upgrade; brewery'
}
linux_only () {
alias ls='ls -GFh --color'
alias ll='ls -FGlhp --color'
alias la='ls -FGlAhp --color'
alias which='type -a'
alias aptup='sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt clean -y && sudo apt autoclean -y'
alias dnfup='sudo dnf update -y && sudo dnf upgrade -y && sudo dnf autoremove -y && sudo dnf clean all'
alias yumup='sudo yum update -y && sudo yum upgrade -y && sudo yum clean all'
alias free='free -h'
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
alias cpuinfo='lscpu'
alias down='sudo shutdown -h now'
}
msys_only () {
alias sudo=''
}
if [[ "$OSTYPE" == "darwin"* ]]; then
macosx_only
elif [[ "$OSTYPE" == "linux"* ]]; then
linux_only
elif [[ "$OSTPYE" == "msys"* ]]; then
msys_only
else
echo "Unknown"
fi
# -----------------------------
# MAKE TERMINAL BETTER
# -----------------------------
alias cp='cp -iv'
alias mv='mv -iv'
alias mkdir='mkdir -pv'
alias less='less -FSRXc'
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
alias cd..='cd ../'
alias ..='cd ../'
alias ...='cd ../../'
alias ~="cd ~"
alias c='clear'
alias q='exit'
alias path='echo -e ${PATH//:/\\n}'
alias show_options='shopt'
alias fix_stty='stty sane'
alias cic='set completion-ignore-case On'
alias sludo='sudo '
alias vi='vim'
alias vf='vimdiff'
alias wget='wget -c'
alias untar='tar -zxvf '
alias df='df -H'
alias du='du -ch'
alias resh="exec $SHELL"
alias f='find . -iname'
alias editHosts='sudo vim /etc/hosts'
alias myip='curl ip.gs' # curl ipinfo.io/ip
alias netCons='lsof -i'
alias openPorts='sudo lsof -i | grep LISTEN'
alias lsock='sudo lsof -i -P'
alias lsockU='sudo lsof -nP | grep UDP'
alias lsockT='sudo lsof -nP | grep TCP'
alias sha256='shasum -a 256 '
alias sha1='shasum '
alias ping='ping -c 5'
alias h='history'
alias j='jobs -l'
alias hg='history | grep '
alias g=git
# -----------------------------
# Functions
# -----------------------------
cd () { builtin cd "$@"; ls -al; }
mcd () { mkdir -p "$1" && cd "$1"; }
mans () {
man $1 | grep -iC2 --color=always $1 | less
}
zipf () { zip -r "$1".zip "$1" ; }
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar xvJf $1 ;;
*.tar.lzma) tar --lzma xvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.dmg) hdiutul mount $1 ;; # mount OS X disk images
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}