#!/usr/bin/env bash # If not running interactively, don't do anything [ -z "$PS1" ] && return # Default editor is vim export EDITOR=/usr/bin/vim #PS1='\d \t\n\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \n\$\[\033[00m\] ' # Use different PS1 when in a screen if [ -z "$STY" ]; then PS1='\e[1A\e[s\e[H\e[37;44;1m\e[K \u@\h: \e[33;44;1m\w \e[199C\e[8D\e[37;44;1m [\A] \e[0m\e[u\n$ ' else PS1='$ ' fi ## Shell varibles export BROWSER='firefox' export PAGER=less export EDITOR=vim export PATH=$PATH:$HOME/bin:/usr/local/bin export LESS='-RX' export wpsetters=feh export HISTSIZE=5000 export HISTFILESIZE=1000 # don't put duplicate lines in the history. See bash(1) for more options export HISTCONTROL=ignoredups export HISTIGNORE="&:ls:ll:la:l.:pwd:exit:clear" ## shopt options shopt -s cdspell # This will correct minor spelling errors in a cd command. shopt -s histappend # Append to history rather than overwrite shopt -s checkwinsize # Check window after each command # files beginning with . to be returned in the results of path-name expansion. shopt -s dotglob ## set options set -o noclobber # prevent overwriting files with cat set -o ignoreeof # stops ctrl+d from logging me out set -o vi # use vim key bindings # enable color support of ls if [ "$TERM" != "dumb" ]; then if [[ -f ~/.dir_colors ]]; then eval `dircolors -b ~/.dir_colors` else eval `dircolors -b /etc/DIR_COLORS` fi alias ls='ls --color=auto' alias grep='grep --color=auto' fi # enable programmable completion features if [ -f /etc/bash_completion ] && [ -z "$BASH_COMPLETION" ]; then . /etc/bash_completion fi ### Aliases ### ## file modification ## alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' ## file listing ## alias ll='ls -l' alias la='ls -A' alias l='ls -CF' ## movement ## alias back='cd $OLDPWD' alias cd..='cd ..' alias df='df -h' alias du='du -h -c' alias mkdir='mkdir -p -v' alias ..='cd ..' ## utility ## alias recent="ls -lAt | head" alias zypper='sudo zypper' alias update='zypper update' alias search='zypper se' alias install='zypper in' ## svn ## # add all ? to svn alias svna="svn st | grep ^\? | sed 's/^\?[ \t]*//' | xargs svn add" # revert all A alias svnra="svn st | grep ^A | sed 's/^A[ \t]*//' | xargs svn revert" alias svnst='svn st --ignore-externals' # search for a file, ignore .svn alias f="find . -path '*.svn*' -prune -o -print | grep" ##functions extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) rar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi } psgrep() { if [ ! -z $1 ] ; then echo "Grepping for processes matching $1..." ps aux | grep $1 | grep -v grep else echo "!! Need name to grep for" fi } # list contents right after changing directories cd() { if [ "$1" ] then builtin cd "$1" && ls else builtin cd && ls fi } # backup bu () { cp $1 ~/.backup/`basename $1`-`date +%Y%m%d%H%M`.backup ; }