- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 66
Alias examples
        Yasuhiro Yamada edited this page Mar 10, 2019 
        ·
        2 revisions
      
    Alias:
alias xpanes='xpanes -B "set {}"'Command example:
$ xpanes -c 'echo $1-$2-$3' 'A B C' 'E F G' 'H I J' 'L M N'Result:
    +-------------------------------+------------------------------+
    │$ echo $1-$2-$3                │$ echo $1-$2-$3               │
    │A-B-C                          │E-F-G                         │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    +-------------------------------+------------------------------+
    │$ echo $1-$2-$3                │$ echo $1-$2-$3               │
    │H-I-J                          │L-M-N                         │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    +-------------------------------+------------------------------+
A is assigned to $1, and B is $2 as same ... due to set command (see Positional parameters).
Finally, $N variables can be refered by -c.
Off-course, it works under the Pipe mode.
Command example:
echo A B C | xpanes -c 'printf "%s,%s,%s\n" $1 $2 $3'Result:
    +-------------------------------+
    │$ printf "%s,%s,%s\n" $1 $2 $3 │
    │A,B,C                          │
    │                               │
    │                               │
    │                               │
    │                               │
    │                               │
    +-------------------------------+
Alias:
_tmp='INDEX=`tmux display -pt "${TMUX_PANE}" "#{pane_index}"`'
alias xpanes="xpanes -B '${_tmp}'"Command example:
$ xpanes -sc 'echo $INDEX' _ _ _ _Result:
    +-------------------------------+------------------------------+
    │$ echo $INDEX                  │$ echo $INDEX                 │
    │0                              │1                             │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    +-------------------------------+------------------------------+
    │$ echo $INDEX                  │$ echo $INDEX                 │
    │2                              │3                             │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    │                               │                              │
    +-------------------------------+------------------------------+
Alias:
_tmp="tmux list-panes -F '#{pane_width} #{pane_height} #{pane_id}' | awk '{s=\$1*\$2;if(max_s<s){max_s=s;id=\$3}}END{print id}' | xargs tmux select-pane -t"
alias xpanes="xpanes -B '${_tmp}'"Command example:
$ xpanes 1 2 3    +------------------------------+------------------------------+
    │$ echo 1                      │$ echo 2                      │
    │1                             │2                             │
    │                              │                              │
    │                              │                              │
    │                              │                              │
    │                              │                              │
    │                              │                              │
    │                              │                              │
    +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
    @$ echo 3                                                     @
    @3                                                            @
    @                                                             @
    @                                                             @
    @                                                             @
    @                                                             @
    @                                                             @
    @ (This pane is selected)                                     @
    +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
Alias:
alias xpanes='xpanes -t -B "tmux select-pane -t \${TMUX_PANE} -T \"ARG:{} PID:$$\""'Command example:
$ xpanes AAA BBB CCCResult:
    +-------------------------------+-------------------------------+
    │$ echo AAA                     │$ echo BBB                     │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    +--ARG:AAA :PID:123-------------+--ARG:BBB :PID:123-------------+
    │$ echo CCC                     │$ echo DDD                     │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    │                               │                               │
    +--ARG:CCC :PID:123-------------+--ARG:DDD :PID:123-------------+