Advertisement
bee1k

bashrc

Jul 23rd, 2012
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.21 KB | None | 0 0
  1. #!/bin/bash
  2. # based on a function found in bashtstyle-ng 5.0b1
  3. # Original author Christopher Roy Bratusek (http://www.nanolx.org)
  4. # Last arranged by ayoli (http://ayozone.org) 2008-02-04 17:16:43 +0100 CET
  5.  
  6. function pre_prompt {
  7. newPWD="${PWD}"
  8. user="whoami"
  9. host=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
  10. datenow=$(date "+%a, %d %b %y")
  11. let promptsize=$(echo -n "┌($user@$host ddd., DD mmm YY)(`date \"+%H:%M\"`)┐" \
  12.                  | wc -c | tr -d " ")
  13. let fillsize=${COLUMNS}-${promptsize}
  14. fill=""
  15. while [ "$fillsize" -gt "0" ]
  16. do
  17.     fill="${fill}─"
  18.     let fillsize=${fillsize}-1
  19. done
  20. if [ "$fillsize" -lt "0" ]
  21. then
  22.     let cutt=3-${fillsize}
  23.     newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
  24. fi
  25.  
  26. }
  27.  
  28. PROMPT_COMMAND=pre_prompt
  29.  
  30. export black="\[\033[0;38;5;0m\]"
  31. export red="\[\033[0;38;5;1m\]"
  32. export orange="\[\033[0;38;5;130m\]"
  33. export green="\[\033[0;38;5;2m\]"
  34. export yellow="\[\033[0;38;5;3m\]"
  35. export blue="\[\033[0;38;5;4m\]"
  36. export bblue="\[\033[0;38;5;12m\]"
  37. export magenta="\[\033[0;38;5;55m\]"
  38. export cyan="\[\033[0;38;5;6m\]"
  39. export white="\[\033[0;38;5;7m\]"
  40. export coldblue="\[\033[0;38;5;33m\]"
  41. export smoothblue="\[\033[0;38;5;111m\]"
  42. export iceblue="\[\033[0;38;5;45m\]"
  43. export turqoise="\[\033[0;38;5;50m\]"
  44. export smoothgreen="\[\033[0;38;5;42m\]"
  45. export myred="\[\033[01;31m\]"
  46.  
  47.  
  48. case "$TERM" in
  49. xterm)
  50.    PS1="$bblue┌─[$myred\u@\h \$(date \"+%a, %d %b %y\")$bblue]─\${fill}───[$myred\$(date \"+%H:%M\")\
  51. $bblue]──┐\n$bblue└─[$myred\$newPWD$bblue]>$white "
  52.    ;;
  53. screen)
  54.    PS1="$white┌─[$myred\u@\h \$(date \"+%a, %d %b %y\")$white]─\${fill}───[$myred\$(date \"+%H:%M\")\
  55. $white]──┐\n$white└─[$myred\$newPWD$white]>$white "
  56.    ;;    
  57.    *)
  58.    PS1="┌─(\u@\h \$(date \"+%a, %d %b %y\"))─\${fill}(\$newPWD\
  59. )─┐\n└─(\$(date \"+%H:%M\") \$)> "
  60.    ;;
  61. esac
  62.  
  63. # bash_history settings: size and no duplicates and no lines w/ lead spaces
  64. exportHISTCONTROL="ignoreboth"
  65. export HISTSIZE=1024
  66.  
  67. # aliases #############################################
  68.  
  69. # enable color support of ls and also add handy aliases
  70. eval `dircolors -b`
  71. alias ls='ls --color=auto'
  72. alias dir='ls --color=auto --format=vertical'
  73. alias vdir='ls --color=auto --format=long'
  74.  
  75. # some more ls aliases
  76. alias ll='ls -lhX'
  77. alias la='ls -A'
  78. alias ldir='ls -lhA |grep ^d'
  79. alias lfiles='ls -lhA |grep ^-'
  80. #alias l='ls -CF'
  81.  
  82. # To see something coming into ls output: lss
  83. alias lss='ls -lrt | grep $1'
  84.  
  85. # To check a process is running in a box with a heavy load: pss
  86. alias pss='ps -ef | grep $1'
  87.  
  88. # usefull alias to browse your filesystem for heavy usage quickly
  89. alias ducks='ls -A | grep -v -e '\''^\.\.$'\'' |xargs -i du -ks {} |sort -rn |head -16 | awk '\''{print $2}'\'' | xargs -i du -hs {}'
  90.  
  91. # cool colors for manpages
  92. alias man="TERMINFO=~/.terminfo TERM=mostlike LESS=C PAGER=less man"
  93.  
  94. ##########################################################
  95. # enable programmable completion features (you don't need to enable
  96. # this, if it's already enabled in /etc/bash.bashrc).
  97. if [ -f /etc/bash_completion ]; then
  98.    . /etc/bash_completion
  99. fi
  100.  
  101. # CDPATH initialisation
  102. CDPATH=.:~:/media/store:/media/sites
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement