Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kadaliao/ece9d053f7dc6989452fb5fb93cab40b to your computer and use it in GitHub Desktop.
Save kadaliao/ece9d053f7dc6989452fb5fb93cab40b 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