Advertisement
Guest User

PogoPlug BashRC for ArchLinux

a guest
Mar 18th, 2015
928
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.02 KB | None | 0 0
  1. # /etc/bash.bashrc
  2. #
  3. # Edited .bashrc file for PogoPlugs on ArchLinux
  4. # Used combined elements from bashrc files found here:
  5. # http://obihoernchen.net/770/plug_computer_arch_linux/
  6. # and... http://forum.doozan.com/read.php?2,11744,11744,quote=1
  7. #
  8. # https://wiki.archlinux.org/index.php/Color_Bash_Prompt
  9. #
  10. # This file is sourced by all *interactive* bash shells on startup,
  11. # including some apparently interactive shells such as scp and rcp
  12. # that can't tolerate any output. So make sure this doesn't display
  13. # anything or bad things will happen !
  14.  
  15. # Test for an interactive shell. There is no need to set anything
  16. # past this point for scp and rcp, and it's important to refrain from
  17. # outputting anything in those cases.
  18.  
  19. # If not running interactively, don't do anything!
  20. [[ $- != *i* ]] && return
  21.  
  22. # Bash won't get SIGWINCH if another process is in the foreground.
  23. # Enable checkwinsize so that bash will check the terminal size when
  24. # it regains control.
  25. # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
  26. shopt -s checkwinsize
  27.  
  28. # Enable history appending instead of overwriting.
  29. shopt -s histappend
  30.  
  31. case ${TERM} in
  32.         xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
  33.                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
  34.                 ;;
  35.         screen)
  36.                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
  37.                 ;;
  38. esac
  39.  
  40. # fortune is a simple program that displays a pseudorandom message
  41. # from a database of quotations at logon and/or logout.
  42. # Type: "pacman -S fortune-mod" to install it, then uncomment the
  43. # following line:
  44.  
  45. # [[ "$PS1" ]] && /usr/bin/fortune
  46.  
  47. # Welcome Message
  48.  
  49. # Arch Linux Logo Welcome Message
  50. c1="$(tput sgr0)$(tput setaf 4)"
  51. c2="$(tput bold)$(tput setaf 4)"
  52. c3="$(tput bold)$(tput setaf 7)"
  53. echo
  54. echo "        $c2,$c1                       _     _ _"
  55. echo "       $c2/$c1#$c2\\$c1        __ _ _ __ ___| |__ | (_)_ __  _   ___  __"
  56. echo "      $c2/$c1###$c2\\$c1      / _\` | '__/ __| '_ \\| | | '_ \\| | | \\ \\/ /"
  57. echo "     $c2/$c1#####$c2\\$c1    | (_| | | | (__| | | | | | | | | |_| |>  <"
  58. echo "    $c2/$c1##,-,##$c2\\$c1    \\__,_|_|  \\___|_| |_|_|_|_| |_|\\__,_/_/\\_\\"
  59. echo "   $c2/$c1##(   )##$c2\\$c1"
  60. echo "  $c2/$c1#.--   --.#$c2\\  $c3 A simple, elegant GNU/Linux distribution."
  61. echo " $c2/$c1\`           \`$c2\\$(tput sgr0)"$'\n'
  62.  
  63. # debian Logo Welcome Message (needs package linuxlogo)
  64. #/usr/bin/linuxlogo
  65.  
  66. # Show date
  67. DATE="$(tput setaf 1)[$(tput setaf 6)$(date)"
  68. DATE="${DATE}$(tput setaf 1)]"
  69. echo $DATE
  70. # Show kernel info
  71. KERNEL="$(tput setaf 1)[$(tput setaf 6)$(uname -srmn)"
  72. KERNEL="${KERNEL}$(tput setaf 1)]"
  73. echo "$KERNEL"$'\n'
  74. # Reset colors
  75. tput sgr0
  76. #
  77. # instead, borrow idea from http://thomashunter.name/blog/a-better-debian-ssh-login-message/
  78. w # uptime information and who is logged in
  79. echo "" # for spacing
  80. df -h -x tmpfs -x udev # disk usage, minus def and swap
  81. #
  82.  
  83. # Set colorful PS1 only on colorful terminals.
  84. # dircolors --print-database uses its own built-in database
  85. # instead of using /etc/DIR_COLORS. Try to use the external file
  86. # first to take advantage of user additions. Use internal bash
  87. # globbing instead of external grep binary.
  88.  
  89. # sanitize TERM:
  90. safe_term=${TERM//[^[:alnum:]]/?}
  91. match_lhs=""
  92.  
  93. [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
  94. [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
  95. [[ -z ${match_lhs} ]] \
  96.         && type -P dircolors >/dev/null \
  97.         && match_lhs=$(dircolors --print-database)
  98.  
  99. if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then
  100.  
  101.         # we have colors <img src="http://obihoernchen.net/wordpress/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley">
  102.  
  103.         # Enable colors for ls, etc. Prefer ~/.dir_colors
  104.         if type -P dircolors >/dev/null ; then
  105.                 if [[ -f ~/.dir_colors ]] ; then
  106.                         eval $(dircolors -b ~/.dir_colors)
  107.                 elif [[ -f /etc/DIR_COLORS ]] ; then
  108.                         eval $(dircolors -b /etc/DIR_COLORS)
  109.                 fi
  110.         fi
  111.  
  112.         # -- CUSTOM PS1 String START --
  113.  
  114.         PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\076 \[\033[0m\]"
  115.         # --- Custom PS1 String END ---
  116.  
  117.         # Use this other PS1 string if you want \W for root and \w for all other users:
  118.         # PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "
  119.  
  120.         alias ls="ls --color=auto"
  121.         alias dir="dir --color=auto"
  122.         alias grep="grep --colour=auto"
  123.  
  124. else
  125.  
  126.         # show root@ when we do not have colors
  127.  
  128.         PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "
  129.  
  130.         # Use this other PS1 string if you want \W for root and \w for all other users:
  131.         # PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "
  132.  
  133. fi
  134.  
  135. PS2="> "
  136. PS3="> "
  137. PS4="+ "
  138.  
  139. # Try to keep environment pollution down, EPA loves us.
  140. unset safe_term match_lhs
  141.  
  142. # Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
  143. [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
  144.  
  145. # Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
  146. # See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
  147. [ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement