Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ -z "$PS1" ] && return
- umask 0022
- # completion
- if [ -f "$HOME/.bash_completion" -a ! "${BASH_COMPLETION+set}" ]; then
- . "$HOME/.bash_completion"
- fi
- # remap console keys
- if [ -z "$DISPLAY" -a -f "$HOME/.loadkeys" ]; then
- loadkeys "$HOME/.loadkeys" >/dev/null
- fi
- ## prompt {{{
- if [ "$TERM" = "linux" ]
- then
- # (system console) long prompt
- PS1="\u@\h[\#]\W\$ "
- else
- # (xterm etc.) short, color prompt if possible
- if [ -x /bin/tput -o -x /usr/bin/tput ] && tput setaf 1 &>/dev/null; then
- if type __git_ps1 &>/dev/null; then
- GIT_PS1='\[\e['30';1m\]$(__git_ps1 "·%s")\[\e[0m\]'
- else
- GIT_PS1=
- fi
- PS1='$(if [ $? -eq 0 ]
- then echo "\[\e['30';1m\]·\[\e[0m\]"
- else echo "\[\e['31';1m\]·\[\e[0m\]"
- fi)\[\e['33';1m\]$(promptwd "\w")\[\e[0m\]'"$GIT_PS1"'\$ '
- unset GIT_PS1
- else
- PS1='[\#]\W\$ '
- fi
- # disable XON/XOFF
- stty -ixon
- fi
- # set variable identifying the chroot you work in
- if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
- fi
- PS1="${debian_chroot:+($debian_chroot)}$PS1"
- PS1 ()
- {
- if [[ "$PS1" =~ promptwd ]]; then
- PS1=$(echo "$PS1" | awk '{ sub(/\$\(promptwd "\\w"\)/, "\\W"); print }')
- else
- PS1=$(echo "$PS1" | awk '{ sub(/\\W/, "$(promptwd \"\\w\")"); print }')
- fi
- }
- #promptwd ()
- #{
- # local top=$(echo "$1" | sed "s#\([^/]*/\)\(.*\)\(/[^/]\+/[^/]\+\)#\2#")
- # if [ "$top" = "$1" ]; then
- # echo "$1"
- # elif [ ${#top} -gt 5 ]; then
- # top="${top:0:3}"
- # top="${top%%/*}.."
- # echo "$1" | sed "s#\([^/]*/\)\(.*\)\(/[^/]\+/[^/]\+\)#\1$top\3#"
- # else
- # echo "$1"
- # fi
- #}
- # title bar
- case "$TERM" in
- xterm*|*rxvt*)
- PROMPT_COMMAND='history -a; echo -ne "\033]0;$USER@$HOSTNAME:${PWD/$HOME/~}\007"'
- ;;
- esac
- ## }}}
- ## options and variables {{{
- shopt -s no_empty_cmd_completion
- shopt -s checkwinsize # if necessary, update LINES/COLUMNS after each command
- shopt -s cmdhist # multi-line histories
- shopt -s dotglob # include hidden files in pathname expansions
- shopt -s extglob # extended pattern matching
- shopt -s histappend # append to history file rather than overwrite
- shopt -s nocaseglob # case-insensitive matching
- # use embedded newlines instead of ; for multi-line commands
- # shopt -s lithist
- # avoid cluttering bash dotfiles
- HISTFILE=$HOME/.commandline_history
- # max number of lines in history file
- HISTFILESIZE=10000
- # max number of commands
- HISTSIZE=10000
- # commands to exclude from history
- HISTIGNORE="l[saltScoh]:cls:c[dl]:mcl *:j:bd:..*(.):popd:pp:dirs:[bf]g:pwd:?:hist?(op):clear:reset:exit"
- # exclude duplicate commands and command lines starting with space
- HISTCONTROL=ignoreboth
- # time builtin format
- TIMEFORMAT=$'\n%2lR\t%P%%'
- # allow scripts access to window dimensions
- export LINES
- export COLUMNS
- # pager
- export PAGER=less
- export LESS=-Mi
- export LESS_TERMCAP_mb=$'\e[01;31m' # blinking
- export LESS_TERMCAP_md=$'\e[01;94m' # begin bold
- export LESS_TERMCAP_so=$'\e[01;90;103m' # begin stand-out mode (search highlighting)
- export LESS_TERMCAP_us=$'\e[01;36m' # begin underline
- export LESS_TERMCAP_me=$'\e[0m' # end mode
- export LESS_TERMCAP_se=$'\e[0m' # end stand-out mode
- export LESS_TERMCAP_ue=$'\e[0m' # end underline
- # text editors
- export EDITOR='vim'
- export VISUAL='scim-run gvim'
- export GIT_EDITOR='vim'
- # python
- export PYTHONPATH="$HOME/code/py/modules"
- if [ -f "$HOME/.pythonrc" ]; then
- export PYTHONSTARTUP="$HOME/.pythonrc"
- fi
- ## }}}
- ## user bin directory {{{
- BIN="$HOME/bin"
- lnbin ()
- {
- if [ ! -d "$BIN" ] || ! type abspath &>/dev/null; then
- return 1
- fi
- local IFS=$'\n'
- local code=1 arg file
- for arg in "$@"; do
- for file in $(find "$arg" -maxdepth 1)
- do
- if [ -f "$file" -a -x "$file" ]; then
- ln -fs "$(abspath "$file")" "$BIN"
- code=0
- fi
- done
- done
- return $code
- }
- ## }}}
- # PATH
- addpath ()
- {
- [ $# -ne 1 ] && return 2
- if ! echo "$PATH" | grep '\(:\|^\)'"$1"'\(:\|$\)' >/dev/null
- then PATH="$PATH:$1"
- else return 1
- fi
- }
- # bootstrap other scripts
- addsource ()
- {
- [ $# -eq 0 ] && return 2
- local -i code=0
- local arg
- for arg in "$@"; do
- if [ -f "$arg" ]
- then . "$arg"
- else false
- fi
- code+=$?
- done
- return $code
- }
- addsource "$HOME/.bash_aliases"
- addsource "$HOME/.bash_hacks"
- addpath "."
- # done
- true
- # vim:set ts=4 sw=4 noet fdm=marker:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement