Skip to content

Instantly share code, notes, and snippets.

@Alanaktion
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alanaktion/410b0bba40c31b57b14e to your computer and use it in GitHub Desktop.
Save Alanaktion/410b0bba40c31b57b14e to your computer and use it in GitHub Desktop.
Bash startup script
# Bash settings for ultimate happiness
# Cross-platform and full of hax
# ls aliases
alias ls='ls --color'
alias ll='ls -alhF'
alias la='ls -A'
alias l='ls -CF'
# Shortcuts
alias ..='cd ..'
alias cd..='cd ..'
alias sha1='openssl sha1' # Generate SHA1
alias ports='sudo netstat -tulanp' # Show open ports
alias df='df -H'
alias du='du -h'
# Prevent changing permissions of /
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
# Colorize grep output
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# Ensure I get vim
alias vi='vim'
alias svi='sudo vi'
# I can never remember centerim, chat is easier
alias chat='centerim'
# Qalculate!
alias q='qalc'
# Use sudo on systemy things
alias top='sudo top'
alias atop='sudo atop'
alias htop='sudo htop'
alias iotop='sudo iotop'
# Recursive wget excluding index and parents
alias wgetr='wget -r --no-parent --reject "index.html*"'
# Platform-specific aliases and adjustments
if [ "$(uname)" == "Darwin" ]; then
# Hacky but beautiful terminal prompt from @mdo
# http://markdotto.com/2012/10/18/terminal-hotness/
if hash git 2>/dev/null; then
export PS1='\[\e[0;35m\]⌘\[\e[m\] \[\e[0;36m\]\w/\[\e[m\] \[\e[0;33m\]`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\[\e[m\]'
else
export PS1='\[\e[0;35m\]⌘\[\e[m\] \[\e[0;36m\]\w/\[\e[m\] '
fi
# Remote .DS_Store files in current dir recursively
alias rmdsstore='find . -name ".DS_Store" -depth -exec rm {} \;'
# OS X's locate
alias locate='/usr/bin/locate'
alias updatedb='sudo /usr/bin/libexec/locate.updatedb'
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Alternate version of @mdo's prompt, with the proper escaping for the non-printed chars
# http://mywiki.wooledge.org/BashFAQ/053
if hash git 2>/dev/null; then
export PS1='> \[\e[0;36m\]\w/\[\e[m\] \[\e[0;33m\]`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\[\e[m\]'
else
export PS1='> \[\e[0;36m\]\w/\[\e[m\] '
fi
# Better 'service'
alias service='sudo service'
alias svc='service'
# Always sudo apt
alias apt-get='sudo apt-get'
alias apt-cache='sudo apt-cache'
# apt-get shorthands
alias ains='apt-get install'
alias arm='apt-get remove'
alias aprg='apt-get purge'
alias aar='apt-get autoremove'
# Make updates painless
alias update='sudo apt-get update && sudo apt-get upgrade'
alias upgrade='sudo apt-get upgrade'
alias dist-upgrade='sudo apt-get dist-upgrade'
# Speedometer for eth0
alias speedo='speedometer -r eth0 -t eth0'
# Fortune toast
alias nfortune='fortune -s | xargs -0 notify-send "Fortune"'
# elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
# elif [ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]; then
fi
# Include extras if any
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_variables ]; then
. ~/.bash_variables
fi
# Debian-style terminal prompt
# export PS1='\u@`hostname -s`:\w$ '
# Set terminal title
PROMPT_COMMAND='echo -ne "\033]0;${USER}@$(hostname -s)\007"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment