-
-
Save c02y/34595c5b6bf4bfa34b09b1a49bde36fe to your computer and use it in GitHub Desktop.
t in ~/.local/bin/t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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