Skip to content

Instantly share code, notes, and snippets.

@jaywhy13
Last active February 7, 2022 17:40
Show Gist options
  • Save jaywhy13/4f3c05b15117ad9012a9ffade7789176 to your computer and use it in GitHub Desktop.
Save jaywhy13/4f3c05b15117ad9012a9ffade7789176 to your computer and use it in GitHub Desktop.
#!/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