3 files changed,
63 insertions(+),
1 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-04-14 17:19:36 +0300
Authored at:
2026-04-14 16:52:13 +0300
Change ID:
rxmvqpoxmrlkxxwuuxzxvottlxsolxpt
Parent:
08c0b8c
jump to
| M | readme |
| M | scripts/helpers.sh |
| M | scripts/sessions.sh |
M
readme
··· 44 44 # Default: '$HOME/.local/share/tmux/stare/' 45 45 set -g @stare-dir '$HOME/.local/share/tmux/stare/' 46 46 47 + # Space-separated list of processes allowed to be resurrected. 48 + # - set to 'false' to disable command resurrection 49 + # - set to ':all:' to resurrect everything 50 + # Default: 'vi vim nvim man less more tial htop btop claude opencode copilot pi' 51 + set -g @stare-processes 'emacs man' 52 + 47 53 FUTURE 48 54 49 55 Things I might add in the future.
M
scripts/helpers.sh
··· 26 26 set_opt_initialized() { get_tmux_option "@stare-initialized" "$1"; } 27 27 get_opt_save() { get_tmux_option "@stare-save" "C-s"; } 28 28 get_opt_pick() { get_tmux_option "@stare-pick" ""; } 29 +get_opt_processes() { get_tmux_option "@stare-processes" "vi vim nvim man less more tial htop btop claude opencode copilot pi"; } 29 30 get_opt_dir() { 30 31 local dir="$(get_tmux_option "@stare-dir" "${HOME}/.local/share/tmux/stare" | sed "s,\$HOME,$HOME,g; s,\~,$HOME,g")" 31 32 mkdir -p "$dir"
M
scripts/sessions.sh
··· 185 185 } 186 186 187 187 # === restore 188 +restore_pane_processes_enabled() { 189 + local processes="$(get_opt_processes)" 190 + [[ "$processes" != "false" ]] 191 +} 192 + 193 +restore_all_processes() { 194 + local processes="$(get_opt_processes)" 195 + [[ "$processes" == ":all:" ]] 196 +} 197 + 198 +restore_list() { 199 + get_opt_processes 200 +} 201 + 202 +get_proc_match_element() { 203 + local proc="$1" 204 + printf "%s" "${proc%%->*}" 205 +} 206 + 207 +proc_matches_command() { 208 + local command="$1" 209 + local match="$2" 210 + if [[ "${match:0:1}" == "~" ]]; then 211 + local relaxed="${match#~}" 212 + [[ "$command" == *"$relaxed"* ]] 213 + else 214 + [[ "$command" == "$match" || "$command" == "$match "* ]] 215 + fi 216 +} 217 + 218 +command_on_restore_list() { 219 + local command="$1" 220 + local proc 221 + local match 222 + local restore_list_value 223 + restore_list_value="$(restore_list)" 224 + # shellcheck disable=SC2086 225 + eval "set -- $restore_list_value" 226 + for proc in "$@"; do 227 + match="$(get_proc_match_element "$proc")" 228 + if proc_matches_command "$command" "$match"; then 229 + return 0 230 + fi 231 + done 232 + return 1 233 +} 234 + 235 +should_restore_command() { 236 + local command="$1" 237 + [[ -z "$command" ]] && return 1 238 + restore_pane_processes_enabled || return 1 239 + restore_all_processes && return 0 240 + command_on_restore_list "$command" 241 +} 242 + 188 243 restore_session_from_file() { 189 244 local session_file="$1" 190 245 local session_name=$(basename "$session_file" | sed 's/_last$//') ··· 219 274 if [[ "$pane_active" == "1" ]]; then 220 275 tmux select-pane -t "$session_name:$window_index.$pane_index" 221 276 fi 222 - if [[ -n "$command" ]]; then 277 + if should_restore_command "$command"; then 223 278 tmux send-keys -t "$session_name:$window_index.$pane_index" "$command" Enter 224 279 fi 225 280 ;;