Skip to content

Commit

Permalink
Merge pull request #284 from rummik/mosh-client-strategy
Browse files Browse the repository at this point in the history
Add mosh-client default strategy
  • Loading branch information
bruno- authored Jan 7, 2019
2 parents b020b24 + e99f197 commit c3ffe89
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/restoring_programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [General instructions](#general-instructions)
- [Clarifications](#clarifications)
- [Working with NodeJS](#nodejs)
- [Restoring Mosh](#mosh)

### General instructions <a name="general-instructions"></a>
Only a conservative list of programs is restored by default:<br/>
Expand Down Expand Up @@ -169,3 +170,10 @@ A work around, for this problem until it's fixed, is:

... node:node /path/to/yarn gulp "test-it"


### Restoring Mosh <a name="#mosh"></a>
Mosh spawns a `mosh-client` process, so we need to specify that as the process to be resurrected.

set -g @resurrect-processes 'mosh-client'

Additionally a mosh-client strategy is provided to handle extracting the original arguments and re-run Mosh.
1 change: 1 addition & 0 deletions resurrect.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set_restore_bindings() {

set_default_strategies() {
tmux set-option -gq "${restore_process_strategy_option}irb" "default_strategy"
tmux set-option -gq "${restore_process_strategy_option}mosh-client" "default_strategy"
}

set_script_path_options() {
Expand Down
25 changes: 25 additions & 0 deletions strategies/mosh-client_default_strategy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# "mosh-client default strategy"
#
# Example mosh-client process:
# mosh-client -# charm tmux at | 198.199.104.142 60001
#
# When executed, the above will fail. This strategy handles that.

ORIGINAL_COMMAND="$1"
DIRECTORY="$2"

mosh_command() {
local args="$ORIGINAL_COMMAND"

args="${args#*-#}"
args="${args%|*}"

echo "mosh $args"
}

main() {
echo "$(mosh_command)"
}
main

0 comments on commit c3ffe89

Please sign in to comment.