Select Git revision
Forked from
Video AG Infrastruktur / website
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
bashrc 4.24 KiB
bash_prompt() {
case $TERM in
xterm*|rxvt*)
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
;;
*)
local TITLEBAR=""
;;
esac
local NONE="\[\033[0m\]" # unsets color to term's fg color
# regular colors
local K="\[\033[0;30m\]" # black
local R="\[\033[0;31m\]" # red
local G="\[\033[0;32m\]" # green
local Y="\[\033[0;33m\]" # yellow
local B="\[\033[0;34m\]" # blue
local M="\[\033[0;35m\]" # magenta
local C="\[\033[0;36m\]" # cyan
local W="\[\033[0;37m\]" # white
# emphasized (bolded) colors
local EMK="\[\033[1;30m\]"
local EMR="\[\033[1;31m\]"
local EMG="\[\033[1;32m\]"
local EMY="\[\033[1;33m\]"
local EMB="\[\033[1;34m\]"
local EMM="\[\033[1;35m\]"
local EMC="\[\033[1;36m\]"
local EMW="\[\033[1;37m\]"
# background colors
local BGK="\[\033[40m\]"
local BGR="\[\033[41m\]"
local BGG="\[\033[42m\]"
local BGY="\[\033[43m\]"
local BGB="\[\033[44m\]"
local BGM="\[\033[45m\]"
local BGC="\[\033[46m\]"
local BGW="\[\033[47m\]"
local UC=$G # user's color
[ $UID -eq "0" ] && UC=$R # root's color
PS1="$TITLEBAR ${EMW}\t [${UC}\u ${EMK}@ ${C}\h${EMW}] ${EMC}\w ${UC}\\$ ${NONE}"
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "
# extra backslash in front of \$ to make bash colorize the prompt
}
#append_root() {
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$1/lib
# export PATH=$PATH:$1/bin
# export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$1/lib/pkgconfig
# for D in $1/lib/python*/site-packages; do
# export PYTHONPATH=$PYTHONPATH:$D
# done
#}
prepend_root() {
echo "** prepend $1"
export LD_LIBRARY_PATH="$1/lib:$LD_LIBRARY_PATH"
export PATH="$1/bin:$PATH"
export PKG_CONFIG_PATH="$1/lib/pkgconfig:$PKG_CONFIG_PATH"
for D in $1/lib/python*/site-packages; do
export PYTHONPATH="$D:$PYTHONPATH"
done
}
append_element() {
local IFS=":"
for item in $1; do
if ! [[ $item == $2* ]]; then
echo -n "$item:"
fi
done
echo $2
}
prepend_element() {
local IFS=":"
echo $2
for item in $1; do
if ! [[ $item == $2* ]]; then
echo -n ":$item"
fi
done
}
remove_element() {
local IFS=":"
for item in $1; do
if ! [[ $item == $2* ]]; then
echo -n ":$item"
fi
done
}
list_path() {
local IFS=":"
for item in $1; do
echo $item
done
}
append_root() {
export LD_LIBRARY_PATH=$(append_element $LD_LIBRARY_PATH $1/lib)
export PATH=$(append_element $PATH $1/bin)
export PKG_CONFIG_PATH=$(append_element $PKG_CONFIG_PATH $1/lib/pkgconfig)
for D in $1/lib/python*/site-packages; do
export PYTHONPATH=$(append_element $PYTHONPATH $D)
done
}
remove_root() {
PATH=$(remove_element $PATH $1)
LD_LIBRARY_PATH=$(remove_element $LD_LIBRARY_PATH $1)
PKG_CONFIG_PATH=$(remove_element $PKG_CONFIG_PATH $1)
PYTHONPATH=$(remove_element $PYTHONPATH $1)
}
# Check for an interactive session
[ -z "$PS1" ] && return
if [ "$PS1" ]; then
shopt -s checkwinsize
shopt -s cdspell
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
alias ls='ls -h --color=auto'
alias l='ls -lh --color=auto'
alias ll='ls -Alh --color=auto'
alias ssh='ssh -A -X'
alias make='make -j 4'
alias ne='TERM=xterm ne'
alias ..='cd ..'
bash_prompt
export EDITOR=/usr/bin/vim
set bell-style none
# enhanced bash completition
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
if [ -f ~/.bash_completion ]; then
. ~/.bash_completion
fi
# if [ -z "$SSH_AUTH_SOCK" ] && [ "${SSH_AUTH_SOCK}xxx" = "xxx" ]; then
# SSH_ENV="$HOME/.ssh/environment"
# echo "Starting KeyChain"
# # Source SSH settings, if applicable
# keychain --nogui --eval id_rsa
# . ~/.keychain/$HOSTNAME-sh &> /dev/null
# . ~/.keychain/$HOSTNAME-sh-gpg &> /dev/null
# fi
#prepend_root $HOME/.local
if [ -f $HOME/.bashrc.local ]
then
source $HOME/.bashrc.local
fi
fi