xxh / xxh-shell-fish

Use the fish shell wherever you go through the SSH without installation on the host.
BSD 2-Clause "Simplified" License
18 stars 12 forks source link

xxh.fish seamless mode script #8

Open anki-code opened 4 years ago

anki-code commented 4 years ago

Examples to start:

For community: ⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

anki-code commented 4 years ago

@frederickjh could you please create xxh.fish file for seamless mode?

frederickjh commented 4 years ago

I am not sure I totally understand seamless mode. I have read the description and looked at the files for the other shells.

What all needs to be moved to the remote host or configured in the file xxh.fish for seamless mode?

anki-code commented 4 years ago

In short: seamless mode script just get environment variables which described in env files in plugins and add it as base64 encoded +heb arguments to xxh. For example if you have fish theme with FISH_THEME environment variable you can create xxh plugin for your theme ans add FISH_THEME to env file. When you run source xxh.fish the FISH_THEME variable will be on host and you will be in your lovely theme.

What seamless mode script do:

  1. Find env file in the plugins
  2. Get the environment variable names from env file
  3. Create the variable init code in fish syntax and encode to base64
  4. Create bash export code (it should be bash for all shells) for variable with name <plugin_name>_EXE_<variable)_name>
  5. base64 encode this export code
  6. Add +heb argument
  7. Run xxh with +heb arguments

I think the main question here is step 3 because bash command declare -p <variable> returns valid bash code to create <variable>. I don't know the analog in fish. In fact we should get the variable and create the fish code to init it with saving the type of variable. For example for xonsh I used repr function.

  1. And the final step is to read environment variables on the host and eval the code.

The description is looks tricky :) I understand if you haven't enough time and you don't need this I will not force you )

Here is the seamless mode demo for bash - https://asciinema.org/a/314508

frederickjh commented 4 years ago

:ok_hand: I still don't understand all that but I did understand what you are missing.

I think that the Fish shell equivalent to declare -p is set . Just running set will list all variables. Running set -S shows information about the variables. I don't see one command that does this all together.

anki-code commented 4 years ago

It's helpful! Thanks!