mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
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?
|
||||
|
||||
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
|
||||
command which will automatically copy the terminfo files over.
|
||||
You can ssh in using the following command which will automatically copy the
|
||||
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
|
||||
on the server, but is slower, as it has to ssh into the server twice:
|
||||
If for some reason that does not work, you can use the following one-liner
|
||||
instead (it is slower as it needs to ssh into the server twice).
|
||||
|
||||
....
|
||||
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
|
||||
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?
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
SHELL_SCRIPT = '''\
|
||||
#!/bin/sh
|
||||
|
||||
tmp=$(mktemp /tmp/terminfo.XXXXXX)
|
||||
cat >$tmp << 'TERMEOF'
|
||||
TERMINFO
|
||||
@ -17,47 +16,16 @@
|
||||
rc=$?
|
||||
rm $tmp
|
||||
if [ "$rc" != "0" ]; then echo "$tic_out"; exit 1; fi
|
||||
if [ -z "$USER" ]; then 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.
|
||||
if [ -z "$USER" ]; then export USER=$(whoami); fi
|
||||
|
||||
# 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.
|
||||
# Shell scripting is a horrible joke, thank heavens for python.
|
||||
local IFS=:
|
||||
if [ $ZSH_VERSION ]; then
|
||||
# zsh does not split by default
|
||||
setopt sh_word_split
|
||||
fi
|
||||
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))"
|
||||
|
||||
# We need to pass the first argument to the executed program with a leading -
|
||||
# to make sure the shell executes as a login shell. Note that not all shells
|
||||
# support exec -a
|
||||
shell_name=$(basename $0)
|
||||
exec -a "-$shell_name" "$0"
|
||||
# exec does not support -a
|
||||
exec "$0" --login
|
||||
'''
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user