Skip to content

Instantly share code, notes, and snippets.

@Frizlab
Last active August 2, 2017 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frizlab/0390464c06fb844f81a14d5c423d3ca2 to your computer and use it in GitHub Desktop.
Save Frizlab/0390464c06fb844f81a14d5c423d3ca2 to your computer and use it in GitHub Desktop.
Parts of My Bash Profile — Use At Your Own Risks!
#!/bin/bash
# Init file for login shells
# Most of the instructions here should be in the .bashrc file...
function show_branch1() {
git branch >/dev/null 2>&1
if [ $? -eq 0 ]; then printf "["; fi
}
function show_branch2() {
# No need for more than 2 lines of status in theory as untracked are shown at the end
status="$(git status -b --porcelain 2>/dev/null | head -n 3)"
status_ret=${PIPESTATUS[0]}
if [ $status_ret -ne 0 ]; then return; fi
printf "`echo "$status" | sed -En '/^## /s///p'`"
if echo "$status" | grep -Eq '^[^#?]'; then printf '*'
elif echo "$status" | grep -Eq '^\?'; then printf '~'
fi
}
function show_branch3() {
git branch >/dev/null 2>&1
if [ $? -eq 0 ]; then printf "]"; fi
}
# \W: last path component
# You can comment the following lines to come back to the default prompt.
# IMPORTANT NOTE: The colors should be set directly within the variable, not from the output of the
# show_branch* methods (which is why there are three methods...) because of a Terminal
# bug (probably).
export PS1='\[\033[01;36m\]\#\[\033[0m\] \\ \[\033[00;32m\]\t\[\033[0m\] / \[\033[00;33m\]\u@\h\[\033[0m\][\[\033[00;31m\]$?\[\033[0m\]] \[\033[01;38m\]\w\[\033[0m\]) '
export PS1='\[\033[01;36m\]\#\[\033[0m\] \\ \[\033[00;32m\]\t\[\033[0m\] / \[\033[00;33m\]\u@\h\[\033[0m\][\[\033[00;31m\]$?\[\033[0m\]] \[\033[01;38m\]\w\[\033[0m\]`show_branch1`\[\033[00;31m\]`show_branch2`\[\033[0m\]`show_branch3`) '
# We may want to set PS2 too. It sets the prompt shown after a return when the command line is not finished.
export PATH="${PATH}:/usr/local/sbin:~/bin:."
export EDITOR='vi'
# Aliases for ls
alias ls='ls -FG'
alias l='ls -C'
alias ll='ls -l'
alias la='ls -a'
alias lla='ls -la'
alias lt='ls -lrt'
# Dev. aliases
alias gt="git tag | xargs -I@ git log --format=format:\"%ai @%n\" -1 @ | sort | awk '{print \$4}'"; # Outputs git tags in reverse chronological order
alias xcsymbolicate='DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/ /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash'
# Misc. aliases
alias x='chmod ug+x'
alias top='top -o cpu'
alias rem='trash'
alias cd..='cd ..'
alias h='cat ~/.bash_sessions/*.history*'
# Misc. functions
function del_stores() {
# Note: Cannot give "/" in input!
dir="`echo "$1" | sed -E 's:/*$::'`"
if [ -z "$dir" ]; then echo "Usage: del_stores dir" >/dev/stderr; return 1; fi
if [ ! -d "$dir" ]; then echo "dir does not exist or is not a directory" >/dev/stderr; return 2; fi
find "$dir" -name ".DS_Store" -print -delete
}
# Locale fix env
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
########
# Ruby #
########
export GEM_HOME='/usr/local'
##########
# Python #
##########
export PATH="${PATH}:${HOME}/Library/Python/*/bin"
############
# Homebrew #
############
#export PYTHONPATH="${HOME}/Library/Python/2.7/lib/python/site-packages:/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
# This should probably be in .bashrc rather than in the .bash_profile
. /usr/local/etc/bash_completion.d/pass
@Frizlab
Copy link
Author

Frizlab commented Aug 2, 2017

Updated for git repo with a lot of modified or untracked files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment