logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).


L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT → ODT PDF Export

Ceci est une ancienne révision du document !


Shell fish

  • Objet : Fichiers de configuration pour le shell fish
  • Niveau requis :

Installation

Installation de fish

apt install fish

Utiliser fish par défaut

chsh
 
Changing the login shell for <uersname>
Enter the new value, or press ENTER for the default
	Login Shell: /usr/bin/fish

Configuration

Mes fichiers de configuration:

~/.config/fish/config.fish
eval (dircolors -c ~/.dircolors | sed 's/>&\/dev\/null$//')
 
# vi mode
#fish_vi_key_bindings
function fish_mode_prompt --description "called from fish_right_prompt"
   # do stuff
end
 
# abbr
abbr hist 'history'
abbr vi 'nvim'
abbr ls 'ls --color'
abbr ll 'ls -lh'
abbr llt 'ls -lhrt'
abbr lls 'ls -lhrS'
abbr grep 'grep --binary-files=text'
abbr diff colordiff
abbr grep 'grep --color'
abbr igrep 'grep -i'
abbr netstat 'ss -a'
 
#########################################################
# couleur dans le man
#########################################################
set -gx LESS_TERMCAP_mb \e'[01;31m'  
set -gx LESS_TERMCAP_md \e'[01;31m'  
set -gx LESS_TERMCAP_me \e'[0m'  
set -gx LESS_TERMCAP_se \e'[0m'  
set -gx LESS_TERMCAP_so \e'[01;44;33m'  
set -gx LESS_TERMCAP_ue \e'[0m'  
set -gx LESS_TERMCAP_us \e'[01;32m'

Prompt de gauche: Affiche le mode vi et le path courant

~/.config/fish/functions/fish_prompt.fish
function fish_prompt
  set -l last_status $status
  set_color normal
 
  printf '['
  switch $fish_bind_mode
    case default
      set_color --bold red
      printf 'n'
    case insert
      set_color --bold 215eb1
      printf 'i'
    case visual
      set_color --bold magenta
      printf 'v'
  end
  set_color normal
  printf '] '
 
  set_color 9cc8f9
  printf '%s' (prompt_pwd)
 
  if [ $last_status -eq 0 ]
    set_color -o 215eb1
  else
    set_color -o red
  end
  printf ' > '
  set_color normal
end

Prompt de droite: Affiche la durée d'exécution de la dernière commande et l'heure:

~/.config/fish/functions/fish_right_prompt.fish
function __bobthefish_cmd_duration -S -d 'Show command duration'
  [ "$theme_display_cmd_duration" = "no" ]; and return
  [ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]; and return
 
  if [ "$CMD_DURATION" -lt 5000 ]
    echo -ns $CMD_DURATION 'ms'
  else if [ "$CMD_DURATION" -lt 60000 ]
    __bobthefish_pretty_ms $CMD_DURATION s
  else if [ "$CMD_DURATION" -lt 3600000 ]
    set_color $fish_color_error
    __bobthefish_pretty_ms $CMD_DURATION m
  else
    set_color $fish_color_error
    __bobthefish_pretty_ms $CMD_DURATION h
  end
 
  set_color $fish_color_normal
  set_color $fish_color_autosuggestion
 
  [ "$theme_display_date" = "no" ]
    or echo -ns ' ' $__bobthefish_left_arrow_glyph
end
 
function __bobthefish_pretty_ms -S -a ms interval -d 'Millisecond formatting for humans'
  set -l interval_ms
  set -l scale 1
 
  switch $interval
    case s
      set interval_ms 1000
    case m
      set interval_ms 60000
    case h
      set interval_ms 3600000
      set scale 2
  end
 
  switch $FISH_VERSION
    # Fish 2.3 and lower doesn't know about the -s argument to math.
    case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
      math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
    case \*
      math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
  end
end
 
function fish_right_prompt -d "Write out the right prompt"
    __bobthefish_cmd_duration
    set_color white
    date '+%H:%M:%S'
    set_color normal
end
utilisateurs/yaute/config/shell-fish.1537992773.txt.gz · Dernière modification: 26/09/2018 22:12 par yaute

Pied de page des forums

Propulsé par FluxBB