Fish (shell)
fish
|
|
---|---|
the fish shell |
|
Basic data
|
|
developer | Axel Liljencrantz |
Publishing year | 2005 |
Current version |
3.1.2 ( April 29, 2020 ) |
operating system | Unixoid operating systems like FreeBSD and Linux |
programming language | C ++ , C |
category | Shell |
License | GPL version 2 |
German speaking | No |
https://fishshell.com |
On Unixoid operating systems , the Fish Shell (for friendly interactive shell ) is a so-called exotic console: its syntax does not come from the Bourne shell ( bash , ksh , zsh ) or from the C shell ( csh , tcsh). The interesting thing about the Fish-Shell is that a powerful autocomplete makes the job easier; depending on previous entries and the currently mounted drives, it suggests commands, options and directory paths; these can be selected with the tab and arrow keys. Fish also makes work easier by offering help texts and returning understandable error messages. Many useful commands and options can thus be discovered by the user in the console itself.
Syntax and examples
The syntax is similar to a POSIX -compatible shell like bash, but differs in important properties. The fish designers believed that in some ways the POSIX shell was badly designed. For example, you can not change the scope of variables with the POSIX syntax, nor can you define arrays or functions .
# Dieser Befehl weist der Variablen "foo" den Wert "bar" zu.
# fish verzichtet auf '=' als Zuweisungsoperator, da dieser wegen
# seiner Leerraum-Sensitivität häufig falsch benutzt wird; zwei
# Objekte müssen also nicht durch einen Operator getrennt werden.
> set foo bar
> echo $foo
# Der Output des Befehls 'pwd' wird in der Variable 'wd'
# gespeichert. fish verwendet, ungleich bash, nicht ``, da
# es mit '' verwechselt werden kann und ohnehin keine
# Verschachtelung zulässt.
> set wd (pwd)
> echo $wd
# Arrays. 'A' ist ein Array mit fünf Werten:
> set A 3 5 7 9 12
# Ein Segment eines Arrays extrahieren:
> set B $A[1 2]
> echo $B
3 5
# Index eines Arrays – und sogar ein Befehl ('seq 3')
# kann als Index verwendet werden:
> echo $A[(seq 3)]
3 5 7
# B enthält 3 und 5. Mit
> set --erase A[$B]
# wird das dritte und fünfte Element von A entfernt:
> echo $A
3 5 9
# for-Schleife, um jpg-Dateien zu png-Dateien
# umzuwandeln:
> for i in *.jpg
convert $i (basename $i .jpg).png
end
# Eine Funktion definieren:
> function hello
echo "Hello $argv!"
end
# Die Funktion für den späteren Gebrauch abspeichern:
> funcsave hello
# Die Liste der zur Zeit in fish definierten Funktionen ansehen:
> functions -n
# Den Typ eines Objektes abrufen (bei in fish definierten Funktionen wird der Programmcode angezeigt):
> type file
# Aus den installierten Manpages Vorschläge für Optionen generieren:
> fish_update_completions
Web links
Individual evidence
- ↑ Release 3.1.2 . April 29, 2020 (accessed April 30, 2020).
- ↑ a b www.openhub.net .