greymd / tmux-xpanes Goto Github PK
View Code? Open in Web Editor NEWAwesome tmux-based terminal divider
License: MIT License
Awesome tmux-based terminal divider
License: MIT License
$ tmux -V; xpanes -V
tmux 2.4
xpanes 2.0.2
This command causes broken layout sometimes.
$ xpanes '' 2 '\n' 3
Like this
dump
...
+ tmux -S /root/.cache/xpanes/socket send-keys -t xpanes-11535:tmp-11535 '/usr/bin/xpanes '\''-c'\'' '\''echo {} '\'' '\''--'\'' '\'''\'' '\''2'\'' '\''\n'\'' '\''3'\'' ' C-m
+ tmux -S /root/.cache/xpanes/socket send-keys -t xpanes-11535:tmp-11535 exit C-m
+ '[' 1 -eq 1 ']'
+ tmux -S /root/.cache/xpanes/socket attach-session -t xpanes-11535
[exited]
+ '[' 0 -ne 0 ']'
+ xpns_restore_allow_rename on /root/.cache/xpanes/socket
+ local _default_allow_rename=on
+ local _session=/root/.cache/xpanes/socket
+ [[ on == \o\n ]]
+ '[' -z /root/.cache/xpanes/socket ']'
+ tmux -S /root/.cache/xpanes/socket set-window-option -g allow-rename on
no server running on /root/.cache/xpanes/socket
+ exit 0
in case there is any standard input.
Hi,
since I can't use mssh anymore, I learned to love tmux, because of xpanes :-) The only thing I miss under my Linux (bash), is to know, which pane is which (ssh) host. If I connect to 20 hosts or more, I have only the hostname, which you don't see always.
Is there a way to put a small bar under every pane which shows the hostname ?
cu denny
Is there anyway to run different command after xpanes runs up
$ echo -ne "1\n\n2\n\n" | xargs printf '[%s]'
[1][2]
$ echo -ne "1\n\n2\n\n" | xpanes printf '[%s]'
# will open 4 panes, expected 2 panes
In general, all the arguments after the --
are recognized as the arguments (not option).
For example.
$ xpanes -- -a -b -d -l
Expected result is
$ echo -a │$ echo -b
│
│
│
│
│
│
│
───────────────────────────────┼───────────────────────────────
$ echo -d │$ echo -l
│
│
│
│
│
│
│
I want like...
$ figlet -f avatar xpanes
___ _ ____ ____ _ _____ ____
\ \/// __\/ _ \/ \ /|/ __// ___\
\ / | \/|| / \|| |\ ||| \ | \
/ \ | __/| |-||| | \||| /_ \___ |
/__/\\\_/ \_/ \|\_/ \|\____\\____/
Because xpanes uses =~
operator.
It must not work on bash 3.1.
When the large number of arguments are given, the split time is very slow.
There must be better algorithm.
Currently, xpanes executes select-layout tiled
and re-organize the panes for every splitting action.
https://github.com/greymd/tmux-xpanes/blob/master/bin/xpanes#L402
However, the minimum size of the pane is defined by tmux.
Defined in : https://github.com/tmux/tmux/blob/74ecc866cf7613a3af10f400b4d59c12200d38c5/tmux.h#L68
Referd in : https://github.com/tmux/tmux/blob/102df8dc8047d992e2fe72a2aa3d2f7eee3d185a/layout.c#L833
My idea is...
$ TMUX_XPANES_EXEC=~/.config/tmuxvm/bin/tmux ./xpanes 1 2 3
xpanes:Error: tmux is required to work.
This is tmux's spec.
$ tmux send-keys "あああ"
# result
ã^Á^Âã^Á^Âã^Á^Â
$ echo AAA BBB | xargs -n 1 | ./xpanes --ssh
result is
ssh -o StrictHostKeyChecking=no AAA AAA
ssh -o StrictHostKeyChecking=no BBB BBB
I want the feature like this. -a
means append
.
Or, -x
(extend
) may also be meaningful.
+-------------------------------+-------------------------------+
│$ │$ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
+-------------------------------+-------------------------------+
│ $ xpanes -a 4 5 6 │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
+-------------------------------+-------------------------------+
Result:
+-------------------------------+-------------------------------+
│$ │$ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
+-------------------------------+-------------------------------+
│$ │$ echo 4 │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
+-------------------------------+-------------------------------+
│$ echo 5 │$ echo 6 │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
+-------------------------------+-------------------------------+
I use fish shell, and xpanes does not work because it tries to run this command in my default shell (fish)
~
$ /usr/bin/xpanes '-c' 'echo {}' '--' '11' '12' && exit
Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.
fish: /usr/bin/xpanes '-c' 'echo {}' '--' '11' '12' && exit
It doesn't work even if I open bash and run xpanes in it.
Could you add support for trying to open bash if it's not default shell but is available on the system?
$ echo file1 file2 | xargs -n 1 | xpanes rm
it expected following commands will be executed, but it doesn't.
$ rm file1 | $ rm file2
|
|
But like this
$ rm | $ rm
|
|
It is worth adding test cases for macOS.
tmux 2.4 is released April 2017: https://github.com/tmux/tmux/releases/tag/2.4
xpanes --kill-window=$(tmux display-message -p "#I") 1 2 3 4
xpanes -c 'xpanes --kill-window=$(tmux display-message -p "#I") -I@ -c "echo @" {}' "groupA-host1 groupA-host2" "groupB-host1 groupB-host2 groupB-host3" "groupC-host1 groupC-host2"
Improve the way for separating standard input strings.
Introducing same tokenization logic as xargs
, we can implement -n
option as same as xargs
like this.
$ command | xpanes -n 2 -I@ seq @
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ tmux -V
tmux 1.8
$ xpanes -V
xpanes 2.2.0
$ cout-login --log=~/logs host{1..3}
/home/user/.cache/cout-login/bin/xpanes: line 985: cd: ~/logs: No such file or directory
set option: allow-rename -> off
[exited]
failed to connect to server
And ~/logs
directory was not created.
$ echo -ne "1\n\n2\n\n" | xargs printf '[%s]'
[1][2]
$ echo -ne "1\n\n2\n\n" | xpanes printf '[%s]'
# will open 4 panes, expected 2 panes
like this
$ xpanes -dlS hoge
Like this?
$ xpanes -l ev 1 2
generates.
$ echo 1
----------
$ echo 2
$ xpanes -l eh 1 2
generates.
$ echo 1 | $ echo 2
|
|
__xpanes::
prefix_XP_
prefixset -e
And follow the coding rule provided by google.
https://google.github.io/styleguide/shell.xml
$ tmux -V
1.5
$ xpanes 1 2 3
warn: xpanes may not work currectly because current tmux version is 'tmux 1.5'.
tmux 1.6 and more upper versions are officially supported.
If I run xpanes {1..4}
all for window panes/splits are synchronize. With this, when I do ls
for example, all panes do the same thing, giving the same output. Why would this be better default than turning synchronization of by default? I can make changes to the way I want, but just want to understand the rationale first.
$ xpanes -V; tmux -V
xpanes 2.0.2
tmux 2.2
$ xpanes '%d' '%s'
expected: 2panes
actual: 3panes
It seems that this is caused by perl
.
printf
method in perl
interprets such the query.
$ seq 3 | xargs echo -f
-f 1 2 3
$ seq 3 | xpanes echo -f
Invalid option -- 'f'
Hi Yasuhiro,
Thanks for this excellent tmux utility!
I created a "basic" RPM SPEC file to package this for RHEL based systems. I'm using CentOS 7 and it works very well with the distribution included tmux (v1.8).
The generated RPM install the following file tree:
/
|-- usr
| |-- bin
| | |-- tmux-xpanes -> ./xpanes
| | `-- xpanes
| `-- share
| |-- doc
| | `-- tmux-xpanes-2.2.1
| | |-- CONTRIBUTING.md
| | `-- README.md
| |-- licenses
| | `-- tmux-xpanes-2.2.1
| | `-- LICENSE
| `-- man
| `-- man1
| |-- tmux-xpanes.1.gz -> xpanes.1.gz
| `-- xpanes.1.gz
...
If you think this can be useful to others, I can make a pull request or you can copy it directly from my fork: https://github.com/mpatenaude/tmux-xpanes/blob/master/tmux-xpanes.spec
Best,
Math
xpanes -d 1 2
With -d
option, synchronous pane mode is disabled.
This is same as :set synchronize-panes off
in tmux.
-e
option is same as -c '{}'
$ xpanes -e "top" "vmstat 1"
$ top | $ vmstat 1
|
|
$ echo -e "top\nvmstat 1" | xpanes -e
$ top | $ vmstat 1
|
|
i guess this is more of an open ended prompt, i've come across these two in the same breath of internet searching on a couple occasions, curious how/if they relate/conflict/supplement/etc?
https://www.gnu.org/software/parallel/man.html#tmuxpane
tmux-xpanes internally uses tmux
command as the default executor of the tmux.
However, I imagine that someone wants to use tmux -2
as the default command, or someone may want to use tmux
command on the non-general directory, like ~/bin/tmux
.
My idea is...
TMUX_XPANES_EXEC
.xpanes
uses the environment variable as the command. If it's empty, tmux
is just used.$ export TMUX_XPANES_EXEC="~/bin/tmux -2"
$ xpanes 1 2 3 4
# => Then, "~/bin/tmux -2" will internally be used.
Executing xpanes
commands without any arguments, the command does not return any errors and split windows into three panes. And nothing happens.
# (in tmux session)
$ seq 3 | ./xpanes -S aaa
# aaa file is not created.
If the argument has special characters like dot .
, default window name will be escaped one.
for example,
$ xpanes 3.14
Window name will be 3\x2e14
.
\x2e
corresponding to dot .
. This is the specification because if the window name has some special characters like .
, -
, window separation feature given by tmux does not work. But I would like to fix this issue.
I am wondering why this line is necessary.
https://github.com/greymd/tmux-xpanes/blob/v2.2.2/bin/xpanes#L398
It takes much time to finish separation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.