fish & zsh

komfortable shells

und fizsh

Inhalt des Vortrags

  • Übersicht über

    • Features,
    • Ökosysteme rund um die Shells
  • Viele Beispiele

Nicht enthalten

  • Skripting (bash ist überall)

  • Auflistung aller Optionen und Funktionen

    → Read The Fine Manual!

  • PowerShell

Fragen

  • Was könnt, kennt und wollt ihr?

Vorbereitung

  • fish, fizsh, zsh (und git) installieren

  • Tipps:

    • Aliase & Funktionen in eigene Dateien auslagern

    • Default Shell ändern:

      chsh /bin/zsh

    • Wenn tmux als Shell:

      set-option -g default-shell /bin/zsh

Für wen ist fish?

  • komfortabel ohne Konfigurationsarbeit

  • einfach & schnell (RapberryPi, Netbooks etc.)

  • ausführliche und einfach verständliche Dokumentation

  • Mit Webinterface für Konfiguration

Für wen ist zsh?

  • vergleichbar langsam (abhängig von Config)
  • EXTREM!!! mächtig
  • großes Ökosystem
    • viele Anleitungen,
    • Themes,
    • Plugins
    • Frameworks

Für wen ist fizsh?

  • Keine Einrichtung
  • Vorteile von fish
  • ohne Nachteile von fish
  • Kompatibel mit zsh (und somit bash)
  • Keine Webkonfiguration

fish!

fish - friendly interactive shell

  • seit 2005

  • einfach und schnell

  • Syntax ist "exotisch" und teils nicht kompatibel

fish Features - Tab-Completion

  • Erweiterte Tabcompletion (interaktiv)

    cd

    cd ↹↹

  • Syntax highlighting & Fehlerüberprüfung

    mkdir → blau (Befehl existiert)

    asdkljfhas → rot (inexistent)

  • Completion parsed by installed manpages

    rsync -

    (fish_update_completions)

fish Features

  • Unterstützung für 256 Farben

  • valide Pfade werden unterstrichen

  • Multiple Wildcards & rekursive Wildcards

  • Web-basierte Konfiguration und Hilfe

  • Vorschläge von häufig benutzen Pfaden

    und Optionen

Fish Hilfe
help
fish_config
Fish Einstellungen

