
Wenn ich den Tmux- if-shell
Befehl in verwende tmux.conf
, erhalte ich wirklich lange Befehle, wie den folgenden zum Integrieren von Tmux in die Zwischenablage des Systems unter macOS und Linux:
if-shell "[[ $(uname -s) = Linux ]]" "bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel \"pbcopy\"" "bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel \"xclip -in -selection clipboard\""
Ist es möglich, Befehle über mehrere Zeilen zu schreiben tmux.conf
? Ich habe versucht, \
mehrere Zeilen zu verwenden, aber es funktioniert nicht.
Antwort1
Entsprechend man tmux
:
Jeder Befehl wird durch eine neue Zeile oder ein Semikolon (;) abgeschlossen.
Daher kann es so aussehen, als ob in einem Befehl keine neue Zeile eingefügt werden soll.
Allerdings können Befehlsargumente Zeilenumbrüche enthalten, die verwendet werden können, um einen Befehl auf mehrere Zeilen auszudehnen:
' ... \
oder " ... \
:
If the last character of a line is \, the line is joined with the following line (the \ and the newline are completely removed).
( { ... }
):
Braces are similar to single quotes in that the text inside is taken literally without any replacements but this also includes line continuation.
Beispiel:
if-shell '[[ $(uname -s) = Linux ]]' {
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
} {
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
}