Skip to content

Commit edd8132

Browse files
donat-brummik
authored andcommitted
Add cmdline strategy
1 parent b020b24 commit edd8132

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

save_command_strategies/cmdline.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
PANE_PID="$1"
6+
CPID=$(pgrep -P $PANE_PID)
7+
8+
exit_safely_if_empty_ppid() {
9+
if [ -z "$PANE_PID" ]; then
10+
exit 0
11+
fi
12+
}
13+
14+
full_command() {
15+
[[ -z "$CPID" ]] && exit 0
16+
base64 /proc/${CPID}/cmdline
17+
}
18+
19+
main() {
20+
exit_safely_if_empty_ppid
21+
full_command
22+
}
23+
main

scripts/restore.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ restore_all_pane_processes() {
298298
while IFS=$d read session_name window_number pane_index dir pane_full_command; do
299299
dir="$(remove_first_char "$dir")"
300300
pane_full_command="$(remove_first_char "$pane_full_command")"
301+
if base64 -d <<< $pane_full_command >/dev/null 2>&1; then
302+
pane_full_command=$(base64 -d <<< $pane_full_command | perl -ne 'print join(" ", map quotemeta, split(/\000/)), "\n"')
303+
fi
301304
restore_pane_process "$pane_full_command" "$session_name" "$window_number" "$pane_index" "$dir"
302305
done
303306
fi

0 commit comments

Comments
 (0)