Advertisement
Guest User

Untitled

a guest
Dec 16th, 2016
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.56 KB | None | 0 0
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2.  
  3. # If not running interactively, don't do anything
  4. case $- in
  5.     *i*) ;;
  6.       *) return;;
  7. esac
  8.  
  9. # don't put duplicate lines or lines starting with space in the history.
  10. HISTCONTROL=ignoreboth
  11.  
  12. # Add to history instead of overriding it
  13. shopt -s histappend
  14.  
  15. # History lenght
  16. HISTSIZE=1000
  17. HISTFILESIZE=2000
  18.  
  19. # Window size sanity check
  20. shopt -s checkwinsize
  21.  
  22. # User/root variables definition
  23. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  24.     debian_chroot=$(cat /etc/debian_chroot)
  25. fi
  26.  
  27. # Colored XTERM promp
  28. case "$TERM" in
  29.     xterm-color) color_prompt=yes;;
  30. esac
  31.  
  32. # Colored prompt
  33. force_color_prompt=yes
  34.  
  35. if [ -n "$force_color_prompt" ]; then
  36.     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  37.     color_prompt=yes
  38.     else
  39.     color_prompt=
  40.     fi
  41. fi
  42.  
  43. # Prompt Ⓤ    Ⓤ
  44. if [ -n "$SSH_CONNECTION" ]; then
  45. export PS1="\[$(tput setaf 7)\]┌\[$(tput setaf 6)\] U \[$(tput setaf 7)\][\w]\n\[$(tput setaf 7)\]\$(if [[ \$? == 0 ]]; then echo \"\[$(tput setaf 7)\]└╼ \[$(tput setaf 7)\][ssh]\"; else echo \"\[$(tput setaf 7)\]└╼ \[$(tput setaf 7)\][ssh]\"; fi) \[$(tput setaf 7)\]"
  46. else
  47. export PS1="\[$(tput setaf 7)\]┌\[$(tput setaf 6)\] U \[$(tput setaf 7)\][\w]\n\[$(tput setaf 7)\]\$(if [[ \$? == 0 ]]; then echo \"\[$(tput setaf 7)\]└╼\"; else echo \"\[$(tput setaf 7)\]└╼\"; fi) \[$(tput setaf 7)\]"
  48. fi
  49.  
  50. trap 'echo -ne "\e[0m"' DEBUG
  51.  
  52. # I this is an xterm set the title to user@host:dir
  53. case "$TERM" in
  54. xterm*|rxvt*)
  55.     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u: \w\a\]$PS1"
  56.     ;;
  57. *)
  58.     ;;
  59. esac
  60.  
  61. # Color support
  62. if [ -x /usr/bin/dircolors ]; then
  63.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  64.     alias ls='ls --color=auto'
  65. fi
  66.  
  67. # Alias definitions.
  68. if [ -f ~/.bash_aliases ]; then
  69.     . ~/.bash_aliases
  70. fi
  71.  
  72. # Auto-completion
  73. if ! shopt -oq posix; then
  74.   if [ -f /usr/share/bash-completion/bash_completion ]; then
  75.     . /usr/share/bash-completion/bash_completion
  76.   elif [ -f /etc/bash_completion ]; then
  77.     . /etc/bash_completion
  78.   fi
  79. fi
  80.  
  81. # Advanced directory creation
  82. function mkcd {
  83.   if [ ! -n "$1" ]; then
  84.     echo "Entrez un nom pour ce dossier"
  85.   elif [ -d $1 ]; then
  86.     echo "\`$1' existe déjà"
  87.   else
  88.     mkdir $1 && cd $1
  89.   fi
  90. }
  91.  
  92. # Go back with ..
  93. b() {
  94.     str=""
  95.     count=0
  96.     while [ "$count" -lt "$1" ];
  97.     do
  98.         str=$str"../"
  99.         let count=count+1
  100.     done
  101.     cd $str
  102. }
  103.  
  104. # Color man pages
  105. man() {
  106.     env \
  107.         LESS_TERMCAP_mb=$(printf "\e[1;31m") \
  108.         LESS_TERMCAP_md=$(printf "\e[1;31m") \
  109.         LESS_TERMCAP_me=$(printf "\e[0m") \
  110.         LESS_TERMCAP_se=$(printf "\e[0m") \
  111.         LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
  112.         LESS_TERMCAP_ue=$(printf "\e[0m") \
  113.         LESS_TERMCAP_us=$(printf "\e[1;32m") \
  114.             man "$@"
  115. }
  116.  
  117. # Auto cd
  118. shopt -s autocd
  119.  
  120. # ls after a cd
  121. function cd()
  122. {
  123.  builtin cd "$*" && ls
  124. }
  125.  
  126. extract () {
  127.     if [ -f $1 ] ; then
  128.       case $1 in
  129.         *.tar.bz2)   tar xjf $1     ;;
  130.         *.tar.gz)    tar xzf $1     ;;
  131.         *.bz2)       bunzip2 $1     ;;
  132.         *.rar)       unrar e $1     ;;
  133.         *.gz)        gunzip $1      ;;
  134.         *.tar)       tar xf $1      ;;
  135.         *.tbz2)      tar xjf $1     ;;
  136.         *.tgz)       tar xzf $1     ;;
  137.         *.zip)       unzip $1       ;;
  138.         *.Z)         uncompress $1  ;;
  139.         *.7z)        7z x $1        ;;
  140.         *)     echo "'$1' cannot be extracted via extract()" ;;
  141.          esac
  142.      else
  143.          echo "'$1' is not a valid file"
  144.      fi
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement