-
Notifications
You must be signed in to change notification settings - Fork 3
/
.zalias
119 lines (95 loc) · 3.73 KB
/
.zalias
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
# Implicit flags
alias rsync='rsync --progress'
alias mount='mount |column -t'
alias jobs='jobs -l'
alias ping='ping -c 5'
alias wget='wget -c'
# Always 'sudo' when rebooting
if [ $UID -ne 0 ]; then
alias reboot='sudo reboot'
fi
# Restore saved Vim session
alias vims='vim -S ~/.vim/session.vim'
# Open modified files tracked by Git in Vim
alias gim='vim $(git ls-files -m | grep -v "/build/") -p'
# Clean all Git branches that have been merged to master (clean merged)
alias gitcm='git checkout master; git pull origin master; git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
# Show Git status of current branch against master (start stat)
alias gitss='git diff --stat=120,100 origin/master...HEAD "$@"'
# Show Git diff of current branch against master (start diff)
alias gitsd='git diff origin/master...HEAD "$@"'
# Cut a branch from remote master (branch master)
alias gitbm='git checkout master; git pull origin master; git checkout -b "$@"'
# Colorful Git log (color log)
alias gitcl='git log --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
# Put display to sleep (OS X)
alias sleep='pmset displaysleepnow'
# Add space to Dock (OS X)
function addspace() {
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
}
# Change directory to forefront Finder window (OS X)
function finder() {
cd "`osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)'`"
}
# Get public IP
alias ip='dig +short myip.opendns.com @resolver1.opendns.com'
# Flush Directory Service cache
alias flush='dscacheutil -flushcache'
# Empty trash on all mounted volumes and main drive
alias emptytrash='sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash;'
# Start a HTTP webserver with optional port
function serve() {
local port="${1:-8000}"
open "http://localhost:${port}/"
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
# Perform a Google search for query
function google() {
open "http://www.google.com/search?q=${(j: :)@}"
}
# List the largest files in current directory
function largest() {
find ${1:-.} -type f -exec ls -al {} \; | sort -nr -k5 | head -n 20
}
# Generate a random string of characters
function strgen() {
local length="${1:-24}"
openssl rand -hex ${length}
}
# Get headers for request
alias headers='curl -I'
# Extract archive based on filetype
function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# List all socket connections
alias sockets='sudo lsof -i -P'
# Toggle display of hidden files within Finder
alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE; sudo killall Finder'
alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE; sudo killall Finder'
# Identify highest usage processes
alias topmem='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
alias topcpu='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
# Source custom alias file
if [[ -s "${ZDOTDIR:-$HOME}/.zalias-custom" ]]; then
source "${ZDOTDIR:-$HOME}/.zalias-custom"
fi