Giter VIP home page Giter VIP logo

xxh-shell-xonsh's Introduction

The xonsh shell entrypoint for xxh. Use xonsh wherever you go through the SSH without installation on the host.

If you like the idea click โญ on the repo and tweet.

Install

Install from xxh repo:

xxh +I xxh-shell-xonsh
# or from repo: xxh +I xxh-shell-xonsh+git+https://github.com/xxh/xxh-shell-xonsh

Connect

xxh yourhost +s xonsh +if

To avoid adding +s every time use xxh config in ~/.config/xxh/config.xxhc ($XDG_CONFIG_HOME):

hosts:
  ".*":                     # Regex for all hosts
    +s: xonsh

Using python, pip and xontribs

The xonsh.AppImage has python and pip by default. You can update pip and install packages and xontribs ordinarily:

myhost> pip install -U pip
myhost> pip install pandas
myhost> xpip install xontrib-prompt-bar

Packages location comply with hermetic principle:

xxh command pip packages home user home
xxh myhost /home/user/.xxh/.local /home/user/.xxh
xxh myhost +hhh '~' /home/user/.xxh/.local /home/user
xxh myhost +hhh '~' +hhx '~' /home/user/.local /home/user

Note! That packages will be installed in user directory by default i.e. ~/.local. If you're using package manager (e.g. mamba, conda) set $PYTHONNOUSERSITE=1 (doc) after virtual environment activation.

Plugins

xonsh xxh plugin is the set of xsh 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.

Pinned xxh xonsh plugins: autojump.

๐Ÿ”Ž Search xxh plugins on Github or Bitbucket or ๐Ÿ’ก Create xxh plugin

Seamless mode

Add environment variables to env file and bring them to the host using source command:

source xxh.xsh myhost

Alpine Linux

Thanks

xxh-shell-xonsh's People

Contributors

anki-code avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xxh-shell-xonsh's Issues

Windows WSL1 ^Z

When you try to run xxh on Windows with WSL1 you could see:

# xxh YT-1300
^Z

This issue was addressed to Xonsh team in 3367. Just try to run command again.

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Can't load installed xontrib

Local OS (where xxh is installed): macos
Destination host OS: ubuntu 18.04
xxh version:
xxh-plugins installed:

Steps to Reproduce
Whenever I try to run my own .xonshrc, and load some xontribs I always get an error that they're not installed:

$ xxh euclid
The following xontribs are enabled but not installed: 
   autojump
To install them run 
    xpip install xontrib-autojump

$ xpip install xontrib-autojump
$ logout
$ xxh euclid
$ The following xontribs are enabled but not installed: 
   autojump
To install them run 
    xpip install xontrib-autojump

It seems that wherever the packages are being installed to, it doesn't get source upon login.

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

xonsh appimage is an html string

Local OS (where xxh is installed): MacOS 10.14.6
Destination host OS: CentOS 7
xxh version: โฏ xxh --version
xxh-xxh/0.4.4

xxh-plugins installed: None

Steps to Reproduce

  1. I run xxh etld, etld is the name of the host I want to xxh into
  2. The output log:
