Last active
February 7, 2022 17:40
-
-
Save jaywhy13/4f3c05b15117ad9012a9ffade7789176 to your computer and use it in GitHub Desktop.
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
#!/usr/local/bin/bash | |
############################### FOLDER ICONS ################################### | |
folder="$(pwd)" | |
# Construct the path for the folder icon | |
FOLDER_ICON_PATH="$folder/.icon" | |
if [ -f $FOLDER_ICON_PATH ]; then | |
folder_icon="$(cat $FOLDER_ICON_PATH)" | |
else | |
echo "Could not find an .icon file in $folder, using the default icon ️️️️️️🖥️" | |
folder_icon="🖥️" | |
fi | |
# Strip the path and leave the folder name | |
folder_name="$(basename $folder)" | |
# Construct the session name | |
SESSION="$folder_icon $folder_name" | |
# Attach to Tmux | |
if [ -z "$TMUX" ]; then | |
# We're not inside Tmux | |
echo "Attaching to $SESSION" | |
tmux attach-session -d -t "$SESSION" || tmux new-session -s "$SESSION" | |
else | |
# We're inside Tmux | |
if [ -z "$(tmux ls | grep $SESSION)" ]; then | |
# Create a new dettached session | |
tmux new -s "$SESSION" -d | |
fi | |
# Switch to the session | |
tmux switch-client -t "$SESSION" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment