Commit graph

57 commits

Author SHA1 Message Date
Andy Kipp
c0e0687376
docs: Update bash to xonsh guide (#5628)
* update bash to xonsh

* Update bash_to_xsh.rst

* Update bash_to_xsh.rst

* Update docs/bash_to_xsh.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Update docs/bash_to_xsh.rst

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

---------

Co-authored-by: a <1@1.1>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-08-07 22:39:00 +02:00
Andy Kipp
aa69ce868a
Now last executed CommandPipeline is available in `__xonsh__.last` (#5422)
### Motivation

There is no way to access to the CommandPipeline of executed command in
uncaptured mode. This causes:
 * No chance to get return code in one universal way.
 * Barrier to trace and inspection.

### Before

```xsh
$(ls nofile)
# No way to access to the CommandPipeline of executed command.
```

### After
```xsh
$(ls nofile)
__xonsh__.last.rtn  # In interactive or not interactive.
# 2
```
```xsh
# Sugar sir:
last = type('LastCP', (object,), {'__getattr__':lambda self, name: getattr(__xonsh__.last, name) })()

ls nofile
last.rtn
# 2
```

JFYI #5342

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

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-22 09:25:35 -04:00
Andy Kipp
c5cb7044b5
feat: add subproc output format, autostrip singleline output (#5377)
### Motivation

* To have an ability to manage the output format added ``$XONSH_SUBPROC_OUTPUT_FORMAT`` to switch the way to return the output lines. Default ``stream_lines`` to return text. Alternative ``list_lines`` to return the list of lines. Also supported custom lambda function.
* Additionally the [proposal to change default behavior](https://github.com/xonsh/xonsh/pull/5377#discussion_r1587627131) for a single line case.
* Closes #3924 as soft solution.

### Before

```xsh
mkdir -p /tmp/tst && cd /tmp/tst && touch 1 2 3

$(ls)
# '1\n2\n3\n'

id $(whoami)
# id: ‘pc\n’: no such user: Invalid argument

du $(ls)
# du: cannot access '1'$'\n''2'$'\n''3'$'\n': No such file or directory

ls $(fzf)
# ls: cannot access 'FUNDING.yml'$'\n': No such file or directory
```

### After

```xsh
mkdir -p /tmp/tst && cd /tmp/tst && touch 1 2 3

$XONSH_SUBPROC_OUTPUT_FORMAT = 'list_lines'

$(ls)
# ['1', '2', '3']

[f for f in $(ls)]
# ['1', '2', '3']

id $(whoami)
# uid=501(user) gid=20(staff)

du $(ls)
# 0 1
# 0 2
# 0 3

ls $(fzf)
# FUNDING.yml

# etc
mkdir -p /tmp/@($(whoami))/dir
cat /etc/passwd | grep $(whoami)
```

### Notes

* It will be good to improve parser for cases like `mkdir -p /tmp/$(whoami)/dir`. PR is welcome!
* I named the default mode as `stream_lines` (instead of just `stream` or `raw`) because in fact we transform raw output into stream of lines and possibly reduce the length of output ([replacing `\r\n` to `\n`](c3a12b2a9c/xonsh/procs/pipelines.py (L380-L383))). May be some day we need to add raw "stream" output format.
* Now anybody can implement bash `IFS` behavior in [bashisms](https://github.com/xonsh/xontrib-bashisms).

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-02 11:48:25 -04:00
Andy Kipp
042487745a
Moving old xontribs to repositories (#5055)
* Update and rename README to README.rst

* Create hello_world.py

* Update README.rst

* init

* remove bashisms

* Transfer abbrevs to xontrib-abbrevs

* Transfer free-cwd to xontrib-free-cwd

* news

* black

* Transfer fish-completer to xonsh/xontrib-fish-completer

* Transfer vox to xonsh/xontrib-vox

* Transfer pdb, xog to xonsh/xontrib-debug-tools

* remove hello_world

* fix tests

* black

* fix whitespaces

* fix readme

* Update python_virtual_environments.rst

* Update README.rst

* Update xontribs_transfer.rst

---------

Co-authored-by: a <1@1.1>
2023-03-17 13:25:22 +06:00
Noorhteen Raja NJ
cbf23e60fb
Pre commit ci (#4863) 2022-07-01 11:47:01 -04:00
anki-code
c3c655dacf
A bit docs around subprocess strings for sh-ers (#4114)
* Update bash_to_xsh.rst

* Update bash_to_xsh.rst
2021-02-22 10:28:36 -05:00
anki-code
5e19f46a2c
Get PID of the current shell. 2020-10-15 19:47:48 +03:00
Will Shanks
b787a6a396 Document variable escaping in bash_to_xonsh 2020-10-13 12:26:03 -04:00
a
e529709542 text 2020-10-10 21:20:21 +03:00
a
d7ee5244ab text 2020-10-10 20:53:55 +03:00
a
c0914dca93 text 2020-10-10 19:55:45 +03:00
a
74fc38e8aa docs 2020-10-10 03:29:33 +03:00
a
972cfde3b7 docs 2020-10-10 03:28:17 +03:00
a
3dfdd4414b typo 2020-10-06 00:15:20 +03:00
a
249c7042e8 awesome example in bash to xonsh 2020-10-06 00:09:12 +03:00
a
99ae3ff00d docs 2020-10-01 01:36:08 +03:00
a
b618e1ffb3 Bash to xonsh 2020-09-25 10:27:14 +03:00
a
56b1dda6df Bash to xonsh 2020-09-25 10:20:04 +03:00
a
40a95a65ac Bash to xonsh 2020-09-25 10:14:23 +03:00
a
9eef76fcad bash2xonsh 2020-09-25 03:31:30 +03:00
a
1f67c7c80d bash2xonsh 2020-09-25 03:24:03 +03:00
a
2c7f09a29b bash2xonsh 2020-09-25 03:14:12 +03:00
a
32b3688057 bash2xonsh 2020-09-25 03:13:43 +03:00
a
6c3f2a5865 bash2xonsh 2020-09-25 03:11:50 +03:00
a
c7b36f2019 bash2xonsh 2020-09-25 03:04:40 +03:00
a
5d9c64d853 bash2xonsh 2020-09-25 02:57:41 +03:00
a
12cda5f148 bash2xonsh 2020-09-25 02:50:22 +03:00
a
48e16455b8 new 2020-09-25 00:16:49 +03:00
a
033c8c6009 new 2020-09-25 00:15:55 +03:00
a
30bfe190c2 new 2020-09-24 23:42:39 +03:00
a
588b1b7b52 docs 2020-09-24 23:39:36 +03:00
David Strobach
3f56956984 Update docs 2020-09-05 17:35:23 +02:00
anki-code
37c1828bfc bash2xsh improvements 2020-05-27 09:31:44 +03:00
anki-code
30cd46511c exit 2020-05-12 19:10:13 +03:00
anki-code
40af9b197a exit 2020-05-12 17:37:15 +03:00
anki-code
e1e7d27081
Add $XONSH_TRACE_SUBPROC to the tutorial (#3540)
* New xontrib-output-search

* $XONSH_TRACE_SUBPROC in the tutorial #3539

* $XONSH_TRACE_SUBPROC in the tutorial #3539

* news

* trace alternative

Co-authored-by: anki-code <anki-code>
2020-04-30 20:18:28 -04:00
anatoly techtonik
b39922de35
Document file extensions and sheband
Fixes #2990
2019-01-29 13:44:49 +03:00
halloleo
d886143ef0 Doco about how to update xonsh
* Doco about how to update xonsh
* Doco how to set and unset environment variables
2018-12-19 00:07:20 +11:00
David Dotson
1d60f9397b Updated docs with __xonsh__ changes 2018-09-30 13:59:08 -07:00
Andrew Hundt
3f6a780b5e bash_to_xsh.rst add command line args to table 2017-10-09 12:09:29 -04:00
Joel Gerber
12e2fb80cc
Documentation spelling corrections
A number of common spelling typos found within various restructuredText
files have been identified and resolved.
2017-06-07 11:51:06 -04:00
laerus
c2b7e50d45 history tutorial and a bug fix 2016-09-02 13:33:45 +03:00
Konstantinos Tsakiltzidis
fda85042f4 Update bash_to_xsh.rst 2016-06-21 00:32:22 +03:00
Konstantinos Tsakiltzidis
d3c035ec1d Update bash_to_xsh.rst 2016-06-21 00:30:15 +03:00
Konstantinos Tsakiltzidis
3a09dcd8b8 Update bash_to_xsh.rst 2016-06-21 00:27:55 +03:00
Konstantinos Tsakiltzidis
795189e842 'extra info' 2016-06-20 23:33:58 +03:00
Konstantinos Tsakiltzidis
f362469940 bash equivalent of setting envvar for a cmd 2016-06-20 21:40:10 +03:00
laerus
4336b01d10 'updates instruction about the retrieval of the return code of last command' 2016-06-17 14:08:58 +03:00
adam j hartz
7cc777a066 update bash to xonsh guide 2016-06-07 23:19:31 -04:00
Ryan Gonzalez
418b863f82 Mention how to mix commands and variables/text 2016-06-04 17:20:06 -05:00