fish's Eigenheiten

  • keine ~/.fishrc Datei sondern ~/.config/fish/*

  • Es gibt nur functions keine Aliase

    • Kompatibililäts-Funktion für alias Syntax vorhanden
  • $PS1 ist function fish_prompt

  • Umleiten von sdterr wird anders notiert:

    (bash)$ command 2> file

    (fish)> command ^ file

  • Exit-Status ($?) ist $status

  • and anstelle von && und or anstatt ||

Zsh – Last word in shells

  • seit 1990
  • Bash kompatibel (sowie csh, ksh, sh und zsh)

zsh Features - Tab-Completion

  • Erweiterte Tabcompletion (wie bei fish)

  • Tabcompletion für viele populäre Programme

    git↹↹, git c

    kill

  • Pfad Erweiterung

    /u/sh/ico↹ und /u/l/g

  • Pfad Ersetzung

    cd /usr/local/bin dann cd bin share

  • Pfadwechsel ohne cd

Weitere Features

  • Globale Aliase: alias -g

    können überall in einem Befehl genutzt werden

  • Suffix Aliase: alias -s tex=gummi

    Öffnet TeX-Dateien mit Gummi.

  • Alt+q um einen Befehl dazwischen zu schieben

zsh Prompt

  • Rechter Prompt $RPS1

  • $PS2 hat Kontext!

  • git

  • Exit codes

  • Magisches Zeug

  • Mehrzeilig!

  • Infos:

    man zshmisc und im User Guide Kapitel 2.5.6

zsh Konfiguration

  • Konfigurationsdatei: ~/.zshrc

  • Wizard beim ersten Aufruf:

Beispiel zshrc

    HISTFILE=~/.zsh_history
    HISTSIZE=3000
    SAVEHIST=3000

    # prompt
    autoload -U promptinit
    promptinit
    prompt adam2

    alias rload="source ~/lug/zshrc"

    setopt append_history autocd extendedglob notify 
    setopt multios              # Enable piping to multiple outputs
    setopt interactivecomments  # Enable comments in interactive mode

    # Keybindings
    bindkey -v 
    bindkey '^U' backward-kill-line

    # Completion, expansion and globbing
    setopt automenu
    setopt autolist
    setopt complete_in_word
    setopt always_to_end
    setopt menucomplete
    setopt listpacked
    setopt globdots
    setopt extendedglob
    setopt markdirs

    zstyle ':completion:*' auto-description 'specify: %d'
    zstyle ':completion:*' completer _expand _complete _correct _approximate
    zstyle ':completion:*' format 'Completing %d'
    zstyle ':completion:*' group-name ''
    zstyle ':completion:*' menu select=2
    eval "$(dircolors -b)"
    zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
    zstyle ':completion:*' list-colors ''
    zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to
    zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|
    zstyle ':completion:*' menu select=long
    zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%
    zstyle ':completion:*' use-compctl false
    zstyle ':completion:*' verbose true

    zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
    zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

Optionen, Optionen, Optionen!

  • man zshoptions

  • Aktivieren: setopt OPTION

  • Deaktivieren: unsetopt OPTION

    oder setopt NO_OPTION

  • Schreibtweise fast egal:

    • beep
    • BEEP
    • BEep
    • nobeep
    • n__oBeE__P

Interessante Optionen

  • *BASH*, *CSH*, *KSH* und *SH* für Kompatibilität

  • AUTO_CD

  • CORRECT und CORRECT_ALL

  • RM_STAR_SILENT und RM_STAR_WAIT

  • TRANSIENT_RPROMPT

  • MULTIOS

HISTORY OPTIONEN

  • APPEND_HISTORY

    hängt Session nach beenden an HISTFILE

  • INC_APPEND_HISTORY

    incrementelles hinzufügen

  • SHARE_HISTORY

    alle Sitzung haben EINE history

  • EXTENDED_HISTORY

    fügt Startzeit und Dauer hinzu

History Deduplikation

  • HIST_IGNORE_ALL_DUPS

    Duplikate werden aus der history gelöscht

  • HIST_SAVE_NO_DUPS

    Duplikate werden nicht gespeichert

  • HIST_REDUCE_BLANKS

    dopppelte Leerzeichen entfernen

  • HIST_EXPIRE_DUPS_FIRST

    löscht Duplikate zuerst

Weitere History Optionen

  • HIST_NO_STORE

    history und fc Aufrufe werden ignoriert

  • NO_HIST_BEEP

    Kein Beep wenn Element inexistent

oh-my-zsh Community Framework

oh-my-zsh

  • Themes

  • Plugins mit support für

    • Distributionen (Arch, Debian, …)

    • Versionsverwaltungen (git, mercurial, …)

    • Paketmanager (pip, npm, …)

    • Programmiersprachen, Entwicklungsumgebung

      und vieles mehr

  • Eigene Änderungen sollten nach

    ~/.oh-my-zsh/custom/*.zsh

Bequem nach Themes stöbern

oh-my-zsh konfiguration

  • Webseite: http://ohmyz.sh/

  • Installer-Skript herunterladen und ausführen

    oder manuell die Schritte des Skripts ausführen.

  • ~/.zshrc in Editor öffnen und anpassen

Andere Frameworks für zsh

erstellt mit

Moritz Fiedler
2014/2015
CC-BY-SA 4.0

ZSH erweitern

  • Powerline Support:

    . ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh

HELP!

Manpages:

    zsh          zshcompctl   zshmisc      zshtcpsys  
    zsh5         zshcompsys   zshmodules   zshzftpsys 
    zshall       zshcompwid   zshoptions   zshzle     
    zshbuiltins  zshcontrib   zshparam    
    zshcalsys    zshexpn      zshroadmap