Kurobeats

retropie_bashrc

Apr 25th, 2017
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.19 KB | None | 0 0
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples
  4.  
  5. # If not running interactively, don't do anything
  6. case $- in
  7.     *i*) ;;
  8.       *) return;;
  9. esac
  10.  
  11. # don't put duplicate lines or lines starting with space in the history.
  12. # See bash(1) for more options
  13. HISTCONTROL=ignoreboth
  14.  
  15. # append to the history file, don't overwrite it
  16. shopt -s histappend
  17.  
  18. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  19. HISTSIZE=1000
  20. HISTFILESIZE=2000
  21.  
  22. # check the window size after each command and, if necessary,
  23. # update the values of LINES and COLUMNS.
  24. shopt -s checkwinsize
  25.  
  26. # If set, the pattern "**" used in a pathname expansion context will
  27. # match all files and zero or more directories and subdirectories.
  28. #shopt -s globstar
  29.  
  30. # make less more friendly for non-text input files, see lesspipe(1)
  31. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  32.  
  33. # set variable identifying the chroot you work in (used in the prompt below)
  34. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  35.     debian_chroot=$(cat /etc/debian_chroot)
  36. fi
  37.  
  38. # set a fancy prompt (non-color, unless we know we "want" color)
  39. case "$TERM" in
  40.     xterm-color) color_prompt=yes;;
  41. esac
  42.  
  43. # uncomment for a colored prompt, if the terminal has the capability; turned
  44. # off by default to not distract the user: the focus in a terminal window
  45. # should be on the output of commands, not on the prompt
  46. force_color_prompt=yes
  47.  
  48. if [ -n "$force_color_prompt" ]; then
  49.     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  50.     # We have color support; assume it's compliant with Ecma-48
  51.     # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  52.     # a case would tend to support setf rather than setaf.)
  53.     color_prompt=yes
  54.     else
  55.     color_prompt=
  56.     fi
  57. fi
  58.  
  59. if [ "$color_prompt" = yes ]; then
  60.     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
  61. else
  62.     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  63. fi
  64. unset color_prompt force_color_prompt
  65.  
  66. # If this is an xterm set the title to user@host:dir
  67. case "$TERM" in
  68. xterm*|rxvt*)
  69.     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  70.     ;;
  71. *)
  72.     ;;
  73. esac
  74.  
  75. # enable color support of ls and also add handy aliases
  76. if [ -x /usr/bin/dircolors ]; then
  77.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  78.     alias ls='ls --color=auto'
  79.     #alias dir='dir --color=auto'
  80.     #alias vdir='vdir --color=auto'
  81.  
  82.     alias grep='grep --color=auto'
  83.     alias fgrep='fgrep --color=auto'
  84.     alias egrep='egrep --color=auto'
  85. fi
  86.  
  87. # colored GCC warnings and errors
  88. #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  89.  
  90. # some more ls aliases
  91. #alias ll='ls -l'
  92. #alias la='ls -A'
  93. #alias l='ls -CF'
  94.  
  95. # Alias definitions.
  96. # You may want to put all your additions into a separate file like
  97. # ~/.bash_aliases, instead of adding them here directly.
  98. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  99.  
  100. if [ -f ~/.bash_aliases ]; then
  101.     . ~/.bash_aliases
  102. fi
  103.  
  104. # enable programmable completion features (you don't need to enable
  105. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  106. # sources /etc/bash.bashrc).
  107. if ! shopt -oq posix; then
  108.   if [ -f /usr/share/bash-completion/bash_completion ]; then
  109.     . /usr/share/bash-completion/bash_completion
  110.   elif [ -f /etc/bash_completion ]; then
  111.     . /etc/bash_completion
  112.   fi
  113. fi
  114. # RETROPIE PROFILE START
  115.  
  116. function retropie_welcome() {
  117.     local upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
  118.     local secs=$((upSeconds%60))
  119.     local mins=$((upSeconds/60%60))
  120.     local hours=$((upSeconds/3600%24))
  121.     local days=$((upSeconds/86400))
  122.     local UPTIME=$(printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs")
  123.  
  124.     # calculate rough CPU and GPU temperatures:
  125.     local cpuTempC
  126.     local cpuTempF
  127.     local gpuTempC
  128.     local gpuTempF
  129.     if [[ -f "/sys/class/thermal/thermal_zone0/temp" ]]; then
  130.         cpuTempC=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000)) && cpuTempF=$((cpuTempC*9/5+32))
  131.     fi
  132.  
  133.     if [[ -f "/opt/vc/bin/vcgencmd" ]]; then
  134.         if gpuTempC=$(/opt/vc/bin/vcgencmd measure_temp); then
  135.             gpuTempC=${gpuTempC:5:2}
  136.             gpuTempF=$((gpuTempC*9/5+32))
  137.         else
  138.             gpuTempC=""
  139.         fi
  140.     fi
  141.  
  142.     local df_out=()
  143.     local line
  144.     while read line; do
  145.         df_out+=("$line")
  146.     done < <(df -h /)
  147.  
  148.     local rst="$(tput sgr0)"
  149.     local fgblk="${rst}$(tput setaf 0)" # Black - Regular
  150.     local fgred="${rst}$(tput setaf 1)" # Red
  151.     local fggrn="${rst}$(tput setaf 2)" # Green
  152.     local fgylw="${rst}$(tput setaf 3)" # Yellow
  153.     local fgblu="${rst}$(tput setaf 4)" # Blue
  154.     local fgpur="${rst}$(tput setaf 5)" # Purple
  155.     local fgcyn="${rst}$(tput setaf 6)" # Cyan
  156.     local fgwht="${rst}$(tput setaf 7)" # White
  157.  
  158.     local bld="$(tput bold)"
  159.     local bfgblk="${bld}$(tput setaf 0)"
  160.     local bfgred="${bld}$(tput setaf 1)"
  161.     local bfggrn="${bld}$(tput setaf 2)"
  162.     local bfgylw="${bld}$(tput setaf 3)"
  163.     local bfgblu="${bld}$(tput setaf 4)"
  164.     local bfgpur="${bld}$(tput setaf 5)"
  165.     local bfgcyn="${bld}$(tput setaf 6)"
  166.     local bfgwht="${bld}$(tput setaf 7)"
  167.  
  168.     local logo=(
  169.         "${fgred}   .***.   "
  170.         "${fgred}   ***${bfgwht}*${fgred}*   "
  171.         "${fgred}   \`***'   "
  172.        "${bfgwht}    |*|    "
  173.        "${bfgwht}    |*|    "
  174.        "${bfgred}  ..${bfgwht}|*|${bfgred}..  "
  175.        "${bfgred}.*** ${bfgwht}*${bfgred} ***."
  176.        "${bfgred}*******${fggrn}@@${bfgred}**"
  177.        "${fgred}\`*${bfgred}****${bfgylw}@@${bfgred}*${fgred}*'"
  178.         "${fgred} \`*******'${fgrst} "
  179.        "${fgred}   \`\"\"\"'${fgrst}   "
  180.         )
  181.  
  182.     local out
  183.     local i
  184.     for i in "${!logo[@]}"; do
  185.         out+="  ${logo[$i]}  "
  186.         case "$i" in
  187.             0)
  188.                 out+="${fggrn}$(date +"%A, %e %B %Y, %r")"
  189.                 ;;
  190.             1)
  191.                 out+="${fggrn}$(uname -srmo)"
  192.                 ;;
  193.             3)
  194.                 out+="${fgylw}${df_out[0]}"
  195.                 ;;
  196.             4)
  197.                 out+="${fgwht}${df_out[1]}"
  198.                 ;;
  199.             5)
  200.                 out+="${fgred}Uptime.............: ${UPTIME}"
  201.                 ;;
  202.             6)
  203.                 out+="${fgred}Memory.............: $(grep MemFree /proc/meminfo | awk {'print $2'})kB (Free) / $(grep MemTotal /proc/meminfo | awk {'print $2'})kB (Total)"
  204.                 ;;
  205.             7)
  206.                 out+="${fgred}Running Processes..: $(ps ax | wc -l | tr -d " ")"
  207.                 ;;
  208.             8)
  209.                 out+="${fgred}IP Address.........: $(ip route get 8.8.8.8 2>/dev/null | head -1 | cut -d' ' -f8)"
  210.                 ;;
  211.             9)
  212.                 out+="Temperature........: CPU: $cpuTempC°C/$cpuTempF°F GPU: $gpuTempC°C/$gpuTempF°F"
  213.                 ;;
  214.             10)
  215.                 out+="${fgwht}The RetroPie Project, https://retropie.org.uk"
  216.                 ;;
  217.         esac
  218.         out+="\n"
  219.     done
  220.     echo -e "\n$out"
  221. }
  222.  
  223. retropie_welcome
  224. # RETROPIE PROFILE END
Add Comment
Please, Sign In to add comment