Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 09/12/2017, à 14:43

rann

[résolu] .bashrc changer une configuration

Bonjour

Je souhaiterais connaître les lignes à commenter et de-commenter pour avoir un "invit de commande" coloré

j'ai essayé avec les lignes PS1 ca ne fonctionne pas

merci


  GNU nano 2.5.3                                                                            Fichier : .bashrc                                                                                                                                                              

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export 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 /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    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
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

 if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 else
   PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
 fi
 unset color_prompt force_color_prompt

#  If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
   PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi


^G Aide          ^O Écrire        ^W Chercher      ^K Couper        ^J Justifier     ^C Pos. cur.     ^Y Page préc.    M-\ Première lignM-W Cherch.suiv. ^^ Marquer       M-} Indenter     M-U Annuler      ^B En arrière    M-Space Mot précé^A Début doc.
^X Quitter       ^R Lire fich.    ^\ Remplacer     ^U Coller        ^T Orthograp.    ^_ Aller lig.    ^V Page suiv.    M-/ Dernière lignM-] Parenthèse coM-^ Copier       M-{ Supprimer l'iM-E Refaire      ^F En avant      ^Space Mot suivan^E Fin

Dernière modification par rann (Le 10/12/2017, à 16:17)

Hors ligne

#2 Le 09/12/2017, à 14:55

MicP

Re : [résolu] .bashrc changer une configuration

Bonjour rann

Dans ton fichier ~/.bashrc
enlève le premier caractère # qui est au début de la ligne suivante :

#force_color_prompt=yes

Dernière modification par MicP (Le 09/12/2017, à 14:57)

Hors ligne

#3 Le 10/12/2017, à 11:12

rann

Re : [résolu] .bashrc changer une configuration

Merci à toi
j'essaie

Hors ligne

#4 Le 10/12/2017, à 11:15

rann

Re : [résolu] .bashrc changer une configuration

Impeccable

je vais abuser
et si je veux changer la couleur de l'invit ?

Hors ligne

#5 Le 10/12/2017, à 15:39

MicP

Re : [résolu] .bashrc changer une configuration

Bonjour rann

rann a écrit :

…si je veux changer la couleur de l'invit ?

C'est dans la variable PS1 de l'interpréteur de commandes bash
qu'est définie l'apparence de l'invite de commande (que l'on appelle aussi : le prompt)

Quelques exemples de couleurs :
1512916728.png

=======
Si tu veux que la couleur que tu as choisie pour ton prompt
soit utilisée dans toutes les nouvelles fenêtres de terminal que tu ouvriras depuis ton compte utilisateur,
dans ton fichier ~/.bashrc il te faudra modifier la ligne :

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

=======
Voir aussi :

man termcap
man console_codes

https://stackoverflow.com/questions/484 … -sequences

Dernière modification par MicP (Le 14/12/2017, à 10:19)

Hors ligne

#6 Le 10/12/2017, à 16:16

rann

Re : [résolu] .bashrc changer une configuration

Un énorme merci

Hors ligne