
でTmux のif-shell
コマンドを使用するとtmux.conf
、macOS および Linux で Tmux をシステムのクリップボードと統合するための以下のコマンドのように、非常に長いコマンドになります。
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\""
複数行にわたってコマンドを記述することは可能ですかtmux.conf
? 複数行にわたって使用しようとしました\
が、機能しません。
答え1
によるとman tmux
:
各コマンドは改行またはセミコロン (;) で終了します。
したがって、コマンドに改行を挿入するわけではないと思われるかもしれません。
ただし、コマンド引数には改行が含まれる場合があり、これを使用してコマンドを複数行にまたがることができます。
' ... \
または" ... \
:
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.
例:
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"
}