Paste and run commands from bash, zsh, fish in xonsh shell.
Project description
Paste and run commands from bash, zsh, fish in xonsh shell.
If you like the idea click ⭐ on the repo and stay tuned.
Install
xpip install -U xontrib-sh
echo 'xontrib load sh' >> ~/.xonshrc
# Reload xonsh
Usage
Start a line with an exclamation point — !
— then paste the sh-compatible commands
after it and run. The command syntax will be tested in installed shells (bash, zsh, fish, sh)
and the commands will be run in the first matching shell.
The commands will be executed in the environment that will be inherited from current but if the commands modify the environment there will no changes in source xonsh environment.
Note! The syntax checking is not determine the shell exactly right and pull requests are welcome! The short commands may be determined as bash commands but it's fish or zsh. As result the command will be failed. Use this carefully and if you know that you need only bash just remove the zsh and fish from the list as described below.
Use cases
The main use case
The main use case of xontrib-sh
is when you copy and paste the sh-commands from some article or instruction
and this commands are environment agnostic and you want to run it without rewriting it on xonsh or run sh-shell.
For example you've found xxh local snippet:
XH=~/.xxh \
&& XD=https://github.com/xxh/xxh-portable/raw/master/result/xxh-portable-musl-alpine-Linux-x86_64.tar.gz \
&& mkdir -p $XH && cd $XH \
&& ( [[ -x $(command -v curl) ]] && curl -L $XD || wget -O- $XD ) | tar zxf - xxh \
&& echo 'Usage: ./xxh local [+s xonsh/zsh/fish/osquery/bash]'
It's bash and it's environment agnostic and you hesitate how xonsh will execute this. Just start with !
and
paste this commands. As result you've installed xxh local
and stayed in xonsh.
One line: brace expansion (bash syntax)
! echo 01.{05..10}
bash:
01.05 01.06 01.07 01.08 01.09 01.10
Many lines: for loop (zsh syntax)
! for x (1 2 3); do
echo $x;
done
for x (4 5 6); do
echo $x;
done
zsh:
1
2
3
4
5
6
Set certain shell for any commands
$XONTRIB_SH_SHELLS = ['bash']
Credits
This package was created with xontrib cookiecutter template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for xontrib_sh-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebcaacb289c73473eae23ae406629a1b331c5be2208b6af0d361dc3750015611 |
|
MD5 | 77f0c1b4cf5d82a9fc74ba85059696ec |
|
BLAKE2b-256 | 8fa9233688894f0af594b14d3430fb27e87cf3f694579d66dbb20744974bb025 |