โฏ xxh etld
etld:/home/jasony/.xxh not found. Install xxh? [Y/n] y
Install xxh to etld:/home/jasony/.xxh
Upload using rsync
            457 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)
          3,230 100%   28.08kB/s    0:00:00 (xfr#3, to-chk=0/4)
First run xonsh on etld
./xonsh: line 1: syntax error near unexpected token `<'
./xonsh: line 1: `<html><body>You are being <a href="https://github-production-release-asset-2e65be.s3.amazonaws.com/190451180/24306380-60cb-11ea-908f-3bc05f834509?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200309%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20200309T173439Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=b350321fae301bc2c57d1c3851e6321a7522bc4738e4237b8e04319afc0e5e8f&amp;X-Amz-SignedHeaders=host&amp;actor_id=0&amp;response-content-disposition=attachment%3B%20filename%3Dxonsh-x86_64.AppImage&amp;response-content-type=application%2Foctet-stream">redirected</a>.</body></html>'

  1. What is the problem

Looks like the contents of the xonsh script on the remote host I'm trying to ssh into. And the installation fails when that script is trying to be run.
For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Using xxh after xxh

> xxh host +s xxh-shell-xonsh-appimage
$ pip install --upgrade pip

$ pip install pandas
$ import pandas
$ # good

But:

$ pip install xxh-xxh                                                                                                                                                                                                               
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 2:
   command: /tmp/.mount_xonshb8hyNU/usr/python/bin/python /home/ubuntu/.xxh/pip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-0hoqobgh/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (20 lines):
  Collecting setuptools>=40.8.0
    Using cached setuptools-46.0.0-py3-none-any.whl (582 kB)
  Collecting wheel
    Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
  Installing collected packages: setuptools, wheel
  ERROR: Exception:
  Traceback (most recent call last):
    File "/home/ubuntu/.xxh/pip/pip/_internal/cli/base_command.py", line 186, in _main
      status = self.run(options, args)
    File "/home/ubuntu/.xxh/pip/pip/_internal/commands/install.py", line 395, in run
      installed = install_given_reqs(
    File "/home/ubuntu/.xxh/pip/pip/_internal/req/__init__.py", line 67, in install_given_reqs
      requirement.install(
    File "/home/ubuntu/.xxh/pip/pip/_internal/req/req_install.py", line 781, in install
      scheme = get_scheme(
    File "/home/ubuntu/.xxh/pip/pip/_internal/locations.py", line 185, in get_scheme
      scheme = distutils_scheme(
    File "/home/ubuntu/.xxh/pip/pip/_internal/locations.py", line 118, in distutils_scheme
      assert not (home and prefix), "home={} prefix={}".format(home, prefix)
  AssertionError: home=/tmp/pip-target-gfhcplhq prefix=/tmp/pip-build-env-0hoqobgh/overlay
  ----------------------------------------
ERROR: Command errored out with exit status 2: /tmp/.mount_xonshb8hyNU/usr/python/bin/python /home/ubuntu/.xxh/pip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-0hoqobgh/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

AttributeError: 'XonshSession' object has no attribute 'env'

Traceback (most recent call last):
....
  File "/tmp/.mount_xonshS434io/usr/python/lib/python3.8/site-packages/xonsh/environ.py", line 386, in style_name
    env = builtins.__xonsh__.env
AttributeError: 'XonshSession' object has no attribute 'env'
Xonsh encountered an issue during launch
Failback to /bin/sh
$ 

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Xonsh: bash: python3.10: No such file or directory

Local OS (where xxh is installed):
EndavourOS 6.0.10-arch2-1
Destination host OS:
Debian 11.5
xxh version:
xxh/0.8.11
xxh-plugins installed:
none

Steps to Reproduce

  1. I run xxh ruud@docker-02 +s xonsh +v
  2. The output log:
Load xxh config from /home/ruud/.config/xxh/config.xxhc
ssh arguments: ['-o', 'StrictHostKeyChecking=accept-new', '-o', 'User=ruud']
ruud@docker-02's password: 
Pexpect result:
{'user_host_accept': None, 'user_host_password': '*********', 'user_key_password': None, 'output': 'xxh_home_realpath=/home/ruud/.xxh\r\nxxh_version=0.8.11\r\nxxh_shell_exists=1\r\nxxh_home_writable=1\r\nxxh_parent_home_writable=1\r\nrsync=\r\nscp=/usr/bin/scp\r\nshell=\r\nkernel=Linux\r\narch=x86_64\r\n'}
Host info:
xxh_home_realpath=/home/ruud/.xxh
xxh_version=0.8.11
xxh_shell_exists=1
xxh_home_writable=1
xxh_parent_home_writable=1
rsync=
scp=/usr/bin/scp
shell=
kernel=Linux
arch=x86_64

bash: /home/ruud/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/usr/bin/usr/bin/python3.10: No such file or directory
Connection to docker-02 closed.
  1. What is the problem
    The python3.10 file is not found when trying to use xonsh shell. With fish shell everything works fine. The part /usr/bin inside /usr/bin does not exists. Is the path wrong or are the files missing?

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

AppImage GLIBs versions

Current method to make xonsh portable is using an AppImage which was built on manylinux2010 (PEP 571). In case you see the error like /xonsh-x86_64.AppImage: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.25 not found (required by /ppp/xonsh-x86_64.AppImage) this means you should rebuild the AppImage for older version of linux distributive. Try linuxdeploy-plugin-python.

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Raspbian Buster on RaspberryPi 4: ./xonsh: cannot execute binary file: Exec format error

Local OS (where xxh is installed): macOS 10.15
Destination host OS: Raspbian Buster
xxh version: 0.8.6
xxh-plugins installed: None (unless homebrew installs them)

Steps to Reproduce

I'm brand new to xxh. Attempting to connect for the first time:

~ $ xxh katsushiro +s xonsh
Create sample config file in /Users/jaraco/.config/xxh/config.xxhc
katsushiro:/home/jaraco/.xxh/.xxh/shells/xxh-shell-xonsh not found. Install xxh-shell-xonsh? [Y/n] 
Install xxh-shell-xonsh to katsushiro:/home/jaraco/.xxh
Install xxh-shell-xonsh to local /Users/jaraco/.xxh/.xxh/shells/xxh-shell-xonsh
Git clone https://github.com/xxh/xxh-shell-xonsh
Build xxh-shell-xonsh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   645  100   645    0     0   2179      0 --:--:-- --:--:-- --:--:--  2171
100 24.9M  100 24.9M    0     0  2038k      0  0:00:12  0:00:12 --:--:-- 3106k
Installed /Users/jaraco/.xxh/.xxh/shells/xxh-shell-xonsh
First time upload using rsync (this will be omitted on the next connections)
First run xxh-shell-xonsh on katsushiro
bash: ./xonsh: cannot execute binary file: Exec format error
mv: cannot stat 'squashfs-root': No such file or directory
ln: failed to create symbolic link 'xonsh': File exists
bash: /home/jaraco/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh: cannot execute binary file: Exec format error

I'd previously used xonsh on the target host using pipx and chsh, so there is a xonsh install at ~/.local/bin/xonsh. The user's shell is set to /bin/bash.

I'm on Raspbian Buster on RaspberryPi 4 (ARM).

Suggestions?

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Ubuntu1404: ModuleNotFoundError: No module named 'math'

Local OS (where xxh is installed): Arch linux
Destination host OS: Ubuntu1404
xxh version: xxh/0.8.6
xxh-plugins installed: xxh-shell-xonsh

Steps to Reproduce

  1. bring up the machine with the following Vagrantfile
directory=$(mktemp -d)
cd $directory
wget https://gist.githubusercontent.com/grg121/4c5b060fab2f1de83043f2d69cf419bb/raw/1f5cffc6f2336ec753729493dd2efbf7906a172d/gistfile1.txt -O Vagrantfile
vagrant up ub1404
xxh +if +s xonsh [email protected]
  1. The output log:
โฏ xxh +if +s xonsh [email protected]
[email protected]'s password: 
Install xxh-shell-xonsh to 192.168.56.69:/home/vagrant/.xxh
Remove 192.168.56.69:/home/vagrant/.xxh/.xxh
First time upload using rsync (this will be omitted on the next connections)
First run xxh-shell-xonsh on 192.168.56.69
Traceback (most recent call last):
  File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh", line 6, in <module>
    from xonsh.main import main
  File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/opt/python3.8/lib/python3.8/site-packages/xonsh/main.py", line 13, in <module>
    from xonsh.timings import setup_timings
  File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/opt/python3.8/lib/python3.8/site-packages/xonsh/timings.py", line 13, in <module>
    import math
ModuleNotFoundError: No module named 'math'
  1. What is the problem

Hello there, I'm facing an issue with xxh which I could not understand. I'm trying to connect to different hosts running in virtual machines using vagrant. One with ubuntu14 and the other with centos7. While the second one works as expected, the ubuntu gives me the described problem.

I don't understand why python is complaining about math module, the Xonsh appimage is supposed to use his own Python3.8 with all the required modules, isn't it? Then, why it doesn't find math? Maybe I am not understanding something here.

I've tried downloading the app image from Xonsh manually and it runs good, so I think there must be a problem with the build script or something, nevertheless I don't understand why Xonsh is trying to look for math package without sucess.

What is more, if I run:

vagrant@metasploitable3-ub1404:~$ which python
/usr/bin/python
vagrant@metasploitable3-ub1404:~$ /usr/bin/python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math

It seems that the default system python does have math module installed. So the problem must be with the one used by Xonsh.

I'm trying to find the cause and open this issue to write it down and in case someone could explain to me how is this Xonsh portable shell running and which Python is actually using.

Best regards.

For the community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Support xonsh rc.d

Is your feature request related to a problem? Please describe.
I use rc config pattern as you can see in my dotfiles. xxh install does not copy it:

$ xxh dickbag +s xonsh +if
Install xxh-shell-xonsh to dickbag:/home/ryan/.xxh
Remove dickbag:/home/ryan/.xxh/.xxh
First time upload using scp (this will be omitted on the next connections).
Note: you can install rsync on local and remote host to increase speed.
xonshrc.xsh                                                                                                                   100% 2039    53.9KB/s   00:00
xonsh                                                                                                                         100%   25MB   9.5MB/s   00:02
entrypoint.sh                                                                                                                 100% 3872   127.2KB/s   00:00

Describe the solution you'd like
xxh +i should bring everything in ~/.config/xonsh.

Describe alternatives you've considered
I can do it manually, but that defeats the purpose of xxh +i.

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

python no such file or directory

Local OS (where xxh is installed): Arch
Destination host OS: Some kind of newer Linux (not under my control)
xxh version: 0.8.10
xxh-plugins installed: Unsure

Steps to Reproduce
With a fresh xxh install using

pip install xxh-xxh I get the following error trying to connect to a remote host:

bash: /home/mehrlich/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/usr/bin/usr/bin/python3.10: No such file or directory

Somehow xxh is coming up with a weird path for python, note the repeated /usr/bin: .../usr/bin/usr/bin/python3.10

I can confirm that the remote host has /usr/bin/python3.10 under the .xxh directory but of course not /usr/bin/usr

using zsh works so I think this is specific to the xonsh plugin

For community:
โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Allow switch to host python

If the host has python and tools that use it it will be good to switch from xonsh python to host`s python for using the tools.

โฌ‡๏ธ Please click the ๐Ÿ‘ reaction instead of leaving a +1 or ๐Ÿ‘ comment

Both xpip and pip fail to run

>>> cd ~/.xxh                                                                                                                                                         
>>> xpip install xonsh-vox-tabcomplete                                                                                                                                             
usage: -c [-h] [-V] [-c COMMAND] [-i] [-l] [--config-path CONFIG_PATH] [--rc RC [RC ...]] [--no-rc] [--no-script-cache] [--cache-everything] [-D ITEM]
          [--shell-type {b,best,d,dumb,ptk,ptk1,ptk2,prompt-toolkit,prompt_toolkit,prompt-toolkit1,prompt-toolkit2,rand,random,rl,readline}] [--timings]
          [script-file] ...
-c: error: unrecognized arguments: -m

Any idea what I'm doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.