Advertisement
Yunga

bashrc

May 25th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.21 KB | None | 0 0
  1. # ~/.bashrc -- yunga.palatino@gmail.com
  2.  
  3. umask 002
  4.  
  5. ### Non-interactive shell stops here
  6. [[ $- != *i* ]] && return;
  7.  
  8. WARNINGS=0
  9.  
  10.  
  11. ### Locales
  12. unset -v LC_ALL
  13. export LANG="en_US.utf-8"              # All locale settings at once, customization in LC_* below
  14. export LC_COLLATE="C.utf-8"            # Define alphabetical ordering of strings.
  15. export LC_CTYPE="fr_FR.utf-8"          # Determines which characters are seen as part of alphabet, numeric and so on. This also determines the character set used, if applicable.
  16. export LC_MESSAGES="C.utf-8"           # Program localizations
  17. export LC_TIME="POSIX"                 # Time format
  18.  
  19.  
  20. ### Temporay files directory
  21. export TMP="$HOME/tmp"                 # Temporary directory
  22. export TEMP="$TMP"                     # for dos/win apps
  23. export TMPDIR="$TMP"                   # Unix
  24.  
  25. if [[ ! -d $TMP ]]; then               # xxx maybe create the temp dir?
  26.     echo bashrc: Something is wrong with your TMP dir: "$TMP".
  27.     unset -v TMP TEMP TMPDIR
  28. fi
  29.  
  30.  
  31. ### Bash Options
  32. #export TMOUT=300                       # Exit bash after 5 minutes (for remote users)
  33. export IGNOREEOF=1                     # CTRL-D twice to exit
  34. export CDPATH=".:~/.cdpath"            # Path to search when cd'ing
  35. export TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS\ncpu%%\t%P' # Output format for the time builtin
  36.  
  37. # History settings:
  38. export HISTFILESIZE=4096               # Number of line to save
  39. export HISTSIZE=1024                   # Number of command to remember
  40. export HISTCONTROL="ignoreboth"        # dont save already entered commands, and command starting with a space (same as ignoredups:ignorespace)
  41. export PROMPT_COMMAND='history -a'     # Save history everytime you issue a command, useful when multiple bash are running in screen (see shopt -s histappend)
  42.  
  43.  
  44. ### Editor
  45. export EDITOR="vim"
  46. export VISUAL=$EDITOR                  # screen oriented editor (as opposed to ed)
  47. export FCEDIT=$EDITOR                  # edit command with vim
  48.  
  49.  
  50. ### Pager
  51. unset -v LESSCHARSET # Fix manpages looking funky
  52. export PAGER='less'
  53. export LESS='-iMnQRSw -PM[%i/%m\: ?f%f:STDIN.] [C\:%c] [L\:?l%l:*.-?lb%lb:*./?L%L:*.] [P\:?d%d:*./?D%D:*.] [O\:?b%b:*./?B%B:*.] [?pt%pt:*.-?Pb%Pb:*.\%]'
  54. export LESS_TERMCAP_mb=$(tput bold; tput setaf 2)               # green
  55. export LESS_TERMCAP_md=$(tput bold; tput setaf 6)               # cyan
  56. export LESS_TERMCAP_me=$(tput sgr0)
  57. export LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4) # yellow on blue
  58. export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
  59. export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7)    # white
  60. export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
  61. export LESS_TERMCAP_mr=$(tput rev)
  62. export LESS_TERMCAP_mh=$(tput dim)
  63. export LESS_TERMCAP_ZN=$(tput ssubm)
  64. export LESS_TERMCAP_ZV=$(tput rsubm)
  65. export LESS_TERMCAP_ZO=$(tput ssupm)
  66. export LESS_TERMCAP_ZW=$(tput rsupm)
  67. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  68. ### Various
  69. export GREP_COLOR=31
  70. #export LYNX_CFG="~/.lynx/lynx.cfg"
  71. export SCREENRC="$HOME/.screenrc"
  72. eval "$(dircolors .dircolors)"
  73.  
  74.  
  75. ### Command line option/completion
  76. export FIGNORE='.bck:.bak:.sav:~'            # ignored ext for completion
  77. if [ -f /etc/bash_completion ]; then
  78.     . /etc/bash_completion
  79. fi
  80.  
  81. ### if the command-not-found package is installed, use it
  82. if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found ]; then
  83.     function command_not_found_handle {
  84.         # check because c-n-f could've been removed in the meantime
  85.         if [ -x /usr/lib/command-not-found ]; then
  86.             /usr/bin/python /usr/lib/command-not-found -- $1
  87.             return $?
  88.         elif [ -x /usr/share/command-not-found ]; then
  89.             /usr/bin/python /usr/share/command-not-found -- $1
  90.             return $?
  91.         else
  92.             return 127
  93.         fi
  94.     }
  95. fi
  96.  
  97.  
  98. ### Setting PATH:
  99. export PATH="~/bin/:$PATH"
  100. #unset -v PATH
  101. #line=1
  102. #while read -r path; do
  103. #   path=${path%#*}
  104. #   path=${path##*([$' \t\n'])}
  105. #   path=${path%%*([$' \t\n'])}
  106. #   eval "path=\"$path\""
  107. #
  108. #   if [[ $path ]]; then
  109. #       if [[ -d "$path" && -r "$path" ]]; then
  110. #           PATH="$PATH:$path"
  111. #       else
  112. #           [ $WARNINGS == 1 ] && echo Discarded "$path" at line $line from your PATH.
  113. #       fi
  114. #   fi
  115. #
  116. #   let line=line+1
  117. #done < ~/.bash/path.txt
  118. #
  119. #unset -v line path
  120. #export PATH
  121.  
  122.  
  123. ### Load shell options, aliases, functions, and host configurations file.
  124. # ATTN: All previously defined aliases will be removed!
  125. for file in ~/.bash/shell_options.sh ~/.bash/aliases_functions.sh ~/.bash/hosts/$HOSTNAME_*.sh; do
  126.     if [[ -f  $file && -r $file ]]; then
  127.         . $file
  128.     else
  129.         [ $WARNINGS == 1 ] && echo bashrc: there is an problem with "$file".
  130.     fi
  131. done
  132. unset -v file
  133.  
  134.  
  135. ### Prompt
  136. # Old: PS1="\n\033[93;44m\n\033[93;92mDate: \033[93;44m\d, \t \033[0;92m\nUser: \033[0;97m[\033[0;93m\u\033[0;97m@\033[0;93m\H\033[0;97m] \033[0;92mJobs: \033[0;97m[\033[0;93m\j\033[0;97m]\033[0;92m History: \033[0;97m[\033[0;93m\!\033[0;97m]\033[0;39m\n\033[0;93m\w\033[0;97m\$\033[0;39m "
  137. PS1='\n\[\017\]\033[33;`if [ $? = 0 ]; then echo "44"; else echo "41"; fi`;1m\n# \D{%F %T} \033[32mU:\033[37m[\033[33m\u\033[37m@\033[33m\H\033[37m] \033[32mJ:\033[37m[\033[33m\j\033[37m] \033[32mH:\033[37m[\033[33m\#/\!\033[37m]\033[33;40;1m\n# \w\033[37m\$\[\033[0m\]\n'
  138. PS2='\033[0;91m> \033[0;39m'
  139.  
  140.  
  141. ### Keyboard, bell, display style: the readline config file:
  142. export INPUTRC="$HOME/.inputrc"        # process my readline settings
  143. bind -f ~/.inputrc
  144.  
  145.  
  146. ### Function keys (use ctrl-v key at prompt to know the assigned string, it's a hack)
  147. # here we assign
  148. bind '"\eOP":"\201"';   bind -x '"\201":"aliasinfo"'       #   F1:  Aliases help
  149. bind '"\e[23~":"\212"'; bind -x '"\212":"cliref"'          # S-F1:  Unix CLI Reference
  150. bind '"\eOQ":"\202"';   bind -x '"\202":"ncal -y | less"'  #   F2:  Display Calendar
  151. bind '"\eOR":"\203"';   bind -x '"\203":"psaux -p$USER"'   #   F3:  List Processes
  152. bind '"\eOS":"\204"';   bind -x '"\204":"$EDITOR ."'       #   F4:  Editor
  153. bind '"\e[20~":"\209"'; bind -x '"\209":"htop"'            #   F8:  Htop
  154. bind '"\e[21~":"\210"'; bind -x '"\210":"mc"'              #   F10: Midnight Commander
  155.  
  156.  
  157. ### Perl local::lib, touch ~/.perlib to enable this
  158. if [[ -f ~/.perlocalib ]]; then
  159.     cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
  160. fi
  161.  
  162. ### Clean
  163. unset -v WARNINGS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement