Drop the requirement for having python on the server when using the ssh kitten
This commit is contained in:
parent
d20e801793
commit
30b38e9fa0
@ -560,15 +560,15 @@ for why kitty does not support background color erase.
|
|||||||
=== I get errors about the terminal being unknown or opening the terminal failing when SSHing into a different computer?
|
=== I get errors about the terminal being unknown or opening the terminal failing when SSHing into a different computer?
|
||||||
|
|
||||||
This happens because the kitty terminfo files are not available on the server.
|
This happens because the kitty terminfo files are not available on the server.
|
||||||
If you have python installed on the server, you can ssh in using the following
|
You can ssh in using the following command which will automatically copy the
|
||||||
command which will automatically copy the terminfo files over.
|
terminfo files to the server:
|
||||||
|
|
||||||
....
|
....
|
||||||
kitty +kitten ssh server_name
|
kitty +kitten ssh myserver
|
||||||
....
|
....
|
||||||
|
|
||||||
Alternatively, you can use the following one-liner which does not require python
|
If for some reason that does not work, you can use the following one-liner
|
||||||
on the server, but is slower, as it has to ssh into the server twice:
|
instead (it is slower as it needs to ssh into the server twice).
|
||||||
|
|
||||||
....
|
....
|
||||||
infocmp xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
|
infocmp xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
|
||||||
@ -578,16 +578,6 @@ Really, the correct solution for this is to convince the OpenSSH maintainers to
|
|||||||
have ssh do this automatically when connecting to a server, so that all
|
have ssh do this automatically when connecting to a server, so that all
|
||||||
terminals work transparently.
|
terminals work transparently.
|
||||||
|
|
||||||
In the meantime, you can automate it by using a simple script called, for example,
|
|
||||||
`~/bin/myssh`
|
|
||||||
|
|
||||||
....
|
|
||||||
#!/bin/sh
|
|
||||||
infocmp xterm-kitty | ssh $1 tic -x -o \~/.terminfo /dev/stdin && ssh $1
|
|
||||||
....
|
|
||||||
|
|
||||||
Then you can use `myssh server` to log in to `server` with the terminfo file
|
|
||||||
being automatically available.
|
|
||||||
|
|
||||||
=== How do I change the colors in a running kitty instance?
|
=== How do I change the colors in a running kitty instance?
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import sys
|
|||||||
|
|
||||||
SHELL_SCRIPT = '''\
|
SHELL_SCRIPT = '''\
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
tmp=$(mktemp /tmp/terminfo.XXXXXX)
|
tmp=$(mktemp /tmp/terminfo.XXXXXX)
|
||||||
cat >$tmp << 'TERMEOF'
|
cat >$tmp << 'TERMEOF'
|
||||||
TERMINFO
|
TERMINFO
|
||||||
@ -17,47 +16,16 @@ tic_out=$(tic -x -o ~/.terminfo $tmp 2>&1)
|
|||||||
rc=$?
|
rc=$?
|
||||||
rm $tmp
|
rm $tmp
|
||||||
if [ "$rc" != "0" ]; then echo "$tic_out"; exit 1; fi
|
if [ "$rc" != "0" ]; then echo "$tic_out"; exit 1; fi
|
||||||
if [ -z "$USER" ]; then USER=$(whoami); fi
|
if [ -z "$USER" ]; then export USER=$(whoami); fi
|
||||||
search_for_python() {
|
|
||||||
# We have to search for python as Ubuntu, in its infinite wisdom decided
|
|
||||||
# to release 18.04 with no python symlink, making it impossible to run polyglot
|
|
||||||
# python scripts.
|
|
||||||
|
|
||||||
# We cannot use command -v as it is not implemented in the posh shell shipped with
|
|
||||||
# Ubuntu/Debian. Similarly, there is no guarantee that which is installed.
|
# We need to pass the first argument to the executed program with a leading -
|
||||||
# Shell scripting is a horrible joke, thank heavens for python.
|
# to make sure the shell executes as a login shell. Note that not all shells
|
||||||
local IFS=:
|
# support exec -a
|
||||||
if [ $ZSH_VERSION ]; then
|
shell_name=$(basename $0)
|
||||||
# zsh does not split by default
|
exec -a "-$shell_name" "$0"
|
||||||
setopt sh_word_split
|
# exec does not support -a
|
||||||
fi
|
exec "$0" --login
|
||||||
local candidate_path
|
|
||||||
local candidate_python
|
|
||||||
local pythons=python3:python2
|
|
||||||
# disable pathname expansion (globbing)
|
|
||||||
set -f
|
|
||||||
for candidate_path in $PATH
|
|
||||||
do
|
|
||||||
if [ ! -z $candidate_path ]
|
|
||||||
then
|
|
||||||
for candidate_python in $pythons
|
|
||||||
do
|
|
||||||
if [ ! -z "$candidate_path" ]
|
|
||||||
then
|
|
||||||
if [ -x "$candidate_path/$candidate_python" ]
|
|
||||||
then
|
|
||||||
printf "$candidate_path/$candidate_python"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
set +f
|
|
||||||
printf "python"
|
|
||||||
}
|
|
||||||
PYTHON=$(search_for_python)
|
|
||||||
exec $PYTHON -c "import os, pwd; shell = pwd.getpwuid(os.geteuid()).pw_shell or 'sh'; os.execlp(shell, '-' + os.path.basename(shell))"
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user