Skip to content

Instantly share code, notes, and snippets.

@c02y
Created March 12, 2019 09:09
Show Gist options
  • Save c02y/cdbfbe42656fbaf6457c9a67c4598ead to your computer and use it in GitHub Desktop.
Save c02y/cdbfbe42656fbaf6457c9a67c4598ead to your computer and use it in GitHub Desktop.
config.fish
function t -d 'if tmux is running, attach it, if not, create a new tmux session, and check $SHELL'
if not command -sq tmux
echo tmux is not installed, please install it!
return 1
end
if test (basename $SHELL) = "bash"
if test -f ~/anaconda3/bin/fish
set -gx SHELL ~/anaconda3/bin/fish
else if command -sq fish
set -gx SHELL (which fish)
else
echo "No fish is installed, using old $SHELL as SHELL!"
end
end
# attach a session if it exists, it failed, tmux a new one, if failed, echo message
tmux attach ^/dev/null; or tmux ^/dev/null; or echo "Already inside a tmux session, $SHELL!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment