-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_aliases
More file actions
176 lines (151 loc) · 4.96 KB
/
.bash_aliases
File metadata and controls
176 lines (151 loc) · 4.96 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#
# UNIX - General
#
alias v='nvim'
alias h='history'
alias c="clear" # easier on the thumb vs cmd+k
alias x='exit 0'
alias p='pwd'
alias ..='cd ..' # up one
alias ....='cd ../..' # up two
alias cdd='cd -' # back
# cd then ls
cd() { builtin cd "$@"; ls -HG; }
# change dir then clear output
cc() { cd $*; clear; }
# change directory, clear output, then list contents
ccl() { cd $*; clear; ls -FG; }
alias l="tree -C -L 1" # show a quick tree of files
alias la='tree -C -a -L 1' # also list hidden files (think "list all")
alias ls="ls -FGh" # color list output with directory markers by default
alias ll='ls -lhFGh | cut -c 2-11,27-34,48-' # show permissions, filesize, name
alias lal="ls -alhFG | cut -c 2-11,28-34,48-" # show permissions, filesize, name for all files
alias lg="ls | grep" # pass in string to get specific ls results
alias lns="ln -s" # symlink in 2 less characters
alias cl="clear; tree -C -L 1" # clear and show a quick tree
alias cla="clear; tree -C -a -L 1" # clear and show a quick tree of all files
alias op="open ./" # open your current dir in Finder and accept defeat
alias rmrf="rm -rf" # as if bricking your machine wasn't easy enough
alias rmrfp="rm -rfp" # you could say that again
alias mkdirp='mkdir -p' # nesting
take() { mkdir -p $1; cd $1; }
alias chx='chmod +x' # make it executable
alias chR='chmod -R' # recursive
if [ $OSNAME == 'Linux' ]; then
if [ command -v xsel >/dev/null ]; then
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
elif [ command -v xclip >/dev/null ]; then
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
fi
fi
alias tails='tail -F $(find . -type f -not -name '*.tar' -not -name '*.gz' -not -name '*.zip' -not -path '*.git*' -not -path '*.svn*' -not -path '*node_modules*' | grep -e '/log/' -e '/logs/' -e '\.log')'
alias lmk="say 'Process complete.'" # pin to the tail of long commands
#
# UNIX - Nifties
#
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias getwebsite="wget -r --no-parent" # download entire directory of web site
#
# programs
#
alias ai="sudo apt install"
alias aud="sudo apt update"
alias aug="sudo apt upgrade"
#
# OSX - Nifties
#
# Quick-look a file (^C or space to close)
alias ql='qlmanage -p 2>/dev/null'
# lock screen
alias lock='/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'
# Save a screen shot to current directory. 1s delay provided for app switching.
alias snap='screencapture -T 1 "Screen Shot $(date +'%Y-%m-%d') at $(date +"%I.%M.%S %p").png"'
# silent ninja snap
alias snapx='screencapture -T 1 -x "Screen Shot $(date +'%Y-%m-%d') at $(date +"%I.%M.%S %p").png"'
alias mute="osascript -e 'set volume output muted true'"
alias unmute="osascript -e 'set volume output muted false'"
#
# WEB (OSX)
#
pagespeed() { open "https://developers.google.com/speed/pagespeed/insights/?url=$1"; }
# search websites
yt() {
IFS='+' # make + the default space char
open https\://www.youtube.com/results\?search_query="$*"&oq="$*"
unset IFS # back to normal mode
}
ggl() {
IFS='+' # make + the default space char
open https\://www.google.com/\?\&q\="$*"
unset IFS # back to normal mode
}
gith() {
IFS='+' # make + the default space char
open https\://github.com/search\?q="$*"
unset IFS # back to normal mode
}
amaz() {
IFS='+' # make + the default space char
open http\://www.amazon.com/s/\?field\-keywords\="$*"
unset IFS # back to normal mode
}
# set timers
timer() {
if [ "$1" -gt 0 ]
then
open "http\://e.ggtimer.com/"$1"%20minutes"
else
echo "Please enter an integer greater than 0."
fi
}
morning() {
open http\://e.ggtimer.com/morning
# (can help get your blood pumping)
}
pomodoro() {
open http\://e.ggtimer.com/pomodoro
# (does one 25/5 minute cycle)
}
tabata() {
open http\://e.ggtimer.com/tabata
# (8 reps of 20/10 second intervals)
}
brushteeth() {
open http\://e.ggtimer.com/brushteeth
# (for healthy teeth)
}
meditate() {
open "http://www.getsomeheadspace.com/pages/account/myheadspace.aspx"
}
# 2048() {
# open "http://gabrielecirulli.github.io/2048/"
# }
# lookup a command at explainshell.com
explain() {
CMD=$(python -c "import urllib, sys; print urllib.quote_plus(sys.argv[1])" "$*")
open "http://explainshell.com/explain?cmd=$CMD"
}
# ff - fuzzy cd from anywhere
# default scope is $HOME
# USAGE: ff [NAME] [PATH]
# inspired by
# https://github.com/junegunn/fzf/wiki/examples#changing-directory
ff() {
if [ "x$1" != "x" ]; then
name="$1"
else
name='*'
fi
if [ "x$2" != "x" ]; then
path="$2"
else
path="$HOME"
fi
dir=$(find "$HOME" -type d -name "$name" |
fzf --ansi --preview="ls -lAFhG $(echo {+1})" --preview-window="up:60%")
cd "$dir" || exit 1
}