This commit is contained in:
anki-code 2020-03-06 13:50:56 +03:00
parent 589efb830a
commit 7baaf6898b
4 changed files with 70 additions and 0 deletions

16
README.md Normal file
View File

@ -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).

22
build.xsh Executable file
View File

@ -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

31
entrypoint.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
#
# Entrypoint script should be pure bash.
#
#
# Support three arguments (this recommend but not required):
# -f <file> Execute file on host, print the result and exit
# -c <command> 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

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
xonsh