mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-22 04:18:48 +00:00
Use a strategy when fetching pane full command
This commit is contained in:
parent
99abfa5f13
commit
9f7050aaae
@ -1,6 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### master
|
### master
|
||||||
|
- plugin now uses strategies when fetching pane full command. Implemented
|
||||||
|
'default' strategy.
|
||||||
|
|
||||||
### v1.3.0, 2014-09-20
|
### v1.3.0, 2014-09-20
|
||||||
- remove dependency on `pgrep` command. Use `ps` for fetching process names.
|
- remove dependency on `pgrep` command. Use `ps` for fetching process names.
|
||||||
|
24
save_command_strategies/default.sh
Executable file
24
save_command_strategies/default.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
PANE_PID="$1"
|
||||||
|
|
||||||
|
exit_safely_if_empty_ppid() {
|
||||||
|
if [ -z "$PANE_PID" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
full_command() {
|
||||||
|
ps -eo "ppid command" |
|
||||||
|
sed "s/^ *//" |
|
||||||
|
grep "^${PANE_PID}" |
|
||||||
|
cut -d' ' -f2-
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
exit_safely_if_empty_ppid
|
||||||
|
full_command
|
||||||
|
}
|
||||||
|
main
|
@ -65,11 +65,22 @@ dump_panes_raw() {
|
|||||||
tmux list-panes -a -F "$(pane_format)"
|
tmux list-panes -a -F "$(pane_format)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_save_command_strategy_file() {
|
||||||
|
local save_command_strategy="$(get_tmux_option "$save_command_strategy_option" "default")"
|
||||||
|
local strategy_file="$CURRENT_DIR/../save_command_strategies/${save_command_strategy}.sh"
|
||||||
|
local default_strategy_file="$CURRENT_DIR/../save_command_strategies/default.sh"
|
||||||
|
if [ -e "$strategy_file" ]; then # strategy file exists?
|
||||||
|
echo "$strategy_file"
|
||||||
|
else
|
||||||
|
echo "$default_strategy_file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
pane_full_command() {
|
pane_full_command() {
|
||||||
local pane_pid="$1"
|
local pane_pid="$1"
|
||||||
ps -eo "ppid command" |
|
local strategy_file="$(_save_command_strategy_file)"
|
||||||
grep "^${pane_pid}" |
|
# execute strategy script to get pane full command
|
||||||
cut -d' ' -f2-
|
$strategy_file "$pane_pid"
|
||||||
}
|
}
|
||||||
|
|
||||||
# translates pane pid to process command running inside a pane
|
# translates pane pid to process command running inside a pane
|
||||||
|
@ -23,3 +23,5 @@ restore_processes=""
|
|||||||
restore_process_strategy_option="@resurrect-strategy-"
|
restore_process_strategy_option="@resurrect-strategy-"
|
||||||
|
|
||||||
inline_strategy_token="->"
|
inline_strategy_token="->"
|
||||||
|
|
||||||
|
save_command_strategy_option="@resurrect-save-command-strategy"
|
||||||
|
Loading…
Reference in New Issue
Block a user