Commit graph

266 commits

Author SHA1 Message Date
Spencer Bliven
7311cb9067
Callable Alias: Update documentation (#5524)
Reorders and updates the callable alias examples.

- Start with examples of valid return types first, then show uses for
different arguments
- Add example of using stdin (documents behavior from #5233)


<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->
(I don't think this PR is significant enough for a changelog item.)

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**
2024-06-29 12:49:57 +02:00
Andy Kipp
934351254a
docs: SpecModifierAlias to the tutorial (#5518)
Added SpecModifierAlias (#5443) to the tutorial.

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

---------

Co-authored-by: a <1@1.1>
2024-06-24 14:28:39 -04:00
Andy Kipp
63da8e3492
Tutorial: Callable alias and capturing (#5472)
<!---

Thanks for opening a PR on xonsh!

Please do this:

1. Include a news file with your PR
(https://xon.sh/devguide.html#changelog).
2. Add the documentation for your feature into `/docs`.
3. Add the example of usage or before-after behavior.
4. Mention the issue that this PR is addressing e.g. `#1234`.

-->

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

---------

Co-authored-by: a <1@1.1>
2024-06-10 09:42:00 -04:00
Andy Kipp
6245e460a6
Tutorial: micro about exec alias args (#5474)
Replaced too emotional warning.

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

Co-authored-by: a <1@1.1>
2024-06-01 22:35:25 +02:00
Andy Kipp
730fe45627
Added SpecModifierAlias and xthread, xunthread aliases (#5443)
### Motivation

* We have no recommended way to force subprocess command be
(un)threadable
  * #4214
  * #2119
  * #5003
* It's interesting opportunity to have a way to modify specs and CP
using `SpecModifierAlias`.

### Before

```xsh
!(ssh host -T "echo 1")
# output=''  # EXPECTED: 1

__xonsh__.commands_cache.threadable_predictors['ssh'] = lambda *a, **kw: True
!(ssh host -T "echo 1")
```


### After

```xsh
xthread
# Mark command as threadable.

!(xthread ssh host -T "echo 1")
# output='1'
```

Closes:
* Closes #4214
* Closes #2119
* Partially closes #5003

Implementation of `SpecModifierAlias` will help in:
* #2618

JFYI #5413 

## 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>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2024-05-28 11:03:45 -04:00
Andy Kipp
499bbf8161
Tutorial: add info about non-blocking !() (#5449)
Closes #3394

### Motivation

After reading [the history of threading and
operators](https://github.com/xonsh/xonsh/issues/5444) I realized that
this was intended, to make the `!()` operator non-blocking. So let's
write about this in tutorial.

### Next steps

In the future we need to solve these points:
* Confusion around `.output` and `.out`.
* Show good cases where non-blocking is doing perfect work to people. Or
remove the non-blocking functionality [to remove
threading](https://github.com/xonsh/xonsh/discussions/4710).

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

---------

Co-authored-by: a <1@1.1>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-28 10:51:22 -04:00
Andy Kipp
b55e6a4e3d
Tutorial: add note about rtn (#5447)
subj

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

---------

Co-authored-by: a <1@1.1>
2024-05-28 09:24:18 -04:00
Andy Kipp
4906ba8598
Update tutorial.rst: remove new line chars (#5382)
Update tutorial.rst
2024-05-02 18:01:06 +02: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
e1a93cef19
New prompt end character (#5063)
Co-authored-by: a <1@1.1>
2023-05-16 13:36:50 +00:00
Tobias Becker
d173ad7f3b
Add a warning to the docs about $args in ExecAlias (#5033) 2023-01-17 13:05:39 -05:00
Vasilis Gerakaris
1d61d8d711 Document that xonshrc files not applied on non-interactive mode 2022-10-20 03:20:33 +05:30
Noorhteen Raja NJ
cbf23e60fb
Pre commit ci (#4863) 2022-07-01 11:47:01 -04:00
Peter Ye
b2c42ed2f3
feat: f-glob strings (#4835)
* feat: add support for f-glob strings

Move xonsh_pathsearch() into the BaseParser class because it needs to use self._set_error()

Parametrize 6 backtick tests in test_parser.py into test_backtick() (and add cases for f-glob strings)

* add news

* docs: update tutorial

* fix news file
2022-06-12 13:45:16 +05:30
dev2718
e62c0e9cec
Returncode enhancements (#4798)
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2022-05-10 09:43:32 -04:00
Noorhteen Raja NJ
d49b164379
gitstatus modular (#4697) 2022-03-21 11:18:36 -04:00
E Pluribus Unum
6fc77f2fcb
do to following -> do the following (#4728)
* do to following -> do the following

very minor spelling correction

* Minor spelling corrections
2022-03-21 10:05:20 +05:30
Kyllingene
1889d3e2ea
Clarified use of time_format in docs (#4714)
* Added reference to ``PROMPT_FIELDS`` section in ``time_format`` definition

* Forgot the news item, added now

* Generalized reference to PROMPT_FIELDS
2022-03-15 08:17:16 +05:30
dev2718
1aefbf3b35
Fix: detype None env-vars to '' to fix #4600 (#4649)
* detype untyped and path env-vars to ""; path_to_str("") == None

* update env-var-tutorial, add news

* update test_expandvars, test_expand_path, test_register_custom_var_str

* trigger CI-rerun since unrelated osx test failed

Co-authored-by: Alexander Firbas <alexander.firbas@gmail.com>
2022-01-21 14:46:50 +05:30
Peter Ye
b74bdbcc72
docs: fix typo in prompt tutorial (#4335) 2021-06-22 19:49:54 +03:00
Andy Kipp
039ce96dcd
feat: Added ability to get arguments list in ExecAlias (#4201)
* black

* news

* test

* alias_argN

* ExecAlias docs

* note about merge operator

* $args

* docs

Co-authored-by: a <a@a.a>
2021-04-15 09:39:13 -04:00
Evgeny
3df1426f8e
Updated references to point to 'main' instead of 'master' (#4202)
* doc: update path to the most recent xonsh source code ('master' to 'main')

* doc: change 'master' to 'main' in some doc references
2021-03-30 13:40:43 -04:00
Andy Kipp
9618fa2a36
Added casting CommandPipeline to int, hash, str (#4205)
* cast

* test

* added tests and str

* news

* test

* skip windows

* docs

* docs

* tests

Co-authored-by: a <a@a.a>
2021-03-30 13:36:01 -04:00
Andy Kipp
38e1383b63
Update tutorial.rst (#4174)
Co-authored-by: a <a>
2021-03-16 13:52:11 -04:00
Nate Simon
c4e7843598
add disown command (#4090)
* add "disown" internal command
This command will remove jobs from the shell's job table, allowing the command
to continue running after the shell exits. Configuration options are provided
to manage how suspended background jobs are handled after being disowned.

* job-ctrl-disown code style update

* job-ctrl-disown style updates + change arg --cont to --continue

* Trim extra "=" in doc for "disown" cmd

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-02-09 10:54:17 -05:00
Daniel Shimon
97d076855b procs: Allow bytes objects in the @() operator 2020-11-06 18:33:27 +02:00
a
08adad5292 Merge branch 'master' of https://github.com/xonsh/xonsh into tutorial_subprocess_mode 2020-10-13 22:26:00 +03:00
a
7bd4daf17a text 2020-10-13 22:25:48 +03:00
a
8f43c99bde text 2020-10-13 22:23:14 +03:00
a
fb08e3f747 Removed "Register typed environment variables" 2020-10-08 00:01:46 +03:00
a
04df5c75ad env path 2020-10-07 19:22:02 +03:00
a
e50067aed7 If you still have concerns about the determination process... 2020-10-07 14:24:58 +03:00
a
a33310f9ab If you still have concerns about the determination process... 2020-10-07 14:15:00 +03:00
a
67033d3e33 docs 2020-10-06 22:26:15 +03:00
a
81c4f4c636 Merge branch 'master' of https://github.com/xonsh/xonsh into printx 2020-10-06 00:02:08 +03:00
Anthony Scopatz
b5a7439dca
Merge pull request #3830 from dannysepler/typos
Fix some typos in docs
2020-10-05 14:42:43 -05:00
Anthony Scopatz
97d0d0592a
Merge pull request #3831 from anki-code/tutorial_literal
Added "Advanced String Literals" to the "Tutorial".
2020-10-05 14:42:00 -05:00
a
9ed8c6b9e3 Advanced String Literals 2020-10-04 18:49:54 +03:00
a
d406fd2919 Advanced String Literals 2020-10-04 18:48:51 +03:00
a
fbeb3f18d4 Advanced String Literals 2020-10-04 18:47:12 +03:00
a
02be19096e Advanced String Literals 2020-10-04 18:39:51 +03:00
Danny Sepler
b59b0ceed2 Fix some typos 2020-10-03 23:02:39 -04:00
a
75d16233d0 printx 2020-10-01 04:08:34 +03:00
a
99ae3ff00d docs 2020-10-01 01:36:08 +03:00
cafehaine
1c7e841da0 Remove reference to NO_COLOR in docs 2020-09-26 15:11:43 +02:00
Eadaen1
50257a563e Update tutorial with cwd_dir changes. 2020-09-11 12:14:04 +01:00
Bob Hyman
59bb6b3b88 More getting started reorg 2020-08-24 04:46:25 -04:00
cafehaine
cb14ea9acd docs: More examples of what SubprocSpec can do 2020-08-02 09:30:22 +02: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
anki-code
cd6cf6433d
Path object allows do some tricks with paths 2020-02-23 19:42:32 +03:00