# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # If not running interactively, don't do anything [ -z "$PS1" ] && return # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/bin/lesspipe ] && eval "$(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 # 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 ]; then . /etc/bash_completion fi ##### if [ -n "$SSH_CLIENT" ]; then if [ -z "$STY" ]; then screen -r fi fi if [ -d $HOME/bin ]; then export PATH=$HOME/bin:$PATH fi export HISTSIZE=1000000 export HISTFILESIZE=1000000000 export HISTCONTROL=ignoredups # make it append, rather than overwrite the history shopt -s histappend # fix typos shopt -s cdspell export BROWSER=firefox export EDITOR=vim # make pilot-xfer go faster than 9600 export PILOTRATE=57600 . ~/dotfiles/conf.sh ##### ssh agent ##### SSH_ENV="$HOME/.ssh_env" function start_agent { /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null /usr/bin/ssh-add ~/.ssh/id_dsa ~/.ssh/zeitin/id_rsa; } function keys { if [ -f "${SSH_ENV}" ]; then /bin/ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { start_agent; } else start_agent; fi ssh-add -l } alias k='keys' alias nk='ssh-add -D; killall ssh-agent' if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null /bin/ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { echo ssh env is old, removing... rm ${SSH_ENV} } fi ##### ssh agent end ##### ################# # Custom Prompt # ################# BGREEN='\[\033[1;32m\]' GREEN='\[\033[0;32m\]' BRED='\[\033[1;31m\]' RED='\[\033[0;31m\]' BBLUE='\[\033[1;34m\]' BLUE='\[\033[0;34m\]' NORMAL='\[\033[00m\]' #TODO: last code flag not working delete it! PS_LAST_CODE_FLAG=false PS_LAST_CODE='$( r=$?; [ $r -ne 0 -a "$PS_LAST_CODE_FLAG" == "false" ] && (echo -n "|$r"; PS_LAST_CODE_FLAG="true"))' PS1="${GREEN}[${BGREEN}\u@\h${GREEN}|${BBLUE}\w${GREEN}|${BLUE}\t${RED}${PS_LAST_CODE}${GREEN}]${NORMAL} " function promptcmd () { #history -a echo } PROMPT_COMMAND=promptcmd ##################### # End Custom Prompt # #################### export homeip='85.96.176.134' export vpsip='209.20.87.58' LS_OPTIONS='-lh --color --group-directories-first' eval `dircolors` alias l='ls $LS_OPTIONS' #alias ls='ls $LS_OPTIONS -Ff --color' alias la='ls $LS_OPTIONS -af' alias ld='ls -d $LS_OPTIONS -af' # directories only! alias pgrep='pgrep -lf' alias df='df -h' alias du='du -h -c' alias ping='ping' alias mkdir='mkdir -p' alias grep='grep --colour' alias g="grep" alias v="vim" alias sv="sudo vim" alias e="emacs" alias sx="startx" function syslog() { sudo tail -f $(find /var/log/ -name '*.log') ~/unison.log | ccze -A } function vpslog() { ssh yayingac.com sudo tail -f $(find /var/log/ -name '*.log') | ccze -A } #alias pci_info="curl --silent -d 'check=Check&lspci=$(lspci -n)' http://kmuto.jp/debian/hcl/index.cgi | sed -n '//,/<\/table>/ p' | lynx -stdin" alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"' alias genpass='< /dev/urandom tr -dc A-Za-z0-9_ | head -c8' # ssh alias vps="ssh 209.20.87.58" alias laptop="ssh 10.0.0.10" alias desktop="ssh 10.0.0.9" alias netbook="ssh 10.0.0.11" alias gray="ssh 192.168.199.67" alias cd.='cd ..' alias cd..='cd ../..' alias cd...='cd ../../..' alias cd....='cd ../../../..' alias cd.....='cd ../../../../..' # For colourful man pages (CLUG-Wiki style) export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' #needed for libpurple msn on arch export NSS_ALLOW_WEAK_SIGNATURE_ALG=1 #finch to work on arch #export TERM=screen export TERM=rxvt-unicode #java awt on xmonad export _JAVA_AWT_WM_NONREPARENTING=1 # down somesubdir # # Find a directory below this that matches the word provided # (locate-based) function down() { dir="" if [ -z "$1" ]; then dir=. fi dir=$(locate -l 1 -r $PWD.*/$1$) cd "$dir"; } # cdd someglobaldir # # quickly change to a directory anywhere that matches the word you typed. # best if your locatedb is in good shape function cdd() { dir="" if [ -z "$1" ]; then dir=. fi dir=$(locate -l 1 -r $1$) cd "$dir"; } function up() { dir="" if [ -z "$1" ]; then dir=.. elif [[ $1 =~ ^[0-9]+$ ]]; then x=0 while [ $x -lt ${1:-1} ]; do dir=${dir}../ x=$(($x+1)) done else dir=${PWD%/$1/*}/$1 fi cd "$dir"; } function upstr() { echo "$(up "$1" && pwd)"; } function extract() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) rar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xvf $1 ;; *.tbz2) tar xvjf $1 ;; *.tgz) tar xvzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "don't know how to extract '$1'..." ;; esac else echo "'$1' is not a valid file!" fi } alias lc="cl" function cl () { if [ $# = 0 ]; then cd && l else cd "$*" && l fi } function duf { du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done } ps () { /bin/ps $@ | ccze -A; } ant () { /usr/bin/ant $@ | ccze -A; } mplayer () { mkfifo /tmp/mpctl; xset s off; /usr/bin/mplayer -input file=/tmp/mpctl "$@"; xset s on; } gmplayer () { mkfifo /tmp/mpctl; /usr/bin/gmplayer -input file=/tmp/mpctl "$@"; } playdvd () { mplayer dvd:// -dvd-device $@; } t () { /usr/bin/tail -f * | ccze -A; } aptitude () { /usr/bin/aptitude $@ | ccze -A; } strace () { (/usr/bin/strace -Ff $@ | ccze -A ) 2>&1 | grep '^[^\(]\+'; } ltrace () { (/usr/bin/ltrace -S -n 3 $@ | ccze -A ) 2>&1 | grep '^[^\(]\+'; }