Skip to content

Instantly share code, notes, and snippets.

@bbrown
Last active February 2, 2024 22:13
Show Gist options
  • Save bbrown/b580ed4e31fd32cf74b9 to your computer and use it in GitHub Desktop.
Save bbrown/b580ed4e31fd32cf74b9 to your computer and use it in GitHub Desktop.
My current bash settings
###############################################
######## THERE ARE SECRETS IN THIS FILE
######## DO NOT COPY THIS OR DISTRIBUTE
######## IT PUBLICLY. BE CAREFUL.
###############################################
alias restart="source ~/.bash_profile"
alias updatedb='sudo /usr/libexec/locate.updatedb'
alias ppj='cat "$1" | python -mjson.tool'
alias work='~/work.sh $output'
alias idea='~/idea.sh $output'
alias ls='ls -lh'
alias c='clear'
alias cls='c;ls'
alias b='brew'
alias bc='b cleanup'
alias bd='b doctor'
alias bo='b outdated'
alias bu='b update'
alias bup='b upgrade'
alias gb='git branch -avv'
alias gcm='git commit --message'
alias gd='git diff head'
alias gds='git diff --staged'
alias gf='git fetch --prune'
alias cgf='gf;cgs'
alias gl='git log --oneline --graph --decorate --branches'
alias gp='git stash;git pull --rebase;git stash pop'
alias cgp='gp;cgs'
alias gr='git checkout --'
alias gs='git status -sb'
alias gsl='git stash list'
alias gsm='git submodule update --remote --recursive'
alias gsu='git submodule update'
alias cgs='c;gs'
alias push='git push;say "Push it real good." -v Samantha'
alias standup='git standup -s'
alias ndb='node --inspect-brk'
alias d='docker'
alias dc='docker-compose'
# via https://unix.stackexchange.com/a/20830/126265
# Key bindings, up/down arrow searches through history
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\eOA": history-search-backward'
bind '"\eOB": history-search-forward'
export EDITOR='subl -w'
export GOPATH=$HOME/go
export PATH=/usr/local/bin:/bin:$HOME/.npm-packages/bin:$GOPATH/bin:$HOME/bin:$PATH
export PS1="\W \$ "
# Needed for Blackbox passphrase entry when installed via Homebrew
export GPG_TTY=`tty`
# Access token for Homebrew to search Github
# Descope entirely - https://gist.github.com/christopheranderton/8644743
export HOMEBREW_GITHUB_API_TOKEN="GITHUB_API_TOKEN"
export HOMEBREW_AUTO_UPDATE_SECS=3600
export HISTSIZE=50000
# Erases any duplicate commands from history
export HISTCONTROL=ignoreboth:erasedups
# Disables history logging for jrnl
export HISTIGNORE="$HISTIGNORE:jrnl *"
[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh
if [ -f "/usr/local/opt/bash-git-prompt/share/gitprompt.sh" ]; then
__GIT_PROMPT_DIR="/usr/local/opt/bash-git-prompt/share"
source "/usr/local/opt/bash-git-prompt/share/gitprompt.sh"
fi
# Colorize man pages
# From: http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized
man()
{
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
export NVM_DIR="$HOME/.nvm"
. /usr/local/opt/nvm/nvm.sh
# https://muhammadraza.me/2023/shell-functions/
function csv {
if [ -z "$1" ]; then echo "Usage: view_csv_pretty <file.csv>"
else cat "$1" | column -s, -t | less -F -S -X -K
fi
}
f()
{
open -a "Finder" "${1-.}";
}
# process grep with optional kill
# From: https://news.ycombinator.com/item?id=12366412
pgk ()
{
[ -z "$*" ] && echo 'Usage: pgk <pattern>' && return 1;
pgrep -fl $*;
[ "$?" == "1" ] && echo 'No processes match' && return 1;
echo 'Hit [Enter] to pkill, [Ctrl+C] to abort';
read && pkill -f $*
}
# truncate each line of the input to X characters ($1)
shorten ()
{
cat | sed -E "s/(.{${1-70}}).*(\.[^\.]+)?$/\1...\2/"
}
# Convert simplified wildcard pattern to regex and grep a file listing using
# Silver Searcher (`brew install the_silver_searcher`)
# http://brettterpstra.com/2018/11/07/shell-tricks-instant-wildcard-directory-search/
lsgrep ()
{
NEEDLE="$(echo $@|sed -E 's/\.([a-z0-9]+)$/\\.\1/'|sed -E 's/\?/./'| sed -E 's/[ *]/.*?/g')";
ag --depth 3 -S -g "$NEEDLE" 2> /dev/null
}
pushover()
{
curl -s -F "token=PUSHOVER_APP_TOKEN" \
-F "user=PUSHOVER_USER_KEY" \
-F "title=terminal" \
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
# Credit: https://news.ycombinator.com/item?id=26304832
sudo() {
unset -f sudo
if [[ "$(uname)" == 'Darwin' ]] && ! grep 'pam_tid.so' /etc/pam.d/sudo --silent; then
sudo sed -i -e '1s;^;auth sufficient pam_tid.so\n;' /etc/pam.d/sudo
fi
sudo "$@"
}
function tabname
{
printf "\e]1;$1\a"
}
function winname
{
printf "\e]2;$1\a"
}
test -e ${HOME}/.iterm2_shell_integration.bash && source ${HOME}/.iterm2_shell_integration.bash
complete -C /Users/bbrown/go/bin/vault vault
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/bbrown/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/bbrown/Downloads/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/bbrown/Downloads/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/bbrown/Downloads/google-cloud-sdk/completion.bash.inc'; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment