Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yudai/sshh
A SSH session duplicator for tmux
https://github.com/yudai/sshh
Last synced: 6 days ago
JSON representation
A SSH session duplicator for tmux
- Host: GitHub
- URL: https://github.com/yudai/sshh
- Owner: yudai
- License: apache-2.0
- Created: 2015-07-18T07:52:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-05-19T22:45:27.000Z (over 3 years ago)
- Last Synced: 2024-10-29T17:55:53.600Z (15 days ago)
- Language: Shell
- Size: 566 KB
- Stars: 80
- Watchers: 8
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SSHH - A SSH session duplicator for tmux
SSHH is a simple helper tool which executes the same SSH command running at a specified window/pane on tmux sessions. You can quickly duplicate your current SSH session into a new pane or window without searching your command history by using the `sshh` command.
![Screenshot](https://raw.githubusercontent.com/yudai/sshh/master/sshh.gif)
SSHH is inspired by [the cdd command](https://github.com/m4i/cdd).
## Installation
Put the `sshh` file to any directory included in the `$PATH` environment variable and give the execution permission to the file.
```sh
wget "https://raw.githubusercontent.com/yudai/sshh/master/sshh" && chmod a+x sshh
```## Usage
You can use the `sshh` command simply as a CLI tool.
```sh
Usage: sshh [window_index],[pane_index] [session_name]
``````sh
# Run the same SSH command running at pane 0 window 3 in the current session
$ sshh 3# Run the same SSH command running at pane 2 of window 3 in the current session
$ sshh 3,2# Run the same SSH command at pane 3 of the current window
$ sshh ,3# Run the same SSH command at window 1 in the session named `develop`
$ sshh 1 develop
```When the process running at the specified window/pane is not the `ssh` command, `sshh` shows a prompt to ask if you really want to run it.
## Usage with `split-window`
By adding (a little bit tricky) `bind-key` settings, you can open a new pane and duplicate your current SSH session into it at once. If you are a Zsh user, add the following lines to your `.tmux.conf`. Users of the other shells need to replace the `zsh` in the lines with your prefered shell command.
```
# Assign C-s to split pane horizontally and start a new SSH session
bind-key C-s run-shell "tmux split-window -h \"SSHH_INDEX=$(tmux display -p \",#{pane_index}\") zsh -l\"" \; send-keys ' sshh ${SSHH_INDEX}' ENTER# Assign C-w to split pane vertically and start a new SSH session
bind-key C-w run-shell "tmux split-window -v \"SSHH_INDEX=$(tmux display -p \",#{pane_index}\") zsh -l\"" \; send-keys ' sshh ${SSHH_INDEX}' ENTER
```## Usage with `new-window`
When you want to open a new window, you can write like:
```
bind-key C-n run-shell "tmux new-window \"SSHH_INDEX=$(tmux display -p \"#{window_index},#{pane_index}\") zsh -l\"" \; send-keys ' sshh ${SSHH_INDEX}' ENTER
```