├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── LICENSE ├── README.md ├── build.sh ├── entrypoint.sh ├── requirements.txt └── xxh-config.fish /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | 2 | # These are supported funding model platforms 3 | 4 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 5 | #patreon: xonssh # Replace with a single Patreon username 6 | #open_collective: # Replace with a single Open Collective username 7 | #ko_fi: # Replace with a single Ko-fi username 8 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 9 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 10 | #liberapay: # Replace with a single Liberapay username 11 | #issuehunt: # Replace with a single IssueHunt username 12 | #otechie: # Replace with a single Otechie username 13 | custom: ['https://github.com/anki-code', 'https://www.buymeacoffee.com/xxh', 'https://github.com/xonsh/xonsh#the-xonsh-shell-community'] 14 | 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Local OS (where xxh is installed):** 11 | **Destination host OS:** 12 | **xxh version:** 13 | **xxh-plugins installed:** 14 | 15 | **Steps to Reproduce** 16 | 1. I run `xxh ... +v` 17 | 2. The output log: 18 | 3. What is the problem 19 | 20 | **For community:** 21 | ⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍 comment** 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020, xxh 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | xxh entrypoint for fish-portable - statically-linked portable fish. 3 |

4 | 5 |

6 | If you like the idea of xxh click ⭐ on the repo and tweet. 7 |

