Code Monkey home page Code Monkey logo

tmux-ssh-split's Introduction

๐ŸŽ›๏ธ TMUX SSH Split

This TMUX plugin is a modern iteration of the concept sshh introduced.

It enables seamless SSH splits. If you're in an SSH session in the current pane and press the designated key combination, the pane will split, and the newly created pane will host an SSH session connected to the host you were previously on. If there's no active SSH session, a regular split will occur.

๐Ÿ’ก NOTE: mosh works too to some extent (experimental)

๐Ÿ“ฅ Installation

You can install this plugin using TPM:

set -g @plugin 'pschmitt/tmux-ssh-split'

๐Ÿ› ๏ธ Configuration

To use this plugin, you need to set at least one of the ssh-split-h-key or ssh-split-v-key options. These keys (PREFIX + key) will be bound to horizontal and vertical splits, respectively.

โš™๏ธ Options

Option Description Default Value
@ssh-split-h-key Key to bind for horizontal splits (prefixed) none
@ssh-split-v-key Key to bind for vertical splits (prefixed) none
@ssh-split-w-key Key to bind for new windows (prefixed) none
@ssh-split-keep-cwd Determines whether the starting directory of the new pane should be the same as the current pane. This is similar to executing tmux split -c "#{pane_current_path}". false
@ssh-split-keep-remote-cwd Similar to the above, but for remote (SSH) splits. Note that remote path detection requires an OSC7 prompt and falls back to PS1 parsing, so it won't work if your prompt doesn't contain the current path. This works best with @ssh-split-strip-cmd=true false
@ssh-split-fail Determines whether to do nothing if the current pane isn't running SSH. By default, a normal split will occur. false
@ssh-split-no-env If set to true, this will not set TMUX_SSH_SPLIT=1 in splits (see tips and tricks section) false
@ssh-split-no-shell If set to true, this will prevent a shell session from spawning after the SSH session, causing the pane to exit when the SSH session ends. false
@ssh-split-strip-cmd If set to true, the SSH command executed in the new pane will be stripped of the remote command portion. For example, if you're running ssh HOST COMMAND in a pane and you split it, tmux-ssh-split will create a new pane with a start command of ssh HOST. false
@ssh-split-verbose Displays a message before the SSH command is spawned with the command being executed false
@ssh-split-debug Debug mode. Redirects the script output to /tmp/tmux-ssh-split.log (or $TMPDIR/tmux-ssh-split.log if TMPDIR is defined). false

๐Ÿ’ก Example config

set-option -g @ssh-split-keep-cwd "true"
set-option -g @ssh-split-keep-remote-cwd "true"
set-option -g @ssh-split-fail "false"
set-option -g @ssh-split-no-env "false"
set-option -g @ssh-split-no-shell "false"
set-option -g @ssh-split-strip-cmd "true"
set-option -g @ssh-split-verbose "true"
set-option -g @ssh-split-debug "false"
set-option -g @ssh-split-h-key "|"
set-option -g @ssh-split-v-key "S"
set-option -g @ssh-split-w-key "C"

set -g @plugin 'pschmitt/tmux-ssh-split'

๐Ÿ”Œ Compatibility with Other Plugins

Some plugins may attempt to bind the same keys as tmux-ssh-split. For instance, tmux-pain-control is one such plugin. With the example configuration provided, both tmux-ssh-split and tmux-pain-control would try to bind the | key. The plugin loaded last will prevail.

โœ… Solution

I've sent a PR to fix this upstream. In the meantime you can use my fork.

To make the forked tmux-pain-control not bind the | key you can set the following:

set -g @disabled_keys "|"

๐ŸŽฉ Tips and Tricks

If you want to determine whether a command has been spawned via tmux-ssh-split in a local or remote split, you can check for the TMUX_SSH_SPLIT environment variable. It should be set to 1 for all splits. If TMUX_SSH_SPLIT is not set on remote splits, ensure that TMUX_SSH_SPLIT is listed in the AcceptEnv property in your sshd config. For example:

AcceptEnv LANG LC_* TMUX_SSH_SPLIT

๐Ÿคš If you want to disable this feature add the following to your TMUX config:

set-option -g @ssh-split-no-env "true"

๐Ÿ“œ License

This project is open source and available under the terms of the GNU General Public License v3.0

tmux-ssh-split's People

Contributors

liuruibin avatar mrjesma avatar pschmitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tmux-ssh-split's Issues

wrong path for script

So i have installed the plugin and setup a binding, but when i go to run it, it throws an error: /scripts/tmux-ssh-splush -v returned 127

If i just do $HOME/.tmux/pugins/tmux-ssh-split/scripts/tmux-ssh-split.sh -v it will actually work, so I think whats happening is that the tmux part of the run is not actually detecting its working dir properly?

Why not use $TMUX_PLUGIN_MANAGER_PATH since if TPM is running... that should exist. instead of doing

swd="$(readlink -f "$(dirname "$0")")/scripts/tmux-ssh-split.sh"

nested ssh doesnt work

So if you are in a nested ssh session, the split opens a session to the parent ssh connection rather than the expected nested one.

Feature request: keep_cwd option not working for remote splits

I've been using this tmux plugin for a few months and it's been pretty useful, but during this time I have made several attempts to debug the keep_cwd option not working for me when splitting remote windows. I always end up at $HOME, which makes it a bit less useful.

I don't think it has anything to do with my shell configuration as I have disabled them on the remote host.

Any ideas?

Is it working on M1 Mac?

Hi

It seems to not be working for me, I found one past issue for Mac but it seems to be fixed by now.

I've installed successfully, so if running again prefix + I this is what I get:

Already installed "tmux-themepack"
Already installed "tmux-prefix-highlight"
Already installed "tmux-resurrect"
Already installed "tmux-ssh-split"
Already installed "tmux-jump"

TMUX environment reloaded.

Done, press ENTER to continue.

As for the settings I'm using this .. its a copy/paste from the README.

set-option -g @ssh-split-keep-cwd "true"
set-option -g @ssh-split-keep-remote-cwd "true"
set-option -g @ssh-split-fail "false"
set-option -g @ssh-split-no-env "false"
set-option -g @ssh-split-no-shell "false"
set-option -g @ssh-split-strip-cmd "true"
set-option -g @ssh-split-verbose "true"
set-option -g @ssh-split-debug "false"
set-option -g @ssh-split-h-key "|"
set-option -g @ssh-split-v-key "S"
set-option -g @ssh-split-w-key "C"

set -g @plugin 'pschmitt/tmux-ssh-split'

Pressing the Prefix + any of these 3 keys above while in a remote SSH connection, it opens up a new pane but locally and not in the remote SSH server.

Am I missing something?

Breaks functionality of the plugin tmux-current-pane-hostname.

Hello.

tmux-current-pane-hostname is a plugin that replaces the #H functionality and also adds some news options.

The goal of the plugin is to be able to tell the hostname of the machine your are ssh'ed into. So if you have 2 panes side by side and one is sshed, selecting that pane dynamically changes the #H value.

Using both plugins together breaks tmux-current-pane-hostname functionality on the new panes created by
tmux-ssh-split.

I have open a report on the tmux-current-pane-hostname github and the author suggested to also open one here in hopes we could work together to see if we can find some kind of middle ground fix:
soyuka/tmux-current-pane-hostname#14

Would love to hear your thought on it.

MacOS Compatibility

Hi, I had an issue when using the plugging in MacOS.

The root cause is the line below. The keyword cmd= is not recognized by the BSD version of ps. For details see the FreeBSD manpage.

child_cmd="$(ps -o cmd= "$child_pid")"

A possible fix is to add command= to the keyword list as follows:
child_cmd="$(ps -o cmd=,command= "$child_pid")"

Thanks for the plugin!

Not working, pressing keys and nothing happens

I've added below to my tmux config and when I press Ctrl+B Shift+S nothing happens:

# Plugins Config
set-option -g @ssh-split-keep-cwd "true"
set-option -g @ssh-split-no-shell "true"
set-option -g @ssh-split-h-key "S"
set-option -g @ssh-split-v-key "W"

# Plugins
set -g @plugin 'pschmitt/tmux-ssh-split'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Can't split if ssh session was launched with port forwarding

If I ssh with something like ssh {username}@{address} -L 8888:localhost:8888, when I try splitting a pane I get

trap -- '' SIGTTIN
trap -- '' SIGTTOU
Bad local forwarding specification 'SendEnv=TMUX_SSH_SPLIT:localhost:SendEnv=TMUX_SSH_SPLIT'

Is this expected behavior?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.