Skip to content

Instantly share code, notes, and snippets.

@bsormagec
Forked from simonrad/bash_profile
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save bsormagec/a5a0f16f71b7f8a9771c to your computer and use it in GitHub Desktop.

Select an option

Save bsormagec/a5a0f16f71b7f8a9771c to your computer and use it in GitHub Desktop.
# Set up custom bash command prompt.
# Default is "\h:\W \u\$ ".
RED="\[\e[0;31m\]"
GREEN="\[\e[0;32m\]"
BLUE="\[\e[0;34m\]"
PLAIN="\[\e[m\]"
PS1="${RED}\u@\h: \w\$ ${PLAIN}"
# Aliases.
alias l='ls -G'
alias la='l -a'
alias ll='l -l'
alias lla='l -la'
alias b='cd ..'
alias gd='git branch; git status; git --no-pager diff'
alias gds='git --no-pager diff --staged'
alias gitnp='git --no-pager'
alias gsu='git submodule update --init'
alias gitsha='git rev-parse --verify HEAD'
alias asa='/Users/Shared/permanent/shell_utils/allow_staff_access.sh'
alias fixbrew='sudo asa -y /usr/local && sudo asa -y /Library/Caches/Homebrew'
# Override the ssh command with a function that copies a bashrc file to the remote machine before running bash.
myssh(){ /usr/bin/ssh -l ubuntu -t $* "curl --silent --show-error 'https://gist.github.com/simonrad/997b6577b326398b2a38/raw' --output /tmp/ssh_override_bashrc_file && /bin/bash --rcfile /tmp/ssh_override_bashrc_file -i"; }
# Pass aliases through sudo.
alias sudo='sudo '
# Increase bash history size.
export HISTFILESIZE=50000
export HISTSIZE=50000
# Make writing to .bash_history immediate.
shopt -s histappend # Append to history, don't overwrite it.
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" # Append, clear, and reload history.
export EDITOR='nano -w'
# Add to my PATH.
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
# Enable magical cd abilities.
export CDPATH='.:~/workspace/'
# Git helpers.
alias get_current_git_branch_name='python -c "print \"$(git symbolic-ref HEAD 2>/dev/null)\".split(\"/\",2)[-1] or \"!no_branch!\""'
alias publish_git_branch='git push -u origin $(get_current_git_branch_name)'
alias delete_remote_git_branch='git push origin --delete'
# Enable git autocompletion.
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
else
echo "Git autocompletion script (~/.git-completion.bash) not found. Attempting to download it."
curl "https://gist.githubusercontent.com/simonrad/d57469270f78327f2fcf/raw" -o ~/.git-completion.bash
source ~/.git-completion.bash
fi
# Set up virtualenvwrapper.
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
source /usr/local/bin/virtualenvwrapper.sh
# Aliases to start and stop the Postgresql server manually.
export PGDATA='/usr/local/var/postgres'
export PGHOST=localhost
alias pgstart='pg_ctl -D $PGDATA -l $PGDATA/server.log start'
alias pgstop='pg_ctl -D $PGDATA stop -s -m fast'
alias pgc='pg_ctl'
# Encryption / decryption utilities.
# ----------------------------------
function set_password_for_encryption {
echo "Please type your password:"
export PASSWORD_FOR_ENCRYPTION=$(cat)
echo "Your password is now \"$PASSWORD_FOR_ENCRYPTION\"."
}
function print_password_for_encryption {
echo "Your password is \"$PASSWORD_FOR_ENCRYPTION\"."
}
function encrypt {
if [ -z "$PASSWORD_FOR_ENCRYPTION" ]; then
echo "Please set your password first, by running set_password_for_encryption"
else
# Reads plaintext from stdin.
# Writes encrypted and base64-encoded cyphertext to stdout.
openssl des -e -aes128 -k "$PASSWORD_FOR_ENCRYPTION" | base64
fi
}
function decrypt {
if [ -z "$PASSWORD_FOR_ENCRYPTION" ]; then
echo "Please set your password first, by running set_password_for_encryption"
else
# Reads encrypted and base64-encoded cyphertext from stdin.
# Writes plaintext to stdout.
base64 -D | openssl des -d -aes128 -k "$PASSWORD_FOR_ENCRYPTION"
fi
}
# ----------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment