Outils pour utilisateurs

Outils du site


linux:installation:bashrc

Table des matières

Pour changer les infos du PS1 plus facilement : https://bashrcgenerator.com

Mon fichier bashrc

Mon fichier bashrc

bashrc.txt
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2.  
  3. # Note: PS1 and umask are already set in /etc/profile. You should not
  4. # need this unless you want different defaults for root.
  5. # PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
  6. # umask 022
  7.  
  8.  
  9.  
  10.  
  11.  
  12. # set a fancy prompt (non-color, unless we know we "want" color)
  13. case "$TERM" in
  14. xterm-color|*-256color) color_prompt=yes;;
  15. esac
  16.  
  17. # uncomment for a colored prompt, if the terminal has the capability; turned
  18. # off by default to not distract the user: the focus in a terminal window
  19. # should be on the output of commands, not on the prompt
  20. #force_color_prompt=yes
  21.  
  22. if [ -n "$force_color_prompt" ]; then
  23. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  24. # We have color support; assume it's compliant with Ecma-48
  25. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  26. # a case would tend to support setf rather than setaf.)
  27. color_prompt=yes
  28. else
  29. color_prompt=
  30. fi
  31. fi
  32.  
  33. if [ "$color_prompt" = yes ]; then
  34. PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;11m\]\@\[$(tput sgr0)\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  35. else
  36. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  37. fi
  38. unset color_prompt force_color_prompt
  39.  
  40. # If this is an xterm set the title to user@host:dir
  41. case "$TERM" in
  42. xterm*|rxvt*)
  43. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  44. ;;
  45. *)
  46. ;;
  47. esac
  48.  
  49. # enable color support of ls and also add handy aliases
  50. if [ -x /usr/bin/dircolors ]; then
  51. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  52. alias ls='ls --color=auto'
  53. #alias dir='dir --color=auto'
  54. #alias vdir='vdir --color=auto'
  55.  
  56. #alias grep='grep --color=auto'
  57. #alias fgrep='fgrep --color=auto'
  58. #alias egrep='egrep --color=auto'
  59. fi
  60.  
  61. # colored GCC warnings and errors
  62. #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. # You may uncomment the following lines if you want `ls' to be colorized:
  75. # export LS_OPTIONS='--color=auto'
  76. # eval "`dircolors`"
  77. # alias ls='ls $LS_OPTIONS'
  78. # alias ll='ls $LS_OPTIONS -l'
  79. # alias l='ls $LS_OPTIONS -lA'
  80. #
  81. # Some more alias to avoid making mistakes:
  82. # alias rm='rm -i'
  83. # alias cp='cp -i'
  84. # alias mv='mv -i'
  85.  
  86.  
  87. # ~/.bashrc: executed by bash(1) for non-login shells.
  88.  
  89.  
  90.  
  91. export PS1='\h:\w\$ '
  92.  
  93. umask 022
  94.  
  95.  
  96.  
  97. # You may uncomment the following lines if you want `ls' to be colorized:
  98.  
  99. # export LS_OPTIONS='--color=auto'
  100.  
  101. # eval "`dircolors`"
  102.  
  103. # alias ls='ls $LS_OPTIONS'
  104.  
  105. # alias ll='ls $LS_OPTIONS -l'
  106.  
  107. # alias l='ls $LS_OPTIONS -lA'
  108.  
  109. #
  110.  
  111.  
  112.  
  113.  
  114.  
  115. # Some more alias to avoid making mistakes:
  116.  
  117. # alias rm='rm -i'
  118.  
  119. # alias cp='cp -i'
  120.  
  121. # alias mv='mv -i'
  122.  
  123.  
  124.  
  125.  
  126.  
  127. alias maj='apt-get update && apt-get dist-upgrade'
  128.  
  129. alias agi='apt-get install'
  130.  
  131. alias watchftp='watch -n 1 "ps ax | grep vsftpd | grep -v grep"'
  132.  
  133. alias bigrestart='/etc/init.d/svnserve restart && /etc/init.d/apache2 restart'
  134.  
  135.  
  136.  
  137. # Calendrier du mois avec le jour en cours en rouge:
  138.  
  139. #alias cal='var=$(/usr/bin/cal -m); echo "${var/$(date +%-d)/$(echo -e "\033[1;31m$(date +%-d)\033[0m")}"'
  140.  
  141.  
  142.  
  143. #Les classiques
  144.  
  145. alias ll='ls -l -h'
  146.  
  147. alias la='ls -A -h'
  148.  
  149. alias l='ls -CF -h'
  150.  
  151. alias lla='ls -la -h'
  152.  
  153.  
  154.  
  155. #Classe par date
  156.  
  157. alias lldate='ls -l -t -h'
  158.  
  159.  
  160.  
  161. #classe par date (inversé)
  162.  
  163. #permet d'avoir le plus recent fichier/dossier sous les yeux
  164.  
  165. alias llrecent='ls -l -tr -h'
  166.  
  167.  
  168.  
  169. #Avoir seulement les repertoires
  170.  
  171. alias llrep='ls -l -d */ -h'
  172.  
  173.  
  174.  
  175. #Repertoires les plus recents
  176.  
  177. alias llrecentrep='ls -l -d */ -tr -h'
  178.  
  179. #Avoir seulement les fichiers/dossiers caches
  180.  
  181. alias llcache='ls -li -A -h --ignore=^"[^\.]"'
  182.  
  183.  
  184.  
  185. #Parce qu'on aime bien voir ce qu'il se passe
  186.  
  187. alias rm='rm --verbose'
  188.  
  189. alias mv='mv --verbose'
  190.  
  191. alias cp='cp --verbose'
  192.  
  193.  
  194.  
  195. #Surligne les patterns retrouvés
  196.  
  197. alias grep='grep -i --color'
  198.  
  199.  
  200.  
  201. #Surligne les patterns retrouvés
  202.  
  203. alias zgrep='zgrep -i --color'
  204.  
  205.  
  206.  
  207.  
  208. #Ligne de separation visuelle
  209.  
  210. alias mark='echo ================================================'
  211.  
  212.  
  213.  
  214. # Arborescence
  215.  
  216. alias tree="find . | sed 's/[^/]*\//| /g;s/| *\([^| ]\)/+--- \1/'"
  217.  
  218.  
  219.  
  220. #Cree le repertoire et va dedans
  221.  
  222. function mkcd() {
  223.  
  224. mkdir $1 && cd $1
  225.  
  226. }
  227.  
  228.  
  229.  
  230. # repeat n times command
  231.  
  232. function repeat()
  233.  
  234. {
  235.  
  236. local i max
  237.  
  238. max=$1; shift;
  239.  
  240. for ((i=1; i <= max ; i++)); do
  241.  
  242. eval "$@";
  243.  
  244. done
  245.  
  246. }
  247.  
  248.  
  249.  
  250. # Comment in the above and uncomment this below for a color prompt
  251.  
  252. PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;11m\]\A\[$(tput sgr0)\] \[$(tput bold)\]\[\033[38;5;46m\]\u\[$(tput sgr0)\]\[\033[38;5;28m\]@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  253.  
  254.  
  255.  
  256.  
  257. #Lors du login
  258.  
  259. echo "==================================="
  260.  
  261. echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` H `date +"%M"`
  262.  
  263. echo "==================================="
  264.  
  265.  
  266. # Une ligne en bash ( affiche un alias au hasard )
  267.  
  268. alias alr='let "n= $RANDOM % `alias | wc -l` + 1" && alias | sed -n "$n"p'
  269.  
  270.  
  271.  
  272. # Une autre : cmd [-n] ( les n commandes les plus utilisées, en ne tenant pas compte du sudo )
  273.  
  274. function cmd {
  275.  
  276. history | sed -e 's/sudo //' | cut -b8- | cut -d' ' -f1 | sort | uniq -c | sort -rg | head $1
  277.  
  278. }

Fichier d’origine

Fichier d’origine

bashrc_origine.txt
  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. [ -z "$PS1" ] && return
  7.  
  8. # don't put duplicate lines in the history. See bash(1) for more options
  9. # don't overwrite GNU Midnight Commander's setting of `ignorespace'.
  10. HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
  11. # ... or force ignoredups and ignorespace
  12. HISTCONTROL=ignoreboth
  13.  
  14. # append to the history file, don't overwrite it
  15. shopt -s histappend
  16.  
  17. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  18.  
  19. # check the window size after each command and, if necessary,
  20. # update the values of LINES and COLUMNS.
  21. shopt -s checkwinsize
  22.  
  23. # make less more friendly for non-text input files, see lesspipe(1)
  24. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  25.  
  26. # set variable identifying the chroot you work in (used in the prompt below)
  27. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  28. debian_chroot=$(cat /etc/debian_chroot)
  29. fi
  30.  
  31. # set a fancy prompt (non-color, unless we know we "want" color)
  32. case "$TERM" in
  33. xterm-color) color_prompt=yes;;
  34. esac
  35.  
  36. # uncomment for a colored prompt, if the terminal has the capability; turned
  37. # off by default to not distract the user: the focus in a terminal window
  38. # should be on the output of commands, not on the prompt
  39. #force_color_prompt=yes
  40.  
  41. if [ -n "$force_color_prompt" ]; then
  42. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  43. # We have color support; assume it's compliant with Ecma-48
  44. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  45. # a case would tend to support setf rather than setaf.)
  46. color_prompt=yes
  47. else
  48. color_prompt=
  49. fi
  50. fi
  51.  
  52. if [ "$color_prompt" = yes ]; then
  53. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  54. else
  55. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  56. fi
  57. unset color_prompt force_color_prompt
  58.  
  59. # If this is an xterm set the title to user@host:dir
  60. case "$TERM" in
  61. xterm*|rxvt*)
  62. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  63. ;;
  64. *)
  65. ;;
  66. esac
  67.  
  68. # enable color support of ls and also add handy aliases
  69. if [ -x /usr/bin/dircolors ]; then
  70. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  71. alias ls='ls --color=auto'
  72. #alias dir='dir --color=auto'
  73. #alias vdir='vdir --color=auto'
  74.  
  75. #alias grep='grep --color=auto'
  76. #alias fgrep='fgrep --color=auto'
  77. #alias egrep='egrep --color=auto'
  78. fi
  79.  
  80. # some more ls aliases
  81. #alias ll='ls -l'
  82. #alias la='ls -A'
  83. #alias l='ls -CF'
  84.  
  85. # Alias definitions.
  86. # You may want to put all your additions into a separate file like
  87. # ~/.bash_aliases, instead of adding them here directly.
  88. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  89.  
  90. if [ -f ~/.bash_aliases ]; then
  91. . ~/.bash_aliases
  92. fi
  93.  
  94. # enable programmable completion features (you don't need to enable
  95. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  96. # sources /etc/bash.bashrc).
  97. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  98. . /etc/bash_completion
  99. fi
linux/installation/bashrc.txt · Dernière modification : 2022/11/04 13:13 de tutospisto