feat(tmux): script to change from notes to last session

This commit is contained in:
Sergio Laín 2025-06-11 00:06:50 +02:00
parent dd3c3efa54
commit 5643ec6b12
No known key found for this signature in database
GPG key ID: 51BB28D8B42FB438
3 changed files with 20 additions and 5 deletions

View file

@ -61,5 +61,5 @@ bind -r ">" swap-window -d -t +1
# Projects
bind-key Enter popup -E -h 80% -w 80% "dev"
# Notes Session
bind-key n run "tmux switch-client -t 'notes-tasks'"
# Switch from Notes/Tasks Session with last session
bind-key n run "tmux-notes-switch"

View file

@ -19,14 +19,14 @@ yaml_config() {
tmuxp_load() {
launch_docs
if [[ -n "$TMUX" ]]; then
tmuxp load -d "$selected_dir"
tmuxp load -y "$selected_dir"
zoxide_score
else
tmuxp load "$selected_dir"
zoxide_score
fi
tmux switch-client -t "$tab_title"
# tmux switch-client -t "$tab_title"
}
handle_tmuxp() {
@ -65,7 +65,9 @@ zoxide_score() {
}
launch_docs() {
tmuxp load -d notes-tasks # Doesn't load if it exists already
if ! tmux has-session -t "$SESSION_NOTES" 2>/dev/null; then
tmuxp load -d notes-tasks
fi
}
selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: ' \

13
.local/bin/tmux-notes-switch Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
SESSION_NOTES="notes-tasks"
if [ "$(tmux display-message -p '#S')" == "$SESSION_NOTES" ]; then
tmux switch-client -l
else
if tmux has-session -t "$SESSION_NOTES" 2>/dev/null; then
tmux switch-client -t "$SESSION_NOTES"
else
tmuxp load -y "$SESSION_NOTES"
fi
fi