Replace notes binding with nvim
This commit is contained in:
27
notes-cmd.sh
27
notes-cmd.sh
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Open neovim in the notes directory.
|
||||
# Detaches the client if all panes in the window are dead afterwards.
|
||||
|
||||
notes_dir="$HOME/Documents/Notes"
|
||||
|
||||
nvim "$notes_dir" || true
|
||||
|
||||
# Brief delay to let tmux update pane status
|
||||
sleep 0.1
|
||||
|
||||
window_id=$(tmux display-message -p '#{window_id}')
|
||||
my_pane=$(tmux display-message -p '#{pane_id}')
|
||||
|
||||
# Count live sibling panes (not us, not dead)
|
||||
other_live=$(tmux list-panes -t "$window_id" -F '#{pane_id} #{pane_dead}' \
|
||||
| awk -v me="$my_pane" '$1 != me && $2 == "0"' | wc -l | tr -d ' ')
|
||||
|
||||
if [ "$other_live" -eq 0 ]; then
|
||||
# No live siblings — close the popup and kill the window
|
||||
# (also cleans up any dead siblings).
|
||||
tmux detach-client
|
||||
tmux kill-window -t "$window_id" 2>/dev/null || true
|
||||
else
|
||||
# User has split off other live panes — only kill ours, keep popup open.
|
||||
tmux kill-pane 2>/dev/null || true
|
||||
fi
|
||||
20
notes.sh
20
notes.sh
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
notes_dir="$HOME/Documents/Notes"
|
||||
|
||||
# Create the notes session if it doesn't exist
|
||||
if ! tmux has-session -t notes; then
|
||||
tmux new-session -ds notes -c "$notes_dir" -n notes "$script_dir/notes-cmd.sh"
|
||||
fi
|
||||
|
||||
# Apply session options on every invocation so updates propagate to live sessions
|
||||
tmux set-option -t notes status off
|
||||
tmux set-option -t notes remain-on-exit on
|
||||
tmux set-option -t notes default-command "$script_dir/notes-cmd.sh"
|
||||
|
||||
# Attach to the session
|
||||
tmux attach-session -t notes
|
||||
@@ -67,7 +67,7 @@ if -b '~/.config/tmux/check-version.sh ">= 3.2" and "< 3.3"' {
|
||||
}
|
||||
bind H display-popup -w 75% -h 75% -E htop
|
||||
bind I display-popup -d '#{pane_current_path}' -E ~/.config/tmux/interpreter.sh
|
||||
bind N display-popup -w 75% -h 90% -E ~/.config/tmux/notes.sh
|
||||
bind N display-popup -d '#{pane_current_path}' -w 60% -h 75% -E nvim
|
||||
bind S display-popup -w 60 -h 10 -E ~/.config/tmux/session.sh
|
||||
bind T display-popup -d '#{pane_current_path}' -E $SHELL
|
||||
}
|
||||
@@ -77,7 +77,7 @@ if -b '~/.config/tmux/check-version.sh ">= 3.3"' {
|
||||
}
|
||||
bind H display-popup -S fg=#54546D -b rounded -w 50% -h 75% -E htop
|
||||
bind I display-popup -S fg=#54546D -b rounded -d '#{pane_current_path}' -E ~/.config/tmux/interpreter.sh
|
||||
bind N display-popup -S fg=#54546D -b rounded -w 75% -h 90% -E ~/.config/tmux/notes.sh
|
||||
bind N display-popup -S fg=#54546D -b rounded -d '#{pane_current_path}' -w 60% -h 75% -E nvim
|
||||
bind S display-popup -B -w 60 -h 10 -E ~/.config/tmux/session.sh
|
||||
bind T display-popup -S fg=#54546D -d '#{pane_current_path}' -E $SHELL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user