Closed duckunix closed 9 years ago
Hi, I can reproduce this issue too.
Was this working for you previously? From what I can see, it is not related to changes in #43...
Here's a suggestion how to update the functions so they work nicely with tmux-resurrect
:
function smosh () {
# create a new empty window and get its `pane_id`
local pane_id=$(tmux new-window -d -n "$1" -P -F "#{pane_id}")
# use `tmux send-keys` to start a desired command in new window
tmux send-keys -t "$pane_id" "/usr/bin/mosh $*" "C-m"
}
I just tested this locally and it worked fine. Does that solve the problem?
That does work for my use case. However, I think I have figured out a more generic way by updating save_command_strategies/ps.sh (forgive the lack of pull request):
diff --git a/save_command_strategies/ps.sh b/save_command_strategies/ps.sh
index 8544add..ea0ec1f 100755
--- a/save_command_strategies/ps.sh
+++ b/save_command_strategies/ps.sh
@@ -11,10 +11,16 @@ exit_safely_if_empty_ppid() {
}
full_command() {
- ps -eo "ppid command" |
- sed "s/^ *//" |
- grep "^${PANE_PID}" |
- cut -d' ' -f2-
+ if ! ps -eo "ppid command" | grep -q "^${PANE_PID}"
+ then
+ ps -o command -p "${PANE_PID}" |
+ grep -v COMMAND
+ else
+ ps -eo "ppid command" |
+ sed "s/^ *//" |
+ grep "^${PANE_PID}" |
+ cut -d' ' -f2-
+ fi
}
I tend to have a few things which do the tmux neww -n
And, ps on FreeBSD 10-RELEASE does not like the -e flag...it lists the environment, not everything.
New patch to get it working on FreeBSD:
diff --git a/save_command_strategies/ps.sh b/save_command_strategies/ps.sh
index 8544add..60417c6 100755
--- a/save_command_strategies/ps.sh
+++ b/save_command_strategies/ps.sh
@@ -3,6 +3,10 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PANE_PID="$1"
+case $(uname -s) in
+ FreeBSD) PS_ARG="-a" ;;
+ *) PS_ARG="-e" ;;
+esac
exit_safely_if_empty_ppid() {
if [ -z "$PANE_PID" ]; then
@@ -11,10 +15,16 @@ exit_safely_if_empty_ppid() {
}
full_command() {
- ps -eo "ppid command" |
- sed "s/^ *//" |
- grep "^${PANE_PID}" |
- cut -d' ' -f2-
+ if ! ps "${PS_ARG}" -o "ppid command" | grep -q "^${PANE_PID}"
+ then
+ ps -o command -p "${PANE_PID}" |
+ grep -v COMMAND
+ else
+ ps "${PS_ARG}" -o "ppid command" |
+ sed "s/^ *//" |
+ grep "^${PANE_PID}" |
+ cut -d' ' -f2-
+ fi
}
main() {
Hi @duck
thanks for all the effort around this. I just added a patch for FreeBSD ps
command arguments in 8fd3858.
I was playing with your first patch and it seems to work.
Unfortunately it also detects bash
(in my case the default shell) for all the panes with no commands running. That means, if this patch was added to the plugin, we would also have to make some kind of filter for bash
commands (or user default shells) because that should not be restored.
On the other hand, legit bash
command should be restored, example bash -c "sleep 1000"
.
I'm sorry to say I think this increasing complexity is definitely not worth it.
Your project....your call...I am okay with that.
It all depends on how the new pane is started. I know that there has been changes made via #43 but, given the way I then to launch ssh/mosh connections, it fails.
I have functions set up to launch a new pane with either ssh or mosh like so:
Now with the new update, the base command gets saved, it just mosh-client or ssh. If I create a new pane via tmux new-window and then start the same commands as above, saving the full command plus arguments work. My last file looks like:
Where panes 2 & 4 are using my bash functions above, and panes 3 & 5 are using the new-window and then start the command method.
I have tracked the issue to the way the PID is passed to _$HOME/.tmux/plugins/tmux-resurrect/save_commandstrategies/ps.sh, but I am not sure where to go look to get it the correct PID of the pane.
Please let me know what other I can provide, or where I can go look to help fix this issue. This is a major road-block on my adoption of this fine plugin full time.
Thanks!
d