Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
linux:installation:bashrc [2022/09/03 12:57] – créée tutospisto | linux:installation:bashrc [2022/11/04 13:13] (Version actuelle) – tutospisto | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Mon fichier bashrc ====== | + | Pour changer les infos du PS1 plus facilement : [[https:// |
+ | <hidden ====== Mon fichier bashrc ======> | ||
- | <code bash yeah.sh [enable_line_numbers=1, | + | |
+ | <code bash bashrc.txt[enable_line_numbers=1, | ||
+ | |||
+ | # ~/.bashrc: executed by bash(1) for non-login shells. | ||
# Note: PS1 and umask are already set in / | # Note: PS1 and umask are already set in / | ||
Ligne 8: | Ligne 12: | ||
# PS1=' | # PS1=' | ||
# umask 022 | # umask 022 | ||
+ | |||
+ | |||
+ | |||
Ligne 32: | Ligne 39: | ||
if [ " | if [ " | ||
- | PS1=' | + | PS1=' |
else | else | ||
PS1=' | PS1=' | ||
Ligne 53: | Ligne 60: | ||
#alias dir=' | #alias dir=' | ||
#alias vdir=' | #alias vdir=' | ||
+ | |||
#alias grep=' | #alias grep=' | ||
#alias fgrep=' | #alias fgrep=' | ||
Ligne 60: | Ligne 68: | ||
# colored GCC warnings and errors | # colored GCC warnings and errors | ||
#export GCC_COLORS=' | #export GCC_COLORS=' | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Ligne 73: | Ligne 90: | ||
# alias cp='cp -i' | # alias cp='cp -i' | ||
# alias mv='mv -i' | # alias mv='mv -i' | ||
+ | |||
# ~/.bashrc: executed by bash(1) for non-login shells. | # ~/.bashrc: executed by bash(1) for non-login shells. | ||
+ | |||
+ | |||
export PS1=' | export PS1=' | ||
+ | |||
umask 022 | umask 022 | ||
+ | |||
+ | |||
# You may uncomment the following lines if you want `ls' to be colorized: | # You may uncomment the following lines if you want `ls' to be colorized: | ||
+ | |||
# export LS_OPTIONS=' | # export LS_OPTIONS=' | ||
+ | |||
# eval " | # eval " | ||
+ | |||
# alias ls='ls $LS_OPTIONS' | # alias ls='ls $LS_OPTIONS' | ||
+ | |||
# alias ll='ls $LS_OPTIONS -l' | # alias ll='ls $LS_OPTIONS -l' | ||
+ | |||
# alias l='ls $LS_OPTIONS -lA' | # alias l='ls $LS_OPTIONS -lA' | ||
+ | |||
+ | # | ||
+ | |||
+ | |||
+ | |||
+ | |||
# Some more alias to avoid making mistakes: | # Some more alias to avoid making mistakes: | ||
+ | |||
# alias rm='rm -i' | # alias rm='rm -i' | ||
+ | |||
# alias cp='cp -i' | # alias cp='cp -i' | ||
+ | |||
# alias mv='mv -i' | # alias mv='mv -i' | ||
- | | + | |
+ | |||
+ | |||
+ | |||
+ | | ||
alias agi=' | alias agi=' | ||
+ | |||
alias watchftp=' | alias watchftp=' | ||
- | | + | |
+ | | ||
+ | |||
# Calendrier du mois avec le jour en cours en rouge: | # Calendrier du mois avec le jour en cours en rouge: | ||
- | | + | |
+ | #alias cal=' | ||
+ | |||
#Les classiques | #Les classiques | ||
+ | |||
alias ll='ls -l -h' | alias ll='ls -l -h' | ||
+ | |||
alias la='ls -A -h' | alias la='ls -A -h' | ||
+ | |||
alias l='ls -CF -h' | alias l='ls -CF -h' | ||
+ | |||
alias lla=' | alias lla=' | ||
+ | |||
+ | |||
#Classe par date | #Classe par date | ||
+ | |||
alias lldate=' | alias lldate=' | ||
+ | |||
+ | |||
#classe par date (inversé) | #classe par date (inversé) | ||
+ | |||
#permet d' | #permet d' | ||
+ | |||
alias llrecent=' | alias llrecent=' | ||
+ | |||
+ | |||
#Avoir seulement les repertoires | #Avoir seulement les repertoires | ||
+ | |||
alias llrep=' | alias llrep=' | ||
+ | |||
+ | |||
# | # | ||
+ | |||
alias llrecentrep=' | alias llrecentrep=' | ||
#Avoir seulement les fichiers/ | #Avoir seulement les fichiers/ | ||
+ | |||
alias llcache=' | alias llcache=' | ||
+ | |||
+ | |||
#Parce qu'on aime bien voir ce qu'il se passe | #Parce qu'on aime bien voir ce qu'il se passe | ||
+ | |||
alias rm='rm --verbose' | alias rm='rm --verbose' | ||
+ | |||
alias mv='mv --verbose' | alias mv='mv --verbose' | ||
+ | |||
alias cp='cp --verbose' | alias cp='cp --verbose' | ||
+ | |||
+ | |||
#Surligne les patterns retrouvés | #Surligne les patterns retrouvés | ||
+ | |||
alias grep=' | alias grep=' | ||
+ | |||
+ | |||
#Surligne les patterns retrouvés | #Surligne les patterns retrouvés | ||
+ | |||
alias zgrep=' | alias zgrep=' | ||
+ | |||
+ | |||
+ | |||
#Ligne de separation visuelle | #Ligne de separation visuelle | ||
+ | |||
alias mark=' | alias mark=' | ||
+ | |||
+ | |||
# Arborescence | # Arborescence | ||
+ | |||
alias tree=" | alias tree=" | ||
+ | |||
+ | |||
#Cree le repertoire et va dedans | #Cree le repertoire et va dedans | ||
+ | |||
function mkcd() { | function mkcd() { | ||
- | | + | |
+ | | ||
} | } | ||
+ | |||
+ | |||
# repeat n times command | # repeat n times command | ||
+ | |||
function repeat() | function repeat() | ||
+ | |||
{ | { | ||
+ | |||
local i max | local i max | ||
+ | |||
max=$1; shift; | max=$1; shift; | ||
+ | |||
for ((i=1; i <= max ; i++)); do | for ((i=1; i <= max ; i++)); do | ||
+ | |||
eval " | eval " | ||
+ | |||
done | done | ||
+ | |||
} | } | ||
+ | |||
+ | |||
# Comment in the above and uncomment this below for a color prompt | # Comment in the above and uncomment this below for a color prompt | ||
- | | + | |
+ | | ||
+ | |||
+ | |||
#Lors du login | #Lors du login | ||
+ | |||
echo " | echo " | ||
+ | |||
echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +" | echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +" | ||
+ | |||
echo " | echo " | ||
+ | |||
# Une ligne en bash ( affiche un alias au hasard ) | # Une ligne en bash ( affiche un alias au hasard ) | ||
+ | |||
alias alr=' | alias alr=' | ||
+ | |||
+ | |||
# Une autre : cmd [-n] ( les n commandes les plus utilisées, en ne tenant pas compte du sudo ) | # Une autre : cmd [-n] ( les n commandes les plus utilisées, en ne tenant pas compte du sudo ) | ||
+ | |||
function cmd { | function cmd { | ||
+ | |||
history | sed -e ' | history | sed -e ' | ||
- | | + | |
- | + | | |
- | + | </ | |
- | ====== Fichier d’origine ====== | + | |
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | <code bash bashrc_origine.txt [enable_line_numbers=1, | ||
+ | # ~/.bashrc: executed by bash(1) for non-login shells. | ||
+ | # see / | ||
+ | # for examples | ||
+ | |||
+ | # If not running interactively, | ||
+ | [ -z " | ||
+ | |||
+ | # don't put duplicate lines in the history. See bash(1) for more options | ||
+ | # don't overwrite GNU Midnight Commander' | ||
+ | HISTCONTROL=$HISTCONTROL${HISTCONTROL+: | ||
+ | # ... or force ignoredups and ignorespace | ||
+ | HISTCONTROL=ignoreboth | ||
+ | |||
+ | # append to the history file, don't overwrite it | ||
+ | shopt -s histappend | ||
+ | |||
+ | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | ||
+ | |||
+ | # check the window size after each command and, if necessary, | ||
+ | # update the values of LINES and COLUMNS. | ||
+ | shopt -s checkwinsize | ||
+ | |||
+ | # make less more friendly for non-text input files, see lesspipe(1) | ||
+ | #[ -x / | ||
+ | |||
+ | # set variable identifying the chroot you work in (used in the prompt below) | ||
+ | if [ -z " | ||
+ | debian_chroot=$(cat / | ||
+ | fi | ||
+ | |||
+ | # set a fancy prompt (non-color, unless we know we " | ||
+ | case " | ||
+ | xterm-color) color_prompt=yes;; | ||
+ | esac | ||
+ | |||
+ | # uncomment for a colored prompt, if the terminal has the capability; turned | ||
+ | # off by default to not distract the user: the focus in a terminal window | ||
+ | # should be on the output of commands, not on the prompt | ||
+ | # | ||
+ | |||
+ | if [ -n " | ||
+ | if [ -x / | ||
+ | # We have color support; assume it's compliant with Ecma-48 | ||
+ | # (ISO/ | ||
+ | # a case would tend to support setf rather than setaf.) | ||
+ | color_prompt=yes | ||
+ | else | ||
+ | color_prompt= | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | PS1=' | ||
+ | else | ||
+ | PS1=' | ||
+ | fi | ||
+ | unset color_prompt force_color_prompt | ||
+ | |||
+ | # If this is an xterm set the title to user@host: | ||
+ | case " | ||
+ | xterm*|rxvt*) | ||
+ | PS1=" | ||
+ | ;; | ||
+ | *) | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | # enable color support of ls and also add handy aliases | ||
+ | if [ -x / | ||
+ | test -r ~/ | ||
+ | alias ls='ls --color=auto' | ||
+ | #alias dir=' | ||
+ | #alias vdir=' | ||
+ | |||
+ | #alias grep=' | ||
+ | #alias fgrep=' | ||
+ | #alias egrep=' | ||
+ | fi | ||
+ | |||
+ | # some more ls aliases | ||
+ | #alias ll='ls -l' | ||
+ | #alias la='ls -A' | ||
+ | #alias l='ls -CF' | ||
+ | |||
+ | # Alias definitions. | ||
+ | # You may want to put all your additions into a separate file like | ||
+ | # ~/ | ||
+ | # See / | ||
+ | |||
+ | if [ -f ~/ | ||
+ | . ~/ | ||
+ | fi | ||
+ | |||
+ | # enable programmable completion features (you don't need to enable | ||
+ | # this, if it's already enabled in / | ||
+ | # sources / | ||
+ | if [ -f / | ||
+ | . / | ||
+ | fi | ||
+ | </ | ||
+ | </ | ||