Skip to content

Instantly share code, notes, and snippets.

@tuna-f1sh
Created March 4, 2016 15:56
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 tuna-f1sh/ea90237ce04a8f3347d9 to your computer and use it in GitHub Desktop.
Save tuna-f1sh/ea90237ce04a8f3347d9 to your computer and use it in GitHub Desktop.
My portable bashrc
#Colors
#=======
#enables color in the terminal bash shell export
CLICOLOR=1
#sets up the color scheme for list export
LSCOLORS=gxfxcxdxbxegedabagacad
# for a colourful vim
export TERM='xterm-256color'
#=============COLORS=================
# Normal Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
# Bold
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Background
On_Black='\e[40m' # Black
On_Red='\e[41m' # Red
On_Green='\e[42m' # Green
On_Yellow='\e[43m' # Yellow
On_Blue='\e[44m' # Blue
On_Purple='\e[45m' # Purple
On_Cyan='\e[46m' # Cyan
On_White='\e[47m' # White
NC="\e[m" # Color Reset
ALERT=${BWhite}${On_Red} # Bold White on red background
#Prompt Styling
#===============
printf "${BWhite}
__ __ __
/ /___ / /_ ____ __ ______ / /___ __
__ / / __ \/ __ \/ __ \/ / / / __ \/ __/ / / /
/ /_/ / /_/ / / / / / / / /_/ / / / / /_/ /_/ /
\____/\____/_/ /_/_/ /_/\__,_/_/ /_/\__/\__,_/
"
#Set Prompt
#===========
PS1="\[$BBlue\][\A \u@\[$BGreen\]\h \[$BCyan\]\w\[$BBlue\]]\n>\[$White\] "
#========
# EXPORT
#========
#========
# ALIASES
#========
# Interactive operation delete
alias rm='rm -vi'
# Verbose other commands
alias cp='cp -v'
alias mv='mv -v'
# Default to human readable figures
alias df='df -h'
alias du='du -h'
alias ls='ls -FG'
alias grep='grep --color' # show differences in colour
function cdff { cd "`ff $@`"; };
# Some shortcuts for different directory listings
alias dir='ls -lhcF' # classify files in colour
alias ll='ls -l' # long list
alias la='ls -A' # all but . and ..
alias l='ls -CF' #
alias glg='git log --date-order --all --graph --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
alias ipconfig='ifconfig' # windows memory
alias reload="source ~/.bashrc"
# b) function cd_func
# This function defines a 'cd' replacement function capable of keeping,
# displaying and accessing history of visited directories, up to 10 entries.
# To use it, uncomment it, source this file and try 'cd --'.
# acd_func 1.0.5, 10-nov-2004
# Petar Marinov, http:/geocities.com/h2428, this is public domain
cd_func ()
{
local x2 the_new_dir adir index
local -i cnt
if [[ $1 == "--" ]]; then
dirs -v
return 0
fi
the_new_dir=$1
[[ -z $1 ]] && the_new_dir=$HOME
if [[ ${the_new_dir:0:1} == '-' ]]; then
#
# Extract dir N from dirs
index=${the_new_dir:1}
[[ -z $index ]] && index=1
adir=$(dirs +$index)
[[ -z $adir ]] && return 1
the_new_dir=$adir
fi
#
# '~' has to be substituted by ${HOME}
[[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
#
# Now change to the new dir and add to the top of the stack
pushd "${the_new_dir}" > /dev/null
[[ $? -ne 0 ]] && return 1
the_new_dir=$(pwd)
#
# Trim down everything beyond 11th entry
popd -n +11 2>/dev/null 1>/dev/null
#
# Remove any other occurence of this dir, skipping the top of the stack
for ((cnt=1; cnt <= 10; cnt++)); do
x2=$(dirs +${cnt} 2>/dev/null)
[[ $? -ne 0 ]] && return 0
[[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
if [[ "${x2}" == "${the_new_dir}" ]]; then
popd -n +$cnt 2>/dev/null 1>/dev/null
cnt=cnt-1
fi
done
return 0
}
alias cd=cd_func
# CD SHORTCUTS
# OTHER
alias ql='qlmanage -p "$@" >& /dev/null'
alias path='echo -e ${PATH//:/\\n}'
alias ardserial="screen /dev/tty.usbmodem1421 $1"
alias ipscan='sudo nmap -sn 192.168.0.0/16'
# download website reminder
# wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains learnpythonthehardway.org --no-parent http://learnpythonthehardway.org/book/
#=============
# SETTINGS
#=============
# Set vi mode
set -o vi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment