Last active
September 9, 2020 23:45
-
-
Save SpencerKaiser/1eb650681f6c9a3c0ff68ced1ee517f1 to your computer and use it in GitHub Desktop.
Bash Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# General Shortcuts | |
alias dev="cd ~/Dev" | |
# Git Shortcuts | |
alias commit="git commit" | |
alias add="git add" | |
alias pull="git pull" | |
alias sync="git pull upstream master" | |
alias push="git push" | |
alias status="git status" | |
alias statys="git status" | |
alias diff="git diff" | |
alias diff-last="git diff HEAD^1 HEAD" | |
alias branch="git branch" | |
alias checkout="git checkout" | |
alias co="git checkout" | |
alias fetch="git fetch --all -p" | |
alias prune="git remote prune origin" | |
alias cleanBranches='git branch --merged | egrep -v "(^\*|master|integration)" | xargs git branch -d' | |
log() { | |
numLines=10 | |
if [ "$#" -gt 0 ]; then | |
numLines=$1 | |
fi | |
git log --decorate --oneline --pretty=format:"%h%x09%an%x09%x09%s" -n $numLines | |
} | |
# Bulk delete merged remote branches: | |
# git branch --remote --merged integration/5.3 | grep 'dynamicReaccom' | cut -b 10- | xargs git push --delete origin | |
# Stash all unstaged files (including untracked) | |
alias stash="git stash -k" | |
alias apply="git stash apply" | |
alias pop="git stash pop" | |
# SSH Helpers | |
alias sshkey="cat ~/.ssh/skaiser.pub | pbcopy | echo 'Copied to Clipboard'" | |
alias hosts="code /etc/hosts" | |
alias config="code ~/.ssh/config" | |
# BASH SPECIFIC | |
alias edit="code ~/.zprofile" | |
alias reload="source ~/.zprofile && source ~/.zshrc" | |
mkcd() { | |
mkdir $1 | |
cd $1 | |
} | |
# ls -h: human readable file size | |
alias ls="ls -AlhF" | |
alias which="which -a" | |
alias ..="cd ../" | |
# MISC | |
mkgif() { | |
filename=$(basename "$1") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
ffmpeg -i $1 -pix_fmt rgb24 -r 5 -f gif - | gifsicle --optimize=3 --delay=9 > $filename.gif | |
echo "Done" | |
} | |
# mkgif errors: make sure gigsicle is installed (`brew install gifsicle`) | |
# If you want to use The Fuck (https://github.com/nvbn/thefuck) but want to use it in demos | |
alias fix="fuck" | |
eval $(thefuck --alias) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up colors for `ls` | |
export CLICOLOR=1 | |
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx | |
fpath=(~/.zsh $fpath) | |
autoload -Uz compinit && compinit | |
# Import colors | |
autoload colors && colors | |
# Format colors; adding %{ ... %} will tell zsh that the values have no width | |
# Without this, the colors will add width the cusor position will be impacted | |
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do | |
eval $COLOR='%{$fg_no_bold[${(L)COLOR}]%}' #wrap colours between %{ %} to avoid weird gaps in autocomplete | |
eval BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}' | |
done | |
eval RESET='%{$reset_color%}' | |
# Retrieve current working directory | |
function get_pwd { | |
echo "${PWD/$HOME/~}" | |
} | |
# Get value to be displayed in the prompt | |
function get_prompt { | |
echo "%n [$(get_pwd)] ${BOLD_CYAN}>${RESET} " | |
} | |
# Get the current branch to display in the prompt | |
function get_current_branch() { | |
branch=$(git branch 2>/dev/null | grep '^*' | colrm 1 2 | rev | cut -d "/" -f 1 | rev) | |
if [ -z "$branch" ]; | |
then | |
echo "" | |
else | |
echo "$branch" | |
fi | |
} | |
# Allow function execution in the prompt | |
setopt PROMPT_SUBST | |
# Set left and right prompts | |
PROMPT='$(get_prompt)' | |
RPROMPT='${YELLOW}$(get_current_branch)${RESET}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment