Skip to content

Commit

Permalink
fix(workspace): fix attaching to the same initialized workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
tiborpilz committed Dec 31, 2024
1 parent 7316130 commit 38e80cf
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions home/scripts/switchorspawn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ project_dirs() {
# export TMUX_FZF_ORDER="session|window|keybinding|clipboard"

export FZF_DEFAULT_OPTS='--color=bg+:#D9D9D9,bg:#E1E1E1,border:#C8C8C8,spinner:#719899,hl:#719872,fg:#616161,header:#719872,info:#727100,pointer:#E12672,marker:#E17899,fg+:#616161,preview-bg:#D9D9D9,prompt:#0099BD,hl+:#719899'


#
### Nord
export FZF_DEFAULT_OPTS='--color=bg+:#3B4252,bg:#2E3440,spinner:#81A1C1,hl:#616E88,fg:#D8DEE9,header:#616E88,info:#81A1C1,pointer:#81A1C1,marker:#81A1C1,fg+:#D8DEE9,prompt:#81A1C1,hl+:#81A1C1'
# export TMUX_FZF_PREVIEW=0
# export TMUX_FZF_PREVIEW_FOLLOW=0

Expand All @@ -36,28 +41,28 @@ else
selected=$PROJECTS_DIR/$(project_dirs | fzf --tmux 70%,70% --highlight-line --no-scrollbar --inline-info --pointer="" --border "horizontal" --ansi --query "$query" --preview "if [ -f \"${PROJECTS_DIR}\"/{}/README.md ]; then CLICOLOR_FORCE=0 COLORTERM=truecolor glow \"${PROJECTS_DIR}\"/{}/README.md --style=light; else ls \"${PROJECTS_DIR}\"/{}; fi")
fi

# if [[ -z $selected ]]; then
# exit 0
# fi
if [[ -z $selected ]]; then
exit 0
fi

# selected_name=$(basename "$selected" | tr . _)
selected_name=$(basename "$selected" | tr . _)

# # Check if the selected project is in the smug list
# if echo "$smug_projects" | grep -q "^$selected_name$"; then
# # If it's a smug project, start it with smug
# smug start "$selected_name" --attach
# else
# # If it's not a smug project, use the original tmux logic
# tmux_running=$(pgrep tmux)
# Check if the selected project is in the smug list
if echo "$smug_projects" | grep -q "^$selected_name$"; then
# If it's a smug project, start it with smug
smug start "$selected_name" --attach
else
# If it's not a smug project, use the original tmux logic
tmux_running=$(pgrep tmux)

# if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
# tmux new-session -s "$selected_name" -c $selected
# exit 0
# fi
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s "$selected_name" -c "$selected"
exit 0
fi

# if ! tmux has-session -t="$selected_name" 2>/dev/null; then
# tmux new-session -ds "$selected_name" -c "$selected"
# fi
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
tmux new-session -ds "$selected_name" -c "$selected"
fi

# tmux switch-client -t "$selected_name"
# fikjjkBBBB
tmux switch-client -t "$selected_name"
fi

0 comments on commit 38e80cf

Please sign in to comment.