This commit is contained in:
anki-code 2020-04-19 17:39:40 +03:00
parent 285a6a3071
commit 5c4db9ddb4
2 changed files with 20 additions and 12 deletions

View file

@ -55,7 +55,7 @@ Currently supported OS is Linux on x86_64.
### Prerun plugins ### Prerun plugins
[Prerun plugins](https://github.com/xxh/xxh/wiki#plugins) allow to bring any portable tools, dotfiles, aliases to xxh session before running shell. [Prerun plugins](https://github.com/xxh/xxh/wiki#plugins) allow to bring any portable tools, dotfiles, aliases to xxh session before running shell.
Pinned plugins: [sudo](https://github.com/xxh/xxh-plugin-prerun-sudo), [mc](https://github.com/xxh/xxh-plugin-prerun-mc), [docker](https://github.com/xxh/xxh-plugin-prerun-docker), [python](https://github.com/xxh/xxh-plugin-prerun-python), [vim](https://github.com/xxh/xxh-plugin-prerun-vim), [xxh](https://github.com/xxh/xxh-plugin-prerun-xxh). Pinned plugins: [sudo](https://github.com/xxh/xxh-plugin-prerun-sudo), [dotfiles](https://github.com/xxh/xxh-plugin-prerun-dotfiles), [docker](https://github.com/xxh/xxh-plugin-prerun-docker), [python](https://github.com/xxh/xxh-plugin-prerun-python), [xxh](https://github.com/xxh/xxh-plugin-prerun-xxh), [vim](https://github.com/xxh/xxh-plugin-prerun-vim), [mc](https://github.com/xxh/xxh-plugin-prerun-mc).
## Usage ## Usage
Use `xxh` as replace `ssh` to connecting to the host without changing ssh arguments: Use `xxh` as replace `ssh` to connecting to the host without changing ssh arguments:
@ -147,13 +147,12 @@ Hello from Docker!
myhost> xxh-docker-stop myhost> xxh-docker-stop
``` ```
### Put the cozy configs to xxh session ### Bring dotfiles to xxh session
For example there is [xxh-plugin-prerun-mc](https://github.com/xxh/xxh-plugin-prerun-mc) which creates There is [xxh-plugin-prerun-dotfiles](https://github.com/xxh/xxh-plugin-prerun-dotfiles) which creates config files
[Midnight Commander](https://en.wikipedia.org/wiki/Midnight_Commander) (mc) config when you go to the host using xxh. when you go to the host using xxh. You can fork it and create your cozy settings once and forever.
You can fork it and create your cozy settings for mc once and forever.
### Oh My Zsh seamless SSH ([demo](https://asciinema.org/a/rCiT9hXQ5IdwqOwg6rifyFZzb)) ### Seamless Oh My Zsh ([demo](https://asciinema.org/a/rCiT9hXQ5IdwqOwg6rifyFZzb))
```shell script ```shell script
source xxh.zsh myhost +I xxh-plugin-zsh-ohmyzsh +if +q source xxh.zsh myhost +I xxh-plugin-zsh-ohmyzsh +if +q
``` ```

View file

@ -7,7 +7,7 @@ from base64 import b64encode
from signal import signal, SIGINT from signal import signal, SIGINT
from .shell import * from .shell import *
XXH_VERSION = '0.7.12' XXH_VERSION = '0.7.13'
def sigint_handler(signal_received, frame): def sigint_handler(signal_received, frame):
sys.exit(0) sys.exit(0)
@ -877,7 +877,8 @@ class xxh:
# Upload files # Upload files
bash_wrap_begin = "bash -c 'shopt -s dotglob && "
bash_wrap_end = "'"
if which('rsync') and host_info['rsync']: if which('rsync') and host_info['rsync']:
self.eprint('First time upload using rsync (this will be omitted on the next connections)') self.eprint('First time upload using rsync (this will be omitted on the next connections)')
@ -891,7 +892,9 @@ class xxh:
progress=('' if self.quiet or not self.verbose else '--progress') progress=('' if self.quiet or not self.verbose else '--progress')
) )
self.S("{rsync} {shell_build_dir}/ {host}:{host_xxh_shell_build_dir}/ 1>&2".format( self.S("{bb}{rsync} {shell_build_dir}/ {host}:{host_xxh_shell_build_dir}/ 1>&2{be}".format(
bb=bash_wrap_begin,
be=bash_wrap_end,
rsync=rsync, rsync=rsync,
host=A(host), host=A(host),
shell_build_dir=shell_build_dir, shell_build_dir=shell_build_dir,
@ -900,7 +903,9 @@ class xxh:
for local_plugin_dir in list(local_plugins_dir.glob(f'xxh-plugin-prerun-*')) + list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')): for local_plugin_dir in list(local_plugins_dir.glob(f'xxh-plugin-prerun-*')) + list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')):
local_plugin_build_dir = local_plugin_dir/'build' local_plugin_build_dir = local_plugin_dir/'build'
local_plugin_name = local_plugin_dir.name local_plugin_name = local_plugin_dir.name
self.S("{rsync} {local_plugin_build_dir}/* {host}:{host_xxh_plugins_dir}/{local_plugin_name}/build/ 1>&2".format( self.S("{bb}{rsync} {local_plugin_build_dir}/* {host}:{host_xxh_plugins_dir}/{local_plugin_name}/build/ 1>&2{be}".format(
bb=bash_wrap_begin,
be=bash_wrap_end,
rsync=rsync, rsync=rsync,
host=A(host), host=A(host),
local_plugin_build_dir=local_plugin_build_dir, local_plugin_build_dir=local_plugin_build_dir,
@ -915,7 +920,9 @@ class xxh:
ssh_arguments=A(self.ssh_arguments), ssh_arguments=A(self.ssh_arguments),
arg_q=A(arg_q) arg_q=A(arg_q)
) )
self.S('{scp} {shell_build_dir} {host}:{host_xxh_shell_dir}/ 1>&2'.format( self.S('{bb}{scp} {shell_build_dir} {host}:{host_xxh_shell_dir}/ 1>&2{be}'.format(
bb=bash_wrap_begin,
be=bash_wrap_end,
scp=scp, scp=scp,
shell_build_dir=shell_build_dir, shell_build_dir=shell_build_dir,
host=host, host=host,
@ -925,7 +932,9 @@ class xxh:
for local_plugin_dir in list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')) + list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')): for local_plugin_dir in list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')) + list(local_plugins_dir.glob(f'xxh-plugin-{self.short_shell_name}-*')):
local_plugin_build_dir = local_plugin_dir/'build' local_plugin_build_dir = local_plugin_dir/'build'
local_plugin_name = local_plugin_dir.name local_plugin_name = local_plugin_dir.name
self.S('{scp} {local_plugin_build_dir}/* {host}:{host_xxh_plugins_dir}/{local_plugin_name}/build/ 1>&2'.format( self.S('{bb}{scp} {local_plugin_build_dir}/* {host}:{host_xxh_plugins_dir}/{local_plugin_name}/build/ 1>&2{be}'.format(
bb=bash_wrap_begin,
be=bash_wrap_end,
scp=scp, scp=scp,
local_plugin_build_dir=local_plugin_build_dir, local_plugin_build_dir=local_plugin_build_dir,
host=host, host=host,