From 7baaf6898b39c119467a28624c806edeb390c31a Mon Sep 17 00:00:00 2001 From: anki-code Date: Fri, 6 Mar 2020 13:50:56 +0300 Subject: [PATCH] init --- README.md | 16 ++++++++++++++++ build.xsh | 22 ++++++++++++++++++++++ entrypoint.sh | 31 +++++++++++++++++++++++++++++++ requirements.txt | 1 + 4 files changed, 70 insertions(+) create mode 100644 README.md create mode 100755 build.xsh create mode 100755 entrypoint.sh create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..5011f96 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +## Workflow + +1. Fork this repo to create your xxh shell entrypoint. +2. Rename your repo to `xxh-shell-myshell` +3. Install [xxh](https://github.com/xxh/xxh) and run once to creating `~/.xxh` +4. `cd ~/.xxh/shells && git clone https://github.com/you/xxh-shell-myshell && cd xxh-shell-myshell` +5. Edit `build.xsh` script +6. Edit `entrypoint.sh` script +7. Run `./build.xsh` +8. Try to connect `xxh myhost +s xxh-shell-myshell` +9. If everything works commit and push your changes +10. You rock! [Tell us about your work](https://gitter.im/xonssh-xxh/community)! + +## xxh-shell example + +Real life example of creating xxh-shell and xxh-plugins you could find in [xxh-shell-xonsh-appimage](https://github.com/xxh/xxh-shell-xonsh-appimage). \ No newline at end of file diff --git a/build.xsh b/build.xsh new file mode 100755 index 0000000..66c792d --- /dev/null +++ b/build.xsh @@ -0,0 +1,22 @@ +#!/usr/bin/env xonsh + +# +# Build script is needed to create `build` directory with all files needed to run portable shell on the host +# + +import sys +from shutil import which + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + +script_dir = pf"{__file__}".absolute().parent +build_dir = script_dir / 'build' +rm -rf @(build_dir)/ +mkdir -p @(build_dir) +cd @(build_dir) + +if p'your_portable_shell'.exists(): + eprint('SKIP: Portable shell already builded') +else: + wget https://your_portable_shell \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..6a94c52 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Entrypoint script should be pure bash. +# + +# +# Support three arguments (this recommend but not required): +# -f Execute file on host, print the result and exit +# -c Execute command on host, print the result and exit +# -v Verbose mode to debug +# +while getopts f:c:v: option +do +case "${option}" +in +f) EXECUTE_FILE=${OPTARG};; +c) EXECUTE_COMMAND=${OPTARG};; +v) VERBOSE=${OPTARG};; +esac +done + +# +# Move to current directory +# +CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)" +cd $CURRENT_DIR + +# +# Run the portable shell +# +./your_portable_shell # $EXECUTE_FILE $EXECUTE_COMMAND $VERBOSE \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9fbcb6e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +xonsh \ No newline at end of file