From 40af9cf335427c69e67ec070f4e01d89e8d42e01 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Thu, 27 Oct 2016 00:15:12 +0100 Subject: [PATCH] Command prompt time is moved after hostname + minor enhancements/bug fixes. --- config/.bashrc | 118 +++++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/config/.bashrc b/config/.bashrc index 531d9f0..401792c 100755 --- a/config/.bashrc +++ b/config/.bashrc @@ -41,6 +41,23 @@ kversion=`uname -v` krelease=`uname -r` hostnm=`hostname` +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Bash history +# + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth +# append to the history file, don't overwrite it +shopt -s histappend +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=5000 +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Terminal colors if interactive @@ -109,12 +126,13 @@ if [ -n "$PS1" ]; then # # Colors should be set here and surrounded with \[\]otherwise bash fails to # calculate prompt length. The text is set through PROMPT_COMMAND - PS1="\[$c_user\]\u@\h: \[$c_cwd\]\w" # username@host: working_dir + PS1="\[$c_user\]\u@\h:" # username@host: + PS1+="\[$c_time\]\t" # time + PS1+=" \[$c_cwd\]\w" # working_dir PS1+="\[$c_branch\]\$git_text" # git branch PS1+="\[$c_branch\]\$svn_text" # svn revision PS1+="\[$c_exit\]\$exit_text" # exit status of last command PS1+="\[$c_jobs\]\$jobs_text" # background/suspended jobs - PS1+=" \[$c_time\]\t" # time PS1+="\[$c_reset\]\$ " # reset colors and print $ export PROMPT_COMMAND="__prompt_command; $PROMPT_COMMAND" @@ -175,92 +193,86 @@ fi # # User specific environment and startup programs # -if [ $kernel == Linux ]; then + +# +# Set my paths. +# +if [ -e $HOME/local ]; then + MYLOCAL=$HOME/local +elif [ $kernel == Linux ] && [ -e $HOME/local-lnx ]; then MYLOCAL=$HOME/local-lnx -elif [ $kernel == SunOS ]; then +elif [ $kernel == SunOS ] && [ -e $HOME/local-sun ]; then MYLOCAL=$HOME/local-sun fi +if [ -e $MYLOCAL/bin ]; then + export PATH=$MYLOCAL/bin:$PATH +fi + MYSCRIPTS=$HOME/devel/scripts -PATH=$MYLOCAL/bin:$PATH -PATH=$MYSCRIPTS/bin:$PATH +if [ -e $MYSCRIPTS/bin ]; then + export PATH=$MYSCRIPTS/bin:$PATH +fi # # VIM # export EDITOR=vim +# +# 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 ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + # # GIT # [ -f $MYSCRIPTS/bash/git-completion.bash ] && . $MYSCRIPTSE/bash/git-completion.bash # -# GCC +# colored GCC warnings and errors # -#if [ -e /depot/gcc-4.7.2/bin ]; then -# PATH=/depot/gcc-4.7.2/bin:$PATH -# LD_LIBRARY_PATH=/depot/gcc-4.7.2/lib64:$LD_LIBRARY_PATH -#elif [ -e /depot/gcc-4.7.0/bin ]; then -# PATH=/depot/gcc-4.7.0/bin:$PATH -# LD_LIBRARY_PATH=/depot/gcc-4.7.0/lib64:$LD_LIBRARY_PATH -#elif [ -e /depot/gcc-4.5.2/bin ]; then -# PATH=/depot/gcc-4.5.2/bin:$PATH -# LD_LIBRARY_PATH=/depot/gcc-4.5.2/lib64:$LD_LIBRARY_PATH -#fi - -# -# GDB -# -#prepath /depot/gdb-7.5.1/bin - -# -# VTune Amplifier -# -#export INTEL_LICENSE_FILE=28518@us01-lic10:28518@us01-lic11:28518@us01-lic12:28518@tyndall -#alias vtune=/depot/vtune_amplifier_xe_2013_update5/bin64/amplxe-gui - -# -# PURIFY and all. -# -#postpath /depot/coverity/swat/bin -#export RSU_TEMPLATE2_INI=/depot/pure/templates2.ini -#export RSU_LICENSE_MAP=/depot/pure/PurifyPlus_License_Map -#export PURECOVOPTIONS="-force-rebuild=no -log-file=./%v.%p.log -counts-file=./%v.%p.pcv -windows=no" -#export PUREOPTIONS="-force-rebuild=no -always-use-cache-dir=yes -cache-dir=$HOME/tmp/pure_cache" -#export QUANTIFYOPTIONS="-force-rebuild=no -always-use-cache-dir=yes -cache-dir=$HOME/tmp/pure_cache" -#export LD_LIBRARY_PATH=$HOME/prj/fw/rmain/3pty/qt/4.7.2/amd64/lib:$LD_LIBRARY_PATH -#alias purecov="/depot/swe/a2007.12/bin/purecov" -#alias quantify"/depot/swe/a2007.12/bin/quantify" - -# -# Make sure to export PATH -# -export PATH -export HISTFILESIZE=5000 # Store 5000 commands in history -export HISTCONTROL=ignoredups # Don't put duplicate lines in the history. +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Aliases # if [ $kernel == AIX ]; then - alias l='ls -a' alias ls='ls -a' alias ll='ls -la' alias pd='pushd >/dev/null' alias bd='popd' else - alias l='ls -a --color=tty' - alias ls='ls -a --color=tty' - alias ll='ls -la --color=tty' + alias ls='ls -a --color=auto' + alias ll='ls -la --color=auto' alias pd='pushd >/dev/null' alias bd='popd' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' fi alias cgrep="grep --include \*.cpp --include \*.h --include \*.c" + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Run local settings. # -[ -f $PWD/.bashrc.local ] && . $PWD/.bashrc.local +[ -x $PWD/.bashrc.local ] && . $PWD/.bashrc.local +# +# Clean error level. +# +[ 1 ]