Skip to content

Instantly share code, notes, and snippets.

@c02y
Last active March 12, 2019 09:08
Show Gist options
  • Save c02y/34595c5b6bf4bfa34b09b1a49bde36fe to your computer and use it in GitHub Desktop.
Save c02y/34595c5b6bf4bfa34b09b1a49bde36fe to your computer and use it in GitHub Desktop.
t in ~/.local/bin/t
#!/bin/bash
t () { # set $SHELL fish if it is not, attach tmux session if exists
if ! hash tmux 2>/dev/null; then
echo tmux is not installed, please install it!
return 1
fi
if [ $(basename $SHELL) != "fish" ]; then
if [ -f ~/anaconda3/bin/fish ]; then
export SHELL=~/anaconda3/bin/fish
elif hash fish 2>/dev/null; then
export SHELL=$(which fish)
else
echo "No fish is installed, using old $SHELL as SHELL!"
fi
fi
# attach a session if it exists, it failed, tmux a new one, if failed, echo message
tmux attach 2>/dev/null || tmux 2>/dev/null || echo "Already inside a tmux session!"
}
t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment