Repository navigation
Expand file tree
/
Copy path.bash_profile
More file actions
254 lines (209 loc) · 8.3 KB
/
Copy path.bash_profile
File metadata and controls
254 lines (209 loc) · 8.3 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# Add ``~/bin` to the `$PATH`
export PATH="$HOME/bin:$PATH";
export PATH="/usr/local/sbin:$PATH"
source ~/.bashrc
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Shortcuts
alias d="cd ~/Documents"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias g="git"
alias h="history"
# List all files colorized in long format
alias l="ls -lF ${colorflag}"
# List all files colorized in long format, including dot files
alias la="ls -laF ${colorflag}"
# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
# Optimize all images in a folder
alias optimize='image_optim *.{jpg,png,gif,svg}'
# Get week number
alias week='date +%V'
# brew doctor
alias brewdoc='brew doctor'
# update homebrew
alias brewup='brew update'
# list outdated homebrew packages
alias brewout='brew outdated'
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# 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"
# 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"
# 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"
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 7'"
# Find CPU hogs
alias mem_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
# Show party parrot in terminal.
alias party='curl parrot.live'
# Watch Star Wars in ASCII.
# If telnet is not installed, run `brew install telnet` on macOS.
alias starwars='telnet towel.blinkenlights.nl'
# Turn the terminal-screen into matrix-style gibberish.
alias matrix='LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh
else
local arg=-sh
fi
if [[ -n "$@" ]]; then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
}
# Change directory to the current Finder directory
# cdf to open the Finder directory in the terminal and `open .` to open in Finder
# the cwd.
function cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
# `a` with no arguments opens the current directory in Atom Editor, otherwise
# opens the given location
function a() {
if [ $# -eq 0 ]; then
atom .
else
atom "$@"
fi
}
# Defines transfer alias and provides easy command line file and folder sharing.
# https://gist.github.com/nl5887/a511f172d3fb3cd0e42d
if [ -e "$HOME/.transfer" ]
then
source "$HOME/.transfer"
else
echo "transfer function not found. make sure $HOME/.transfer exists."
fi
alias f="fork open"
alias gs='git status'
alias gaa='git add -A'
alias gdiff='git diff --color-words -w'
alias gclean='git gc --prune=now && git remote prune origin'
alias glog='git log --graph --oneline --all --decorate'
alias glogo='glog `git reflog | cut -c1-7`'
alias gstats='git shortlog -sn --all --no-merges'
alias grecent='git for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"'
alias grecap='git log --all --oneline --no-merges --author=brock.boren@gmail.com'
alias goverview='git log --all --oneline --no-merges'
alias gtoday='git log --since=00:00:00 --all --no-merges --oneline --author=brock.boren@gmail.com'
alias gupstream='git log --oneline --no-merges HEAD..<remote>/<branch>'
alias glocal='git log --oneline --no-merges <remote>/<branch>..HEAD'
alias ggraph='git log --graph --all --decorate --stat --date=iso'
alias gchangelog='git log --oneline --no-merges <last tag>..HEAD'
function goops {
git commit -a --amend
gs
}
function gwut {
echo "
- - - - - - - - - - - - - -
Git Convenience Shortcuts:
- - - - - - - - - - - - - -
gwut - List all Git Convenience commands and prompt symbols.
gs - git status
gaa - Add all changes (including untracted files) to staging
gc \"Message\" - Commit all new files & changes with message
goops - Add changes to previous commit & edit comessage
gp - Pull (via rebase) then push
gup - Pull (via rebase)
glog - Decorated & graphed log
glogo - As glog, including orphan commits
gdiff - A word-diff of changes with whitespace removed. Add --word-diff to show only changed words.
gclean - Compress & garbage collect data store
gstats - Summary of git log. (--since='2 weeks') can be used to limit timeframe.
grecent - See which branches you recently worked on.
grecap - See what you've been up to.
goverview - See what everyone's been up to.
gtoday - A summary of work done since midnight.
gupstream - Check which changes you're about to pull. (git log --oneline --no-merges ..origin/feature/fonts)
glocal - Check what you're about to push. This logs the commits that <remote>/<branch> needs before it resembles HEAD. (git log --oneline --no-merges origin/feature/fonts..HEAD)
ggraph - View complex logs.
gchangelog - Generate a changelog. (git log --oneline --no-merges <last tag or last commit hash>..)
- - - - - - - - - - - - - -
Prompt Symbols:
- - - - - - - - - - - - - -
The prompt shows the current branch & among other helpful things:
* - Uncommitted changes
+ - Staged changes
% - Untracked files
< - You're behind the origin
> - You're ahead of the origin
<> - You've diverged from the origin
= - You're up-to-date with the origin
- - - - - - - - - - - - - -
"
}
# Add tab completion for many Bash commands
if which brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then
source "$(brew --prefix)/share/bash-completion/bash_completion";
elif [ -f /etc/bash_completion ]; then
source /etc/bash_completion;
fi;
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Path to the bash it configuration
export BASH_IT="/Users/brockboren/.bash_it"
# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location /.bash_it/themes/
export BASH_IT_THEME='purity'
# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
# export BASH_IT_REMOTE='bash-it'
# Don't check mail when opening terminal.
unset MAILCHECK
# Change this to your console based IRC client of choice.
export IRC_CLIENT='irssi'
# Set this to the command you use for todo.txt-cli
export TODO="t"
# Set this to false to turn off version control status checking within the prompt for all themes
export SCM_CHECK=true
# Set Xterm/screen/Tmux title with only a short hostname.
# Uncomment this (or set SHORT_HOSTNAME to something else),
# Will otherwise fall back on $HOSTNAME.
#export SHORT_HOSTNAME=$(hostname -s)
# Set Xterm/screen/Tmux title with only a short username.
# Uncomment this (or set SHORT_USER to something else),
# Will otherwise fall back on $USER.
#export SHORT_USER=${USER:0:8}
# Set Xterm/screen/Tmux title with shortened command and directory.
# Uncomment this to set.
#export SHORT_TERM_LINE=true
# Set vcprompt executable path for scm advance info in prompt (demula theme)
# https://github.com/djl/vcprompt
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt
# (Advanced): Uncomment this to make Bash-it reload itself automatically
# after enabling or disabling aliases, plugins, and completions.
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1
# Uncomment this to make Bash-it create alias reload.
# export BASH_IT_RELOAD_LEGACY=1
# Load Bash It
source "$BASH_IT"/bash_it.sh
export PATH="/usr/local/opt/python@3.8/bin:$PATH"