0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fishでtmuxの空いてるセッションにアタッチする

Posted at

これがしたいんだけど、fish scriptがアレすぎて「bash script to fish script」とかでググり続けた結果…。

fishermanから
https://github.com/fisherman/fisherman

bass入れて
fisher edc/bass

vim ~/.config/fish/functions/tmux.bash.sh

tmux.bash.sh
if [[ ! -n $TMUX && $- == *l* ]]; then
  # get the IDs
  ID="`tmux list-sessions`"
  if [[ -z "$ID" ]]; then
    tmux new-session
  fi
  create_new_session="Create New Session"
  ID="$ID\n${create_new_session}:"
  ID="`echo $ID | $PERCOL | cut -d: -f1`"
  if [[ "$ID" = "${create_new_session}" ]]; then
    tmux new-session
  elif [[ -n "$ID" ]]; then
    tmux attach-session -t "$ID"
  else
    :  # Start terminal normally
  fi
fi

という感じでそのままコピペして…

chmod 755 ~/.config/fish/functions/tmux.bash.sh

権限あげたら

vim ~/.config/fish/config.fish

config.fish
bass ~/.config/fish/functions/tmux.bash.sh

source ~/.config/fish/config.fish

動いた。

教訓

fishで動かないものはbassにsh投げろ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?