-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
75 lines (62 loc) · 1.77 KB
/
.functions
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
# ~/.functions
# =================================
function serve() {
PORT=${1:-8000}
http-server -c-1 -o -p "$PORT"
}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# find shorthand
function f() {
find . -name "$1" 2>&1 | grep -v 'Operation not permitted'
}
# Use Mac OS Preview to open a man page in a more handsome format
function manp() {
man -t $1 | open -f -a /Applications/Preview.app
}
## output directory/file tree, excluding ignorables
function tre(){
tree -aC -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst "$@"
}
function ipinfo(){
curl ipinfo.io/$1
}
# Get local IP address
function myip() {
ifconfig | \
sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
}
function showdotfiles() {
defaults write com.apple.finder AppleShowAllFiles -bool true
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
function hidedotfiles() {
defaults write com.apple.finder AppleShowAllFiles -bool false
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
function hidedesktop() {
defaults write com.apple.finder CreateDesktop -bool false
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
function showdesktop() {
defaults write com.apple.finder CreateDesktop -bool true
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
function clonebranch() {
git clone $1 --branch $2 --single-branch;
}
# takes a port and ends the process running on that port
function killport() {
pid=$(lsof -i:$1 -t);
kill -TERM $pid || kill
}