1. Mario Fuest
  2. dotfiles

Source

dotfiles / .bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth

# 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)"

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    ;;
*)
    ;;
esac

## foo+arrow leads to history starting with foo
bind '"\e[A"':history-search-backward
bind '"\e[B"':history-search-forward

## sudo tab completition
complete -cf sudo

## hg and co should use vim
export EDITOR=vim

# Alias definitions.
# 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 ]; then
    . /etc/bash_completion
fi

## Modify PATH
export PATH=/home/$USER/.bin:$PATH

## PS1
export PS1='\[\033[1;32m\]\u@\h:\033[01;34m\]\w\[\033[00m\]\$ '

# support colors in less (and so man as well)
# thanks to the grml team
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'
 
export SDL_audiodriver=alsa

## functions
# reminder
function remind() {
    echo "notify-send \"Reminder\" \"$1\"" | at $2 $3 2> /dev/null
}
alias 'r'='remind'

# Who can remind which tool to use?
function extract() {
    if [[ -f "$1" ]]; then
        case "$1" in
            *.tar.bz2)   tar xvjf "$1"    ;;
            *.tar.gz)    tar xvzf "$1"    ;;
            *.bz2)       bunzip2 "$1"     ;;
            *.rar)       unrar 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
}

# Follow copied and moved files to destination directory
goto() { [ -d "$1" ] && cd "$1" || cd "$(dirname "$1")"; }
cpf() { cp "$@" && goto "$_"; }
mvf() { mv "$@" && goto "$_"; }

function pacsearch() {
  echo -e "$(pacman -Ss $@ | sed \
  -e 's#current/.*#\\033[1;31m&\\033[0;39m#g' \
  -e 's#extra/.*#\\033[0;32m&\\033[0;39m#g' \
  -e 's#community/.*#\\033[1;35m&\\033[0;39m#g' \
  -e 's#^.*/.* [0-9].*#\\033[0;36m&\\033[0;39m#g' )"
}