github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/integrations/tmux_posix.mx (about)

     1  autocomplete set tmux %[
     2      { Dynamic: "{ tmux-commands }"    }
     3      { Dynamic: "{ tmux-subcommands }" }
     4  ]
     5  
     6  private tmux-commands {
     7      # Parse `tmux` command line arguments
     8      tmux start\; list-commands -> [:0]
     9  }
    10  
    11  test unit private tmux-commands %{
    12      StdoutRegex: '([-a-z]+\n)+'
    13  }
    14  
    15  
    16  private tmux-subcommands {
    17      # Parses `tmux` command line arguments
    18      tmux start\; list-commands -> regexp m/$ARGS[1]/ -> regexp 'f#\[\-([-a-zA-Z0-9]+)#' -> foreach { -> jsplit "" -> format * } -> regexp m/[a-zA-Z0-9]/ -> prefix -
    19  }
    20  
    21  test unit private tmux-subcommands %{
    22      Parameters: [ attach-session ]
    23      StdoutRegex: '(-[a-zA-Z]\n)+'
    24  }
    25  
    26  function tsplit {
    27      # Splits the current tmux session horizontally and runs a murex code block
    28  
    29      test state cmd { $cmd }
    30      test state pwd { $PWD }
    31      
    32      test state tmux {
    33          (tmux split -h ($SHELL --load-modules -c (cd $PWD; clear; source $cmd)))
    34      }
    35  
    36      test state shell {
    37          ($SHELL --load-modules -c (cd $PWD; clear; source $cmd))
    38      }
    39  
    40      if { $TMUX } then {
    41          trypipe {
    42              $ARGS[1] -> set cmd
    43              pwd -> set PWD
    44              tmux <state_cmd> <state_pwd> <state_tmux> <state_shell> \
    45                  split -h ($SHELL --load-modules -c (cd $PWD; clear; sleep 4; echo $cmd; source $cmd; sleep 4))
    46          }
    47      } else {
    48          err "tmux is not running."
    49      }
    50  }