-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
133 lines (96 loc) · 5.09 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
128
129
130
131
132
133
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
###############################################################################
# Navigation #
###############################################################################
# Folders
alias h='cd ~' # home
alias r='cd /' # root
alias d="cd ~/Desktop"
alias p="cd ~/Projects"
###############################################################################
# List Utilities #
###############################################################################
# Always use color output for `l`
alias l="ls ${colorflag}"
# List all files colorized in long format
alias ll="ls -lhF ${colorflag}"
# List all files colorized in long format, including dotfiles
alias la="ls -lhaF ${colorflag}"
# List only directories
alias ld="ls -lahd ${colorflag} */"
alias lad="ls -lhaF ${colorflag} | grep --color=never '^d'"
# List current directory
alias lc="ls -lhd $(pwd)"
# list paths include in environment variable PATH
alias path="echo $PATH | tr ':' '\n'"
###############################################################################
# Utilities #
###############################################################################
# Search history - requires one input
alias shist='history | grep $1'
# Gzip-enabled 'curl'
alias gurl='curl --compressed'
# Get week number
alias week='date +%V'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Merge PDF files - `mergepdf -o output.pdf input{1,2,3}.pdf`
alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'
# Commands for Volume Control
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 7'"
# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# 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"
# Hide/show all desktop icons (useful when presenting)
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
# Quickly access dotfiles
alias dotals="${=EDITOR} ~/.aliases"
alias dotboot="${=EDITOR} ~/.config/yadm/bootstrap"
alias dotbrew="${=EDITOR} ~/.Brewfile"
alias dotexp="${=EDITOR} ~/.exports"
alias dotfun="${=EDITOR} ~/.functions"
alias dotmacos="${=EDITOR} ~/.macos"
alias dotrc="${=EDITOR} ~/.zshrc"
# Command-line GUI tool to handle git operations
alias lg="lazygit"
###############################################################################
# Cleanup #
###############################################################################
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# Empty the Trash on all mounted volumes and the main HDD
# Also, clear Apple’s System Logs to improve shell startup speed
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
# Clean global npm packages
alias npmclean='npm ls -gp --depth=0 | awk -F/ "/node_modules/ && !/\/npm$/ {print $NF}" | xargs npm -g rm'
###############################################################################
# Process #
###############################################################################
alias threads='ps -M -p $(pgrep $1)'
###############################################################################
# Network #
###############################################################################
# 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 }'"
# Enhanced WHOIS lookups
alias whois="whois -h whois-servers.net"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# list open internet files and its ports
alias listport="lsof -i"