# If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac # history setup ## append to the history file, don't overwrite it shopt -s histappend ## no dups+skip space-prefixed commands HISTCONTROL=ignoreboth HISTFILE=~/.local/var/bash/history HISTSIZE=65536 # activate lesspipe [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # TODO: split off aliases? # ls colors if [ -x /usr/bin/dircolors ]; then eval "`dircolors -b`" alias ls='ls --color=auto' fi alias grep='grep --color=auto' alias egrep='egrep --color=auto' # disable flow control # XXX should this be here? stty -ixon unalias ll lt la lh lla llh 2>/dev/null ll() { ls -l "$@"; } lt() { ls -lt "$@"; } la() { ls -A "$@"; } lh() { ls -lh "$@"; } lla() { ls -lA "$@"; } llh() { ls -lAh "$@"; } # cd upwards a given number of levels unalias cu 2>/dev/null cu() { local lvl=$1 if ! [[ "${lvl}" =~ ^[0-9]+$ ]]; then echo "Parameter must be a non-negative integer: ${lvl}" return 1 fi local dir="" for i in $(seq "${lvl}"); do dir=${dir}../ done cd "${dir}" } # head/tail shortcut # e.g. "lt|h" or "h lt" __ht() { local cmd=$1 shift if [ $# -ne 0 ]; then $@ | $cmd else $cmd fi } unalias h t 2>/dev/null h() { __ht "head -32" $@; } t() { __ht "tail -32" $@; } # define the prompt . ~/.config/bash/prompt PS1=$(__prompt_func) # set the terminal window title case "$TERM" in xterm*|rxvt*) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' ;; *) ;; esac # source the machine-local configuration [ -r "$HOME/.config/bash/bashrc_local.bash" ] && . "$HOME/.config/bash/bashrc_local.bash"