Commit graph

1767 commits

Author SHA1 Message Date
jfmontanaro
a33ccdf636
Implement history pull for JSON history backend (#5788)
* add --session-id option to `history pull` command

* implement `history pull` for JSON history

* add news item for `history pull` updates

* add documentation for history pull `--session-id` option

* add explanatory comment for sleep in test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update json-history-pull.rst

* fix failing tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2025-02-03 22:34:19 +06:00
jfmontanaro
77ecefff34
Fix PTK shell sometimes not updating auto-suggest when up-arrow is pressed (#5787)
* fix combining consecutive history entries when loading ptk shell

* add test case for combining history items

* add news item for PTK history combining

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update ptk-history-combining.rst

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2025-01-31 21:40:43 +06:00
jfmontanaro
2cdcd6c976
Forward SIGHUP to child processes and process SystemExit more carefully (#5786)
* propagate SIGHUP to child processes

* do not wait for active job if shell is exiting

* move on_postcommand event out of _append_history and document behavior

* add changelog

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update built_ins.py

* Update hup-propagation.rst

* use sys.exc_info instead of sys.exception for version compatibility

* update test_default_append_history to work with new history/postcommand interaction

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add tests for SIGHUP forwarding and postcommand blocking

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix linting errors in news entry

* use tmpdir fixture in sighup tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_integrations.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2025-01-30 17:06:50 +06:00
Artur Manuel
0292b43e64
feat(environ): allow XONSH_*_DIR to be configurable (#5783)
* feat(environ): allow XONSH_*_DIR to be configurable

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test(env): add env var test

* fix(test): move test to test_environ

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_environ.py

* Update configurable-xonsh-dirs.rst

---------

Co-authored-by: Artur Manuel <balkenix@outlook.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2025-01-29 22:14:02 +06:00
Andy Kipp
5be43ba7a8
Fixed hanging the command right after calling full capture subprocess (#5769)
* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* test

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

---------

Co-authored-by: Andy Kipp <no@no.no>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andy Kipp <123@321.123>
2025-01-13 12:27:29 +06:00
Evgeny
9d49292453
test: split a test to include Windows (#5665)
* test: split a test to include Windows

(moving non-Win commands like ls to a separate test)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-08 20:22:08 +05:30
Simon Billinge
1d1e7a8827
try just using CaseSenssitiveDict from requests to see if it works (#5744)
* try just using CaseSenssitiveDict from requests to see if it works

* put the dependency back in pyproject.toml and ignore typing on import

* news

* code now passing tests locally.  I still need to write tests for the new Class

* tests for CaseInsensitiveDict
2024-12-08 13:58:31 +05:30
Gil Forsyth
9ae14866de
test: add Python 3.13 to test matrix (#5733) 2024-12-08 13:30:20 +05:30
Gil Forsyth
f2e4c93785 test(ubuntu,osx): skip pipeline and specs tests on Python 3.12
Some combination of these tests is hanging CI, but so far isn't
reproducible locally.  Need to narrow it down, but this is to unblock
other work.

test(ubuntu): skip all pipeline tests on Ubuntu on Python 3.12

test(specs): skip specs tests instead

test(pipelines): actually skip the pipeline tests

test: skip jobs

test: skip specs

test: only skip specs

test: skip specs and pipelines
2024-11-16 12:59:35 -05:00
Gil Forsyth
0bbaf74309 test(parser): xfail failed brackets test on windows 2024-11-16 12:59:35 -05:00
Peter Ye
79b3561c21
Catch SystemExit in ProcProxy (#5698)
* catch SystemExit in ProcProxy

* add test

* add news

* update test

* Update fix-procproxy-sys-exit.rst

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2024-10-03 22:04:09 +05:30
Peter Ye
4fc7d59c95
Fix quoting issue in virtualenv activator (#5700)
* add test case for directory with spaces

* Stop XonshActivator from quoting strings

* add news

* Update fix-virtualenv-quoting.rst

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2024-10-03 14:49:05 +02:00
Andy Kipp
938db85a87
Partial fix: Callable alias can provoke Bad file descriptor exception in the internal or external code (#5645)
* fix

* fix

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* test

* test

* test

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* bump test

* bump test

* test

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* test

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-09 14:46:19 +02:00
Aidan Courtney
58e2856145
Fix: exception when completing in python-only context (#5632)
* Fix: change xonsh/completer.py:Completer.complete_with_context and xonsh/completer.py:Completer.complete_line to use the python context prefix if available. Add simple regression test: tests/test_completer.py:test_python_only_context

* Add news item

* Fix: misspelled 'command'

* Update fix_python_only_completion.rst

* Update fix_python_only_completion.rst

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
2024-07-27 21:03:35 +05:30
Andy Kipp
680dcf06ff
executables: Added `locate_relative_path functionality to locate_file`. (#5630)
* locate_relative_path

* test

* news

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* test

* support pathext

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* test

* sep

* prefix

* fix pyghook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix pyghook

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-25 12:56:30 +05:30
Andy Kipp
31e7c4204a
Fixed `$AUTO_CD` regress after previous refactoring. (#5629)
* fix autocd

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-24 19:00:53 +02:00
Andy Kipp
2414ec167a
fix locate_file (#5606)
* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-18 10:53:00 +02:00
Andy Kipp
6b126ddd80
fix locate_file (#5600)
* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-16 13:16:16 +02:00
Andy Kipp
233e407b52
spec modifier: rename to decorator alias (#5579)
* rename

* rename

* rename

* rename

* rename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* rename

* rename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* rename

* rename

* rename

* rename

* rename

* rename

* rename

* rename

* rename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

* fix

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-14 22:00:24 +02:00
Andy Kipp
77f42b2f85
builtin: `exit can return exit code e.g. exit 71` (#5594)
* exit

* news

* switch bool to int

* event

* tests

* tests

* tests

* tests

* bump tests

* tests

* tests

* support unknown arg in exit

* docstring

---------

Co-authored-by: a <1@1.1>
2024-07-14 16:13:06 +02:00
Andy Kipp
38e9397f38
aliases: fix expand_alias (#5598)
* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-13 14:55:46 +02:00
Andy Kipp
87032f6d30
Alias that returns modified command (#5473)
* Command Alias

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* docs

* tests

* docs

* wip

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests

* tests

* clean

* news

* news

* bumptests

* bumptests

* new api

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* doooocs

* comments

* comments

* comments

* aliases.CUT_ARGS

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* aliases.CUT_ARGS

* aliases.CUT_ARGS

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* aliases.CUT_ARGS

* aliases.CUT_ARGS

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* aliases.CUT_ARGS

* comments

* bump test

* remove CUT_ARGS

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

* test

* wip

* revert

* wip

* wip

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* wip

* docs

* news

* tests

* tests

* test

* test

* test

* Update docs/tutorial.rst

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

* Update xonsh/aliases.py

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix, thanks jaraco!

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* more comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleaning

---------

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: Jason R. Coombs <jaraco@jaraco.com>
2024-07-12 01:35:20 +02:00
Andy Kipp
2142a7b85e
tools: added `mkdir to xonsh.tools.chdir` (#5589)
* mkdir chdir

* mkdir chdir

* mkdir chdir

* mkdir chdir

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-10 22:49:57 +02:00
Andy Kipp
059fc301e7
Introduce new resolver for executables to replace commands_cache usages and speed up everything (#5544)
* remove commands_cache from pyghooks to avoid cc.update_cache on every key press

* create executables.py

* replace cc.locate_binary to locate_executable

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* vc: replace locate_binary

* pyghooks: remove commands_cache

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unused func _yield_executables

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Move `executables_in` from tools to commands_cache to avoid circular imports.

* First steps to `procs.executables` that is based on `commands_cache` and `tools`.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test_executables

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add not recommended notes

* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add `get_paths` with test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix source test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* vc: remove tests because commands cache is not used

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* specs: fix exception for recursive call

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* specs: fix exception for recursive call

* improve test_locate_executable

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix test

* beautify pathext

* tests

* docs

* tests

* update locators

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* locate_file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* comments

* return environ locate bin test

* comments

* Update xonsh/procs/executables.py

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

* Update xonsh/procs/executables.py

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

* Update xonsh/procs/executables.py

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add itertools

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* moving is_executable

* doc

* optimization is_executable_in_windows

* micro improvements

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* news

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* bump test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

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: Jason R. Coombs <jaraco@jaraco.com>
2024-07-09 09:44:03 +02:00
Andy Kipp
1653faaeee
refactoring: tests for case when env var is class with repr. (#5583)
* tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-05 23:23:36 +02:00
Andy Kipp
0656eb3d3e
refactoring: deprecation warnings and revert shell moving for backwards compatibility (#5575)
* deprecation warnings

* deprecation warnings

* deprecation warnings

* restore shell

* restore shell

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-04 17:24:04 +02:00
Andy Kipp
6fd8937ee5
aliases: Added ability to set multiple spec modifiers (#5574)
* wip

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-04 16:10:02 +02:00
Andy Kipp
b1ffb11f27
refactoring: do not load user rc in tests (#5572)
wip

Co-authored-by: a <1@1.1>
2024-07-03 21:20:36 +02:00
Andy Kipp
40be260cb0
refactoring: restore parser to backwards compatibility after refactoring (#5571)
Restore parser location after movings in #5552 for backwards
compatibility.

## 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-07-03 10:33:17 +02:00
Andy Kipp
c638fbbc71
refactoring: fix test_main on mac (#5570)
<!---

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>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-03 08:10:03 +02:00
Andy Kipp
61a77ac3ce
Callable alias: fixed capturing stdout in case of redirect (#5527)
### Motivation

Closes #5512. 
The issue was introduced in #4445. It's needed to add checking the
redirect case.

### Before

```xsh
cd /tmp
@aliases.register('a')
def _a():
    print("1-hello")
    echo 2-hello
a > o.txt
# 2-hello
cat o.txt
# 1-hello
```

### After

```xsh
cd /tmp
@aliases.register('a')
def _a():
    print("1-hello")
    echo 2-hello
a > o.txt
cat o.txt
# 1-hello
# 2-hello
```

## 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-07-02 09:30:06 +02:00
Andy Kipp
2788ae3308
refactoring: move lazy to lib (#5560)
#5538

## 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-06-29 12:19:08 +02:00
Andy Kipp
143042aff5
refactoring: create xonsh.api, update xonsh.lib (#5557)
To have clear `./xonsh` directory with the list of components we need to
move common packages that are not components of xonsh to lib directory.
cc #5538

I see that `lib.os` and `lib.subprocess` have a bit different intention.
I think more clearer will be put them to `xonsh.api`. This is the first
step to #5383.



## 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-06-29 11:58:11 +02:00
Andy Kipp
4913edca7a
refactoring: move tests to component dirs: lib, procs (#5558)
https://github.com/xonsh/xonsh/issues/5538

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

---------

Co-authored-by: a <1@1.1>
2024-06-29 11:23:16 +02:00
Andy Kipp
1d7cc00962
refactoring: move shell to shells.shell to avoid unwanted init (#5556)
Continue #5550 for https://github.com/xonsh/xonsh/issues/5538 

---------

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: Noorhteen Raja NJ <jnoortheen@gmail.com>
2024-06-29 14:26:50 +05:30
Andy Kipp
7ffce23d29
refactoring: move parsers (#5552)
#5538


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: Noorhteen Raja NJ <jnoortheen@gmail.com>
2024-06-29 13:58:02 +05:30
Andy Kipp
610f1a41e8
refactoring: form shell submodule (#5550)
#5538


Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-29 12:25:07 +05:30
Andy Kipp
0bece0f5e4
refactoring: move jobs to procs (#5547)
#5538

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-29 12:21:10 +05:30
Andy Kipp
2ef4e329f7
refactoring: move platform, winutils, macutils to platform submodule (#5549)
https://github.com/xonsh/xonsh/issues/5538
## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
2024-06-29 02:01:15 +02:00
Andy Kipp
d7ca254ae3
refactoring: move pretty to lib (#5551)
#5538

## 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-06-29 00:56:16 +02:00
Andy Kipp
b9998ac5be
refactoring: move jsonutils to lib (#5548)
https://github.com/xonsh/xonsh/issues/5538

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

Co-authored-by: a <1@1.1>
2024-06-29 00:46:04 +02:00
Noorhteen Raja NJ
fa254914d7
fix: argparse based completions should work in newer python versions (#5542)
PS.

e47ecbd042

fixes #5471
2024-06-27 11:55:39 +05:30
Andy Kipp
a52aa5febc
Command cache: fix update cache logic (#5539)
### Motivation

I noticed that when I type every letter in the prompt on the remote
server the typing is lagging. I thought it's ssh but no.
After inspection the commands cache code I found that on every key press
there is reading all 2000+ files in PATH because the code for cache
update has funny issue.

### Quiz

```xsh
def f():
    print(1)
    yield False
    print(2)
    yield True
    print(3)

print(any(f()))
```
What will be in the output? Answer:

<details>

```
1
2
True
```

The execution of `print(3)` ignored because `any()` interrupts the
execution of the function.
If we call `print(list(f()))` the output will be `1 2 3 [False, True]`.

</details>

### Before

* Updating cache (read all files in PATH and list of aliases) two times
after start.
* Updating cache (read all files in PATH and list of aliases) on every
key press in prompt.

### After

* Update cache once at start.
* Update cache only when we have real changes of paths or aliases.

cc #4954 #3895 #5309

## 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-06-26 12:02:51 +05:30
Andy Kipp
d351df384a
tests: SpecAttrModifierAlias: integration test (#5533)
Added test.

## 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-06-24 15:12:23 -04:00
Andy Kipp
295e7f0582
xonshrc: add docs and tests for py files (#5515)
* Added py mention to docs
* Added tests
* Microfix

## 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-06-20 14:02:48 +00:00
Andy Kipp
4e12834e84
spec: added raise_subproc_error (#5494)
### Motivation

Add `spec.raise_subproc_error` to have an ability to use
`SpecModifierAlias` to manage the errors. Also this is the first step to
#4351.

Generally in scripts it's good to have RAISE_SUBPROC_ERROR=True to avoid
processing the error for every executed command. But in some cases (e.g.
`![]`) it's needed to avoid raising the error. To more elegant doing
this we can make an ability to create SpecModifier.

### After

```xsh
from xonsh.procs.specs import SpecModifierAlias
class SpecModifierNoErrAlias(SpecModifierAlias):
    def on_modifer_added(self, spec):
        spec.raise_subproc_error = False
aliases['noraise'] = SpecModifierNoErrAlias()

$RAISE_SUBPROC_ERROR = True

if ![noraise git pull]:
    git add --all
```

Cc #5443 

## 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-06-18 08:43:10 -04:00
Andy Kipp
06aca868a2
Fix #5491: more tests (#5498)
Fix #5491: 
* fix condition
* added more well organized tests

## 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-06-14 07:39:16 +02:00
Andy Kipp
5ee386eed9
Fix after #5491 (#5497)
After #5491 there is one case unfixed:

### Before
```xsh
echo 'echo home' >> ~/.xonshrc
cd /tmp
echo 'echo script' > 1.xsh

xonsh 1.xsh
# all rc without ~/.xonshrc
# script
xonsh -i 1.xsh
# all rc without ~/.xonshrc  # bug
# script
```

### After

```xsh
echo 'echo home' >> ~/.xonshrc
cd /tmp
echo 'echo script' > 1.xsh

xonsh 1.xsh
# all rc without ~/.xonshrc
# script
xonsh -i 1.xsh
# all rc with ~/.xonshrc
# home    # FIX
# script
```

## 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-06-13 17:19:21 +02:00
Andy Kipp
f81d55d09b
Do not load ~/.xonshrc in not interactive mode (#5491)
### Motivation

In #5099 was introduced the logic where all RC files are loaded in
interactive and non-interactive modes. This logic is not working good
for home based `~/.xonshrc` file.

First of all `~/.xonshrc` is the buffer/accumulator of settings focused
on interactive mode. Most tools with integration with xonsh (e.g.
`conda`, `zoxide`, etc) offer to just do `echo "init_tool()" >>
~/.xonshrc` (`conda` has around 20 lines of init code) to start using
the tool and users are doing this without any doubts.

But because of after 5099 `~/.xonshrc` is executed in non-interactive
mode the adding code to it leads to unexpected and unintended side
effects:

* If you run a script with shebang (e.g. `#!/usr/bin/env xonsh` or
[xonsh-awesome-cli-app](https://github.com/anki-code/xonsh-awesome-cli-app))
or just from `xonsh script.xsh` the code will be unexpected and
unintended slower.

* If you're using xonsh-based tools (e.g. you install them using pip)
and run them in environment that has no packages that initiated in
`~/.xonshrc` you will see epic errors.

* Additional context: 
* Bash and Zsh do not load `~/.bashrc` and `~/.zshrc` in non-interactive
mode by the same reasons.
* We have welcome message `Create ~/.xonshrc file manually or use xonfig
to suppress the welcome message` and we don't want to make the process
of creating this file complex.

All of this leads to bad unexpected and unintended experience. This PR
is to fix this.

### Expectation

By doing this fix we assume that experienced user who wants to build
good repeatable run control files will use another ways to create config
files and this has [reflection in
docs](8860f2bd52/docs/xonshrc.rst).
In the nutshell if you want to create the RC files that affect every run
of code you should use one or many of these ways:

* Cross-desktop group (XDG) compliant `~/.config/xonsh/rc.xsh` control
file.
* The system-wide control file `/etc/xonsh/xonshrc` for Linux and OSX
and in `%ALLUSERSPROFILE%\xonsh\xonshrc` on Windows. It controls options
that are applied to all users of Xonsh on a given system.
* The home-based directory `~/.config/xonsh/rc.d/` and system
`/etc/xonsh/rc.d/` can contain .xsh files. They will be executed at
startup in order. This allows for drop-in configuration where your
configuration can be split across scripts and common and local
configurations more easily separated.

In your configs you need to check `$XONSH_INTERACTIVE` and
`$XONSH_LOGIN` explicitly.

### Before

`~/.xonshrc` is used in non-interactive mode.

```xsh
echo "echo RC" >> ~/.xonshrc
cd /tmp
echo "echo Script" > script.xsh
xonsh script.xsh
# RC
# Script
```
```xsh
cd /tmp
echo 'echo RC' >> ~/.xonshrc
echo '#!/usr/bin/env xonsh' > myscript
chmod +x myscript

./myscript
# RC
```

### After

`~/.xonshrc` is not used in non-interactive mode. Use `-i` if you need
it.

```xsh
echo "echo RC" >> ~/.xonshrc
cd /tmp
echo "echo Script" > script.xsh
xonsh script.xsh
# Script

xonsh -i script.xsh
# RC
# Script
```
```xsh
cd /tmp
echo 'echo RC' >> ~/.xonshrc
echo '#!/usr/bin/env xonsh' > myscript
chmod +x myscript

./myscript
```
Closes #5488 #4096 #5496

### Fun

I want to leave here some nice representation of how it works in
bash/sh/zsh from [twitter
post](https://twitter.com/paxx39/status/1742768007154479109):



![image](https://github.com/xonsh/xonsh/assets/1708680/cd7b3803-483f-4d5d-bf9d-baa61c794f68)


## 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-06-13 10:08:23 -04:00
Jason R. Coombs
4aec6d1d12
Perform proper case-insensitive matching in command_cache on Windows (#5477)
Closes #5476
Closes #5469
2024-06-10 12:29:13 -04:00