-
Notifications
You must be signed in to change notification settings - Fork 12
/
sssh
executable file
·28 lines (22 loc) · 1004 Bytes
/
sssh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Decription
# -----------
# Script to change your terminal title to user@host when connecting to ssh and changing
# it back after exiting. Additionally sets green prompt on remote host.
# Useful for Keepassx and visual distinction to avoid notorious "wrong window" problem.
# Also works when connecting Fish → Bash
#
# If you want hostname from local `~/.ssh/config` file to appear in title use [sssh2](https://github.com/dmi3/bin/blob/master/sssh2).
# Author: [Dmitry](http://dmi3.net) [Source](https://github.com/dmi3/bin)
# Requirements
# ------------
# `sudo apt-get install xdotool`
# Usage
# -----
# `sssh user@hostname`
# `alias ssh=sssh`
CUSTOM_PS1='PS1="\[$(tput bold)\]\[$(tput setaf 2)\][\u@\h \W]\\$ \[$(tput sgr0)\]"'
CUSTOM_TITLE='echo -e "\033]0;🖧 $USER@$HOSTNAME\a"'
PREV_TITLE=`xdotool getwindowfocus getwindowname`
/usr/bin/ssh -t "$@" "export PROMPT_COMMAND='eval '\\''$CUSTOM_TITLE;$CUSTOM_PS1'\\'; bash --login"
echo -e "\033]0;$PREV_TITLE\a"