-
Notifications
You must be signed in to change notification settings - Fork 3
/
.aliases
115 lines (90 loc) · 4.18 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
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Navigational
alias ..="cd .."
alias ...="cd ../.."
alias d="cd $HOME/Desktop"
alias dl="cd $HOME/Downloads"
alias temp="cd $HOME/Downloads && mkd temp"
alias here="open ."
alias dev="cd $HOME/Development"
# Shortcuts
alias rm="trash"
alias rel="reload"
alias netest="ping www.google.be"
alias kf="killall Finder"
alias kd="killall Dock"
alias rmrf="/bin/rm -rf"
alias purge="sudo purge"
alias chmodx="chmod +x"
alias mime="file --mime-type"
# Applications
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
alias vlc="/Applications/VLC.app/Contents/MacOS/VLC"
alias stubru="curl -o- https://raw.githubusercontent.com/thibmaek/radioscripts/master/stubru | bash"
alias youtube-mp3="youtube-dl --extract-audio --audio-format mp3 --audio-quality 0"
alias copy="pbcopy"
alias grep="grep --color=auto"
alias textedit="open -a TextEdit"
# 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:'
else # macOS `ls`
colorflag="-G"
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi
# `ls` aliases
alias lsa="ls -AF"
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
alias lsf="ls -lF ${colorflag} | grep -v '^d'"
alias l="ls -lF ${colorflag}"
alias la="ls -lAF ${colorflag}"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# Force delete the trash
alias trashs="sudo /bin/rm -rf ~/.Trash/*"
# Gzip-enabled `curl`
alias gurl='curl --compressed'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
alias epoch="date +'%s'"
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# OS X has no `md5sum`, so use `md5` as a fallback
command -v md5sum > /dev/null || alias md5sum="md5"
# OS X has no `sha1sum`, so use `shasum` as a fallback
command -v sha1sum > /dev/null || alias sha1sum="shasum"
# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# Show/hide all desktop icons
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
alias bell="tput bel"
# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# 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}'
# Notify when a terminal task completes
alias hey="terminal-notifier -title 'Task completed' -message 'A terminal task completed/failed'"
# Get file permissions in octal format
alias octal="gstat -c \"%a %n\""
# Generate a random password
alias pass="dd if=/dev/urandom bs=1 count=30 2>/dev/null | base64 | cp_sanitized"
alias pass_ssl="openssl rand -base64 30 | cp_sanitized"
# HTTP Request aliases with lwp-request
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "${method}"="lwp-request -m '${method}'"
done
# Get a DD/MM/YY format date
alias date_dd_mm_yy="date +%x"
# Copy stdin and sanitize trailing newlines
alias cp_sanitized="tr -d '\n' | pbcopy"
# List available SERIAL/COM ports
alias list_serial_ports="ls /dev/{tty,cu}.*"