8 | 9 | ## Install 10 | Install from xxh repo: 11 | ``` 12 | xxh +I xxh-shell-fish 13 | ``` 14 | Install from any repo: 15 | ``` 16 | xxh +I xxh-shell-fish+git+https://github.com/xxh/xxh-shell-fish 17 | ``` 18 | Connect: 19 | ``` 20 | xxh myhost +s fish 21 | ``` 22 | To avoid adding `+s` every time use xxh config in `~/.config/xxh/config.xxhc` (`$XDG_CONFIG_HOME`): 23 | ``` 24 | hosts: 25 | ".*": # Regex for all hosts 26 | +s: fish 27 | ``` 28 | 29 | ## Plugins 30 | 31 | **fish xxh plugin** is the set of fish scripts which will be run when you'll use xxh. You can create xxh plugin with your lovely aliases, tools or color theme and xxh will bring them to your ssh sessions. 32 | 33 | 🔎 [Search xxh plugins on Github](https://github.com/search?q=xxh-plugin-fish&type=Repositories) or [Bitbucket](https://bitbucket.org/repo/all?name=xxh-plugin-fish) or 💡 [Create xxh plugin](https://github.com/xxh/xxh-plugin-fish-example) 34 | 35 | ## Thanks 36 | * **Frederick Henderson** for plugins support 37 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CDIR="$(cd "$(dirname "$0")" && pwd)" 4 | build_dir=$CDIR/build 5 | 6 | while getopts A:K:q option 7 | do 8 | case "${option}" 9 | in 10 | q) QUIET=1;; 11 | A) ARCH=${OPTARG};; 12 | K) KERNEL=${OPTARG};; 13 | esac 14 | done 15 | 16 | rm -rf $build_dir 17 | mkdir -p $build_dir 18 | 19 | for f in entrypoint.sh xxh-config.fish 20 | do 21 | cp $CDIR/$f $build_dir/ 22 | done 23 | 24 | url='https://github.com/xxh/fish-portable/releases/download/3.4.1/fish-portable-musl-alpine-Linux-x86_64.tar.gz' 25 | tarname=`basename $url` 26 | 27 | cd $build_dir 28 | 29 | [ $QUIET ] && arg_q='-q' || arg_q='' 30 | [ $QUIET ] && arg_s='-s' || arg_s='' 31 | [ $QUIET ] && arg_progress='' || arg_progress='--show-progress' 32 | 33 | if [ -x "$(command -v wget)" ]; then 34 | wget $arg_q $arg_progress $url -O $tarname 35 | elif [ -x "$(command -v curl)" ]; then 36 | curl $arg_s -L $url -o $tarname 37 | else 38 | echo Install wget or curl 39 | fi 40 | 41 | mkdir fish-portable 42 | tar -xzf $tarname -C fish-portable 43 | rm $tarname 44 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Support arguments (this recommend but not required): 5 | # -f Execute file on host, print the result and exit 6 | # -c [Not recommended to use] Execute command on host, print the result and exit 7 | # -C Execute command on host, print the result and exit 8 | # -v Verbose mode: 1 - verbose, 2 - super verbose 9 | # -e -e ... Environement variables (B64 is base64 encoded string) 10 | # -b -b ... Base64 encoded bash command 11 | # -H HOME path. Will be $HOME on the host. 12 | # -X XDG_* path (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) 13 | # 14 | 15 | while getopts f:c:C:v:e:b:H:X: option 16 | do 17 | case "${option}" 18 | in 19 | f) EXECUTE_FILE=${OPTARG};; 20 | c) EXECUTE_COMMAND=${OPTARG};; 21 | C) EXECUTE_COMMAND_B64=${OPTARG};; 22 | v) VERBOSE=${OPTARG};; 23 | e) ENV+=("$OPTARG");; 24 | b) EBASH+=("$OPTARG");; 25 | H) HOMEPATH=${OPTARG};; 26 | X) XDGPATH=${OPTARG};; 27 | *) echo "Unknown option: ${option}";; 28 | esac 29 | done 30 | 31 | # Set Verbosity Level based on xxh +v option 32 | if [[ $VERBOSE != '' ]]; then 33 | export XXH_VERBOSE=$VERBOSE 34 | fi 35 | 36 | # Handle -c and -C options for commands 37 | # EXECUTE_COMMAND_ARRAY is required due to different types (string/array) 38 | if [[ $EXECUTE_COMMAND ]]; then 39 | if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then 40 | echo "Execute command: $EXECUTE_COMMAND" 41 | fi 42 | 43 | EXECUTE_COMMAND_ARRAY=(-c "${EXECUTE_COMMAND}") 44 | fi 45 | 46 | if [[ $EXECUTE_COMMAND_B64 ]]; then 47 | EXECUTE_COMMAND=$(echo "$EXECUTE_COMMAND_B64" | base64 -d) 48 | if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then 49 | echo "Execute command base64: $EXECUTE_COMMAND_B64" 50 | echo "Execute command: $EXECUTE_COMMAND" 51 | fi 52 | 53 | EXECUTE_COMMAND_ARRAY=(-c "${EXECUTE_COMMAND}") 54 | fi 55 | 56 | # If a filename is provided, clear the previous set command 57 | if [[ $EXECUTE_FILE ]]; then 58 | unset EXECUTE_COMMAND_ARRAY 59 | fi 60 | 61 | # Handle -e options for environement variables 62 | for env in "${ENV[@]}"; do 63 | # If the env does not look like name=val, let's skip it 64 | if [[ $env != *"="* ]]; then 65 | continue 66 | fi 67 | 68 | name="$( cut -d '=' -f 1 <<< "$env" )"; 69 | val="$( cut -d '=' -f 2- <<< "$env" )"; 70 | val=$(echo "$val" | base64 -d) 71 | 72 | if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then 73 | echo "Entrypoint env: raw=$env, name=$name, value=$val" 74 | fi 75 | 76 | export "$name"="$val" 77 | done 78 | 79 | # Handle -b options for bash commands 80 | for eb in "${EBASH[@]}"; do 81 | bash_command=$(echo "$eb" | base64 -d) 82 | 83 | if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then 84 | echo "Entrypoint bash execute: $bash_command" 85 | fi 86 | eval "$bash_command" 87 | done 88 | 89 | # Where are we? 90 | CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)" 91 | cd "$CURRENT_DIR" || exit 92 | 93 | fish_bin=$CURRENT_DIR/fish-portable/bin/fish.sh 94 | 95 | # Check 96 | if [[ ! -f .entrypoint-check-done ]]; then 97 | check_result=$($fish_bin --version 2>&1) 98 | if [[ $check_result != *"fish"* ]]; then 99 | echo "Something went wrong while running fish on host:" 100 | echo "$check_result" 101 | else 102 | echo "$check_result" > .entrypoint-check-done 103 | fi 104 | fi 105 | 106 | XXH_HOME=$(readlink -f "$CURRENT_DIR"/../../../..) 107 | export XXH_HOME 108 | 109 | export PATH=$CURRENT_DIR/fish-portable/bin:$PATH 110 | export USER_HOME=$HOME 111 | 112 | if [[ $HOMEPATH != '' ]]; then 113 | homerealpath=$HOMEPATH 114 | if [[ -d $homerealpath ]]; then 115 | export HOME=$homerealpath 116 | else 117 | echo "Home path not found: $homerealpath" 118 | echo "Set HOME to $XXH_HOME" 119 | export HOME=$XXH_HOME 120 | fi 121 | else 122 | export HOME=$XXH_HOME 123 | fi 124 | 125 | if [[ $XDGPATH != '' ]]; then 126 | xdgrealpath=$(readlink -f "$XDGPATH") 127 | if [[ ! -d $xdgrealpath ]]; then 128 | echo "XDG path not found: $xdgrealpath" 129 | echo "Set XDG path to $XXH_HOME" 130 | export XDGPATH=$XXH_HOME 131 | fi 132 | else 133 | export XDGPATH=$XXH_HOME 134 | fi 135 | 136 | export XXH_SHELL=fish 137 | export XDG_CONFIG_HOME=$XDGPATH/.config 138 | export XDG_DATA_HOME=$XDGPATH/.local/share 139 | export XDG_CACHE_HOME=$XDGPATH/.cache 140 | export TMPDIR=$XDG_CACHE_HOME/tmp 141 | export TEMP=$TMPDIR 142 | mkdir -p $TMPDIR 143 | 144 | if [ -x "$(command -v getent)" ]; then 145 | XAUTHORITY=$( getent passwd 2>/dev/null | grep -m 1 -E "^$USER\:.*" | cut -d ":" -f 6 )/.Xauthority 146 | export XAUTHORITY 147 | else 148 | export XAUTHORITY=$USER_HOME/.Xauthority 149 | fi 150 | 151 | for pluginrc_file in $(find "$CURRENT_DIR"/../../../plugins/xxh-plugin-*/build -type f -name '*prerun.sh' -printf '%f\t%p\n' 2>/dev/null | sort -k1 | cut -f2); do 152 | if [[ -f $pluginrc_file ]]; then 153 | if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then 154 | echo "Load plugin $pluginrc_file" 155 | fi 156 | #cd $(dirname $pluginrc_file) 157 | source "$pluginrc_file" 158 | fi 159 | done 160 | 161 | cd "$HOME" || exit 162 | $fish_bin --interactive --init-command="source $XXH_HOME/.xxh/shells/xxh-shell-fish/build/xxh-config.fish" "${EXECUTE_COMMAND_ARRAY[@]}" $EXECUTE_FILE 163 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | xxh-xxh 2 | -------------------------------------------------------------------------------- /xxh-config.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # xxh Fish Shell configuration file that loads xxh plugins. 3 | set -U fish_greeting "" 4 | set CURRENT_DIR (dirname (realpath (status current-filename))) 5 | 6 | set -l dirs $CURRENT_DIR/../../../plugins/*/build 7 | for pluginrc_file in (find $dirs -type f -name '*pluginrc.fish' -printf '%f\t%p\n' 2>/dev/null | sort -k1 | cut -f2) 8 | if test -f $pluginrc_file 9 | set plugin_name (basename (dirname (dirname $pluginrc_file))) 10 | 11 | # Load plugin 12 | if test "$XXH_VERBOSE" = "1" -o "$XXH_VERBOSE" = "2" 13 | echo Load plugin $pluginrc_file 14 | end 15 | source $pluginrc_file 16 | end 17 | end 18 | 19 | cd ~ 20 | --------------------------------------------------------------------------------