Skip to content

Instantly share code, notes, and snippets.

Created Oct 4, 2017
What would you like to do?
My dotfiles
# Make ls in color
alias ls="command ls -G"
echo "Hello $USER."
for file in ~/.{profile,bash_prompt,exports,aliases,functions}; do
[ -r "$file" ] && source "$file"
unset file
# Case insensitive globbing
shopt -s nocaseglob
# Append to bash history
shopt -s histappend
# Autocorrect typos in path names
shopt -s cdspell
# Increate the number of files opened
ulimit -n 4096
#launchctl limit maxfiles 10480 10480
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
# Add tab completion for `defaults read|write NSGlobalDomain`
# You could just use `-g` instead, but I like being explicit
complete -W "NSGlobalDomain" defaults
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/petele/google-cloud-sdk/' ]; then source '/Users/petele/google-cloud-sdk/'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/petele/google-cloud-sdk/' ]; then source '/Users/petele/google-cloud-sdk/'; fi
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 256)
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 4)
GREEN=$(tput setaf 2)
PURPLE=$(tput setaf 1)
WHITE=$(tput setaf 7)
BOLD=$(tput bold)
RESET=$(tput sgr0)
function git_info() {
# check if we're in a git repo
git rev-parse --is-inside-work-tree &>/dev/null || return
# quickest check for what branch we're on
branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
# check if it's dirty (via
dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
echo $WHITE" on "$PURPLE$branch$dirty
# Only show username/host if not default
function usernamehost() {
# iTerm Tab and Title Customization and prompt customization
# Put the string " [bash] hostname::/full/directory/path"
# in the title bar using the command sequence
# \[\e]2;[bash] \h::\]$PWD\[\a\]
# Put the penultimate and current directory
# in the iterm tab
# \[\e]1;\]$(basename $(dirname $PWD))/\W\[\a\]
PS1="\[\e]2;$PWD\[\a\]\[\e]1;\]$(basename "$(dirname "$PWD")")/\W\[\a\]${BOLD}\$(usernamehost)\[$GREEN\]\w\$(git_info)\[$WHITE\]\n\$ \[$RESET\]"
# Global stuff
export PATH=$HOME/bin:$PATH
export EDITOR="open -a Sublime\ Text"
# Prefer US English and use UTF-8
export LC_ALL="en_US.UTF-8"
export LANG="en_US"
# Don’t clear the screen after quitting a manual page
export MANPAGER="less -X"
export GOPATH=/Users/petele/Sites/Go
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[B": history-search-forward
"\e[A": history-search-backward
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
# Use Alt/Meta + Delete to delete the preceding word
"\e[3;3~": kill-word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment