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

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.