Created
July 29, 2012 22:41
-
-
Save rob-mcgrail/3202277 to your computer and use it in GitHub Desktop.
bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ~/.bashrc: executed by bash(1) for non-login shells. | |
| # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
| # for examples | |
| # Dropbox Helper | |
| alias dropb='sudo sysctl fs.inotify.max_user_watches=100000' | |
| # Ports | |
| alias ports='sudo netstat -lpn' | |
| # Color shortcuts | |
| # Color | |
| BLACK='\e[0;30m' | |
| BLUE='\e[0;34m' | |
| GREEN='\e[0;32m' | |
| CYAN='\e[0;36m' | |
| RED='\e[0;31m' | |
| PURPLE='\e[0;35m' | |
| BROWN='\e[0;33m' | |
| LIGHTGRAY='\e[0;37m' | |
| DARKGRAY='\e[1;30m' | |
| LIGHTBLUE='\e[1;34m' | |
| LIGHTGREEN='\e[1;32m' | |
| LIGHTCYAN='\e[1;36m' | |
| LIGHTRED='\e[1;31m' | |
| LIGHTPURPLE='\e[1;35m' | |
| YELLOW='\e[1;33m' | |
| WHITE='\e[1;37m' | |
| NC='\e[0m' # No Color | |
| # If not running interactively, don't do anything | |
| if [[ -n "$PS1" ]]; then | |
| # don't put duplicate lines in the history. See bash(1) for more options | |
| # ... or force ignoredups and ignorespace | |
| HISTCONTROL=ignoredups:ignorespace | |
| # replace more with most | |
| export PAGER='most' | |
| # set colours | |
| export TERM=xterm-256color | |
| # append to the history file, don't overwrite it | |
| shopt -s histappend | |
| # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
| HISTSIZE=1000 | |
| HISTFILESIZE=2000 | |
| # check the window size after each command and, if necessary, | |
| # update the values of LINES and COLUMNS. | |
| shopt -s checkwinsize | |
| # fun | |
| alias buddha='echo -e "${GREEN}"; clear ; echo -e "${CYAN}"" Peace be with you $USER" ; echo ' | |
| # make less more friendly for non-text input files, see lesspipe(1) | |
| [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" | |
| # set variable identifying the chroot you work in (used in the prompt below) | |
| if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then | |
| debian_chroot=$(cat /etc/debian_chroot) | |
| fi | |
| # set a fancy prompt (non-color, unless we know we "want" color) | |
| case "$TERM" in | |
| xterm-color) color_prompt=yes;; | |
| esac | |
| # uncomment for a colored prompt, if the terminal has the capability; turned | |
| # off by default to not distract the user: the focus in a terminal window | |
| # should be on the output of commands, not on the prompt | |
| force_color_prompt=yes | |
| if [ -n "$force_color_prompt" ]; then | |
| if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
| # We have color support; assume it's compliant with Ecma-48 | |
| # (ISO/IEC-6429). (Lack of such support is extremely rare, and such | |
| # a case would tend to support setf rather than setaf.) | |
| color_prompt=yes | |
| else | |
| color_prompt= | |
| fi | |
| fi | |
| if [ "$color_prompt" = yes ]; then | |
| PS1='${debian_chroot:+($debian_chroot)}\[\033[01;46m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[00m\]\$ ' | |
| else | |
| PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | |
| fi | |
| unset color_prompt force_color_prompt | |
| # If this is an xterm set the title to user@host:dir | |
| case "$TERM" in | |
| xterm*|rxvt*) | |
| PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" | |
| ;; | |
| *) | |
| ;; | |
| esac | |
| # enable color support of ls and also add handy aliases | |
| if [ -x /usr/bin/dircolors ]; then | |
| test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
| alias ls='ls --color=auto' | |
| alias dir='dir --color=auto' | |
| alias vdir='vdir --color=auto' | |
| alias grep='grep --color=auto' | |
| alias fgrep='fgrep --color=auto' | |
| alias egrep='egrep --color=auto' | |
| fi | |
| # some more ls aliases: | |
| alias ll='ls -alF' | |
| alias la='ls -A' | |
| alias l='ls -CF' | |
| # Colorize grep | |
| alias g="grep --color=always" | |
| alias gi="grep -i --color=always" | |
| # list with greps | |
| alias lsg='ls --color=auto | g' | |
| alias lag='ls -a --color=auto | g' | |
| alias llg='ls -lah --color=auto | g' | |
| #grep for a process | |
| alias pro?='ps -e | grep' | |
| #grep for files | |
| alias ls?='ls | grep' | |
| #make copy etc interactive and verbose: | |
| alias cp="cp -iv" | |
| alias rm="rm -iv" | |
| alias mv="mv -iv" | |
| # back aliases: | |
| alias .='cd ..' | |
| alias ..='cd ../..' | |
| alias ...='cd ../../..' | |
| alias ....='cd ../../../..' | |
| # apt-get aliases | |
| alias Install='sudo apt-get install' | |
| alias Remove='sudo apt-get remove' | |
| alias Update='sudo apt-get update' | |
| alias Upgrade='sudo apt-get upgrade' | |
| # history | |
| alias hist='history | g $1' #Requires one input | |
| # human sizing | |
| alias df='df -h' | |
| # You may want to put all your additions into a separate file like | |
| # ~/.bash_aliases, instead of adding them here directly. | |
| # See /usr/share/doc/bash-doc/examples in the bash-doc package. | |
| if [ -f ~/.bash_aliases ]; then | |
| . ~/.bash_aliases | |
| fi | |
| # enable programmable completion features (you don't need to enable | |
| # this, if it's already enabled in /etc/bash.bashrc and /etc/profile | |
| # sources /etc/bash.bashrc). | |
| if [ -f /etc/bash_completion ] && ! shopt -oq posix; then | |
| . /etc/bash_completion | |
| fi | |
| # Get IP (call with wanip) | |
| function wanip { | |
| myip=`elinks -dump http://checkip.dyndns.org:8245/` | |
| echo "${myip}" | |
| } | |
| alias lanip='ifconfig | grep "inet addr"' | |
| function lowercase() # move filenames to lowercase | |
| { | |
| for file ; do | |
| filename=${file##*/} | |
| case "$filename" in | |
| */*) dirname==${file%/*} ;; | |
| *) dirname=.;; | |
| esac | |
| nf=$(echo $filename | tr A-Z a-z) | |
| newname="${dirname}/${nf}" | |
| if [ "$nf" != "$filename" ]; then | |
| mv "$file" "$newname" | |
| echo "lowercase: $file --> $newname" | |
| else | |
| echo "lowercase: $file not changed." | |
| fi | |
| done | |
| } | |
| function ii() # Get current host related info. | |
| { | |
| echo -e "\nYou are logged on ${RED}$HOST" | |
| echo -e "\nAdditionnal information:$NC " ; uname -a | |
| echo -e "\n${RED}Users logged on:$NC " ; w -h | |
| echo -e "\n${RED}Current date :$NC " ; date | |
| echo -e "\n${RED}Machine stats :$NC " ; uptime | |
| echo -e "\n${RED}Memory stats :$NC " ; free | |
| my_ip 2>&- ; | |
| echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"} | |
| echo -e "\n${RED}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"} | |
| echo -e "\n${RED}Open connections :$NC "; netstat -pan --inet; | |
| echo | |
| } | |
| function repeat() # Repeat n times command. | |
| { | |
| local i max | |
| max=$1; shift; | |
| for ((i=1; i <= max ; i++)); do # --> C-like syntax | |
| eval "$@"; | |
| done | |
| } | |
| # find functions | |
| function ff() { find . -name '*'$1'*' ; } # find a file | |
| function fe() { find . -name '*'$1'*' -exec $2 {} \; ; } # find a file and run $2 on it | |
| function fstr() # find a string in a set of files | |
| { | |
| if [ "$#" -gt 2 ]; then | |
| echo "Usage: fstr \"pattern\" [files] " | |
| return; | |
| fi | |
| SMSO=$(tput smso) | |
| RMSO=$(tput rmso) | |
| find . -type f -name "${2:-*}" -print | xargs grep -sin "$1" | \ | |
| sed "s/$1/$SMSO$1$RMSO/gI" | |
| } | |
| cd | |
| fi | |
| # path for random user scripts | |
| export PATH=$PATH:$HOME/bin | |
| # paths for go-lang | |
| #This line will tell the Go installer where to place the source code before compilation | |
| #export GOROOT=$HOME/gosource | |
| #With this line, you choose the architecture of your machine. | |
| #Those with 64 bit CPUs should enter "amd64" here. | |
| #export GOARCH=386 | |
| #Your operating system | |
| #export GOOS=linux | |
| #export GOPATH=$HOME/opt/go | |
| #Includ eGo binaries in command path | |
| #export PATH=$PATH:$GOBIN | |
| #PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting | |
| #[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | |
| cd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment