You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bashrc 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. # If not running interactively, don't do anything
  5. #if [ $(tty) = "/dev/tty1" ]
  6. #then
  7. # startx
  8. #fi
  9. case $- in
  10. *i*) ;;
  11. *) return;;
  12. esac
  13. source ~/.git-prompt.sh
  14. # don't put duplicate lines or lines starting with space in the history.
  15. # See bash(1) for more options
  16. HISTCONTROL=ignoreboth
  17. # append to the history file, don't overwrite it
  18. shopt -s histappend
  19. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  20. HISTSIZE=1000
  21. HISTFILESIZE=2000
  22. # check the window size after each command and, if necessary,
  23. # update the values of LINES and COLUMNS.
  24. shopt -s checkwinsize
  25. # If set, the pattern "**" used in a pathname expansion context will
  26. # match all files and zero or more directories and subdirectories.
  27. #shopt -s globstar
  28. # make less more friendly for non-text input files, see lesspipe(1)
  29. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  30. # set variable identifying the chroot you work in (used in the prompt below)
  31. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  32. debian_chroot=$(cat /etc/debian_chroot)
  33. fi
  34. # set a fancy prompt (non-color, unless we know we "want" color)
  35. case "$TERM" in
  36. xterm-color) color_prompt=yes;;
  37. esac
  38. # uncomment for a colored prompt, if the terminal has the capability; turned
  39. # off by default to not distract the user: the focus in a terminal window
  40. # should be on the output of commands, not on the prompt
  41. force_color_prompt=yes
  42. if [ -n "$force_color_prompt" ]; then
  43. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  44. # We have color support; assume it's compliant with Ecma-48
  45. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  46. # a case would tend to support setf rather than setaf.)
  47. color_prompt=yes
  48. else
  49. color_prompt=
  50. fi
  51. fi
  52. if [ "$color_prompt" = yes ]; then
  53. PS1='\[\e[01;31m\]$(_ps1_exit_status)\[\e[0m\]${debian_chroot:+($debian_chroot)}\u@\H:'"\[\e[01;34m\]\w\[\e[0m\]\[\e[01;32m\]"'$(__git_ps1 " [%s]")'"\[\e[0m\]\$ "
  54. else
  55. PS1='$?${debian_chroot:+($debian_chroot)}\u@\H:\w$(__git_ps1)\$ '
  56. fi
  57. unset color_prompt force_color_prompt
  58. # If this is an xterm set the title to user@host:dir
  59. case "$TERM" in
  60. xterm*|rxvt*)
  61. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  62. ;;
  63. *)
  64. ;;
  65. esac
  66. # enable color support of ls and also add handy aliases
  67. if [ -x /usr/bin/dircolors ]; then
  68. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  69. alias ls='ls --color=auto'
  70. #alias dir='dir --color=auto'
  71. #alias vdir='vdir --color=auto'
  72. alias grep='grep --color=auto'
  73. alias fgrep='fgrep --color=auto'
  74. alias egrep='egrep --color=auto'
  75. fi
  76. # some more ls aliases
  77. alias ll='ls -alF'
  78. alias la='ls -A'
  79. alias l='ls -CF'
  80. # Add an "alert" alias for long running commands. Use like so:
  81. # sleep 10; alert
  82. # Alias definitions.
  83. # You may want to put all your additions into a separate file like
  84. # ~/.bash_aliases, instead of adding them here directly.
  85. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  86. if [ -f ~/.bash_aliases ]; then
  87. . ~/.bash_aliases
  88. fi
  89. # enable programmable completion features (you don't need to enable
  90. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  91. # sources /etc/bash.bashrc).
  92. if ! shopt -oq posix; then
  93. if [ -f /usr/share/bash-completion/bash_completion ]; then
  94. . /usr/share/bash-completion/bash_completion
  95. elif [ -f /etc/bash_completion ]; then
  96. . /etc/bash_completion
  97. fi
  98. fi
  99. export PATH="$PATH:/sbin:/usr/sbin/:/usr/local/bin/android-studio/bin/:/home/robin/Android/Sdk/platform-tools/:/usr/local/bin/intellij/bin/;/home/robin/.composer/vendor/bin:/home/robin/tools/maven/bin"
  100. reg_ip='([0-9]{1,3}\.){3}[0-9]{1,3}'
  101. reg_mac='([0-9a-f]{2}:){5}[0-9a-f]{2}'
  102. _ps1_exit_status()
  103. {
  104. status=$?
  105. if [ ${status} -ne 0 ]
  106. then
  107. echo "${status} "
  108. fi
  109. }
  110. proj()
  111. {
  112. if [ $# -eq 0 ]
  113. then
  114. cd ~/projets
  115. ls
  116. elif [ $# -ge 1 ]
  117. then
  118. cd ~/projets/*-$1
  119. if [ $# -ge 2 ]
  120. then
  121. cd $2
  122. fi
  123. fi
  124. }
  125. _proj_completion()
  126. {
  127. cur=${COMP_WORDS[COMP_CWORD]}
  128. if [ $COMP_CWORD -eq 1 ]
  129. then
  130. COMPREPLY=($(compgen -W "$(/bin/ls -d ~/projets/* | /usr/bin/env grep -oP "\-\K(.*)")" "$cur"))
  131. elif [ $COMP_CWORD -eq 2 ]
  132. then
  133. p=${COMP_WORDS[COMP_CWORD-1]}
  134. COMPREPLY=($(compgen -W "$(/bin/ls -d ~/projets/*${p}/* | /usr/bin/env grep -oP "\K[^/]+$")" "$cur"))
  135. else
  136. COMPREPLY=()
  137. fi
  138. }
  139. dhcp()
  140. {
  141. if [ $# -eq 0 ]
  142. then
  143. echo "Usage: $0 interface [args]" >&2
  144. else
  145. iface="$1"
  146. shift
  147. sudo ifconfig ${iface} up; sudo dhclient -pf /var/run/dhclient.${iface}.pid ${iface} $@
  148. fi
  149. }
  150. up()
  151. {
  152. if [ $# -eq 0 ]
  153. then
  154. cd ..
  155. else
  156. if echo "$1" | grep -E "[0-9]+" 1>/dev/null 2>/dev/null
  157. then
  158. i=$1
  159. while [ $i -gt 0 ]
  160. do
  161. cd ..
  162. i=$(($i - 1))
  163. done
  164. else
  165. echo "Usage: $0 count" >&2
  166. echo "count: number of directory to up" >&2
  167. fi
  168. fi
  169. }
  170. complete -F _proj_completion proj
  171. export NNTPSERVER=news.epita.fr
  172. . ~/.bash_aliases
  173. . ~/.bash_preexec
  174. . ~/.bash_preexec_hooks