-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aliases.macos
96 lines (75 loc) · 3.98 KB
/
.aliases.macos
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
#!/bin/bash
# Specific macos aliases
# vim: syntax=sh
# See https://github.com/mathiasbynens/dotfiles/blob/master/.aliases
# Override some useful commands
command -v gdate &>/dev/null && alias date='gdate'
command -v gsed &>/dev/null && alias sed='gsed'
command -v gtimeout &>/dev/null && alias timeout='gtimeout'
command -v gxargs &>/dev/null && alias xargs='gxargs'
command -v ggrep &>/dev/null && alias grep='ggrep --color'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; update-prezto'
# IP addresses
alias localip="ipconfig getifaddr en0"
# Flush Directory Service cache
alias flush='dscacheutil -flushcache && killall -HUP mDNSResponder'
# 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'
# 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'
# 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 hidedesktop='defaults write com.apple.finder CreateDesktop -bool false && killall Finder'
alias showdesktop='defaults write com.apple.finder CreateDesktop -bool true && killall Finder'
# Mute/Unmute the system volume. Plays nice with all other volume settings.
alias mute="osascript -e 'set volume output muted true'"
alias unmute="osascript -e 'set volume output muted false'"
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
# (useful when executing time-consuming commands)
alias badge='tput bel'
# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Defaults
alias 'defaults.list=rc="\n" && defaults domains | sed s/,/"$rc"/g'
# Lock the screen (when going AFK)
alias afk='/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'
# which resolver I use
alias net-dns-resolver='scutil --dns | head'
# update blacklist domains
function net-dns-update-blacklist() {
dest='/etc/dnscrypt-proxy-blacklist.txt'
source='https://download.dnscrypt.info/blacklists/domains/mybase.txt'
echo "Update ${dest} from ${source}"
sudo curl -Ls -o "${dest}" "${source}"
}
# shellcheck disable=SC2016
function net-dns-local-enable() {
net-update-interfaces 'sudo networksetup -setdnsservers "$interface" "127.0.0.1"'
}
# shellcheck disable=SC2016
function net-dns-local-disable() {
net-update-interfaces 'sudo networksetup -setdnsservers "$interface" "Empty"'
}
# Update interfaces config, usefull to set Proxies, DNS etc ...
function net-update-interfaces() {
networksetup -listallnetworkservices | while read -r interface; do
if [[ "$interface" =~ LAN || "$interface" == Wi-Fi ]]; then
eval "$1" && print "${1//\$interface/$interface}"
fi
done
}
function net-recreate-automatic() {
sudo networksetup -createlocation 'tmp' populate &>/dev/null
sudo networksetup -switchtolocation 'tmp'
# Automatic
sudo networksetup -deletelocation 'Automatic' || true
sudo networksetup -createlocation 'Automatic' populate
sudo networksetup -switchtolocation 'Automatic'
}