├── .gitmodules ├── LICENSE ├── README.md ├── demo.gif └── ssh-connect.sh /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "listbox"] 2 | path = listbox 3 | url = https://github.com/gko/listbox.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Konstantin Gorodinskii 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ssh-connect 2 | 🐙 simple ssh manager. It looks for your previous ssh sessions in `$HISTFILE` and keeps relevant the ones that you reconnect to. Supports bash and zsh. 3 | 4 | ![demo](https://raw.githubusercontent.com/gko/ssh-connect/master/demo.gif) 5 | 6 | ## Installation 7 | 8 | ### Manually 9 | ```bash 10 | git clone --recursive https://github.com/gko/ssh-connect 11 | ``` 12 | then in .bashrc or .zshrc: 13 | ```bash 14 | source ./ssh-connect/ssh-connect.sh 15 | ``` 16 | 17 | ### With [antigen](https://github.com/zsh-users/antigen) 18 | 19 | In your .zshrc 20 | ```sh 21 | antigen bundle gko/ssh-connect 22 | ``` 23 | 24 | ### With [Fig](https://fig.io) 25 | 26 | Fig adds apps, shortcuts, and autocomplete to your existing terminal. 27 | 28 | Install `ssh-connect` in just one click. 29 | 30 | 31 | 32 | ## Like it? 33 | 34 | :star: this repo 35 | 36 | ## License 37 | 38 | [MIT](http://opensource.org/licenses/MIT) 39 | 40 | Copyright (c) 2012-2016 Konstantin Gorodinskiy 41 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gko/ssh-connect/3ca599b2ac106d6ce4c1b89c0d059f421a8af770/demo.gif -------------------------------------------------------------------------------- /ssh-connect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -n "$ZSH_VERSION" ]; then 4 | src=$(dirname "${(%):-%N}")/listbox/listbox.sh 5 | elif [ -n "$BASH_VERSION" ]; then 6 | src=$(dirname "${BASH_SOURCE[0]}")/listbox/listbox.sh 7 | else 8 | src=$(dirname "$0")/listbox/listbox.sh 9 | fi 10 | 11 | source "$src" 12 | 13 | ssh-history() { 14 | cat "$HISTFILE" | grep -E "^ssh\s" | sed -e 's/\s*$//' | sort | uniq -c | sort -nr | sed -e "s/^\s*[0-9]*\s//" 15 | } 16 | 17 | ssh-connect() { 18 | local hist=$(ssh-history | tr '\n' '|') 19 | res=$(listbox -t "Connect:" -o "$hist" | tee /dev/tty | tail -n 1) 20 | echo "" 21 | echo "$res" >> "$HISTFILE" 22 | eval "$res" 23 | } 24 | --------------------------------------------------------------------------------