tmux起動時のコマンド入力を自動化ほか
Posted in tech with tags tech tmux -tmux起動してから毎回行う定形のコマンドをスクリプト化する
tmux-devというコマンドを作成する
tmuxの中にいればメッセージ出力、
すでにtmuxが起動されていればattach、
何も起動されていない時、設定ファイルを読み込んでtmux起動。
#!/bin/bash
if [ -z $TMUX ]; then
if $(tmux has-session 2> /dev/null); then
tmux -2 attach
else
tmux -2 new-session \; source-file ~/dotfiles/tmux-dev-hugo
fi
else
echo ' *** you already in tmux *** '
fi
tmuxのsource-file
hugo -w -D (ドラフトも含めて更新を監視、更新時にファイルをリビルド)のコマンドを実行するwindowを作成
そのあと、メインのwindowに戻って入力待ち状態に
# start hugo with watch mode
new-window -n hugo
send-keys -t hugo 'cd ~/hugo && hugo -w -D' C-m
select-window -t 0