Commit graph

2000 commits

Author SHA1 Message Date
Andy Kipp
7f7f8758a4
Added xontrib-macro-lib (#4206)
* docs

* Update xontrib_macro_lib.rst

* Update xontribs_meta.py

Co-authored-by: a <a@a.a>
2021-03-31 12:15:49 -04:00
Daniel Shimon
224fc55e41
Completion context (#4017)
* completion-context: Add CompletionContextParser placeholder

Implements the xonsh (tab-)completion context parser.
This parser is meant to parse a (possibly incomplete) command line.

* completers: tools: Implement ``contextual_completer`` decorator

This is used to mark completers that want to use the parsed completion context.

* completers: Enable using contextual completers in xonsh/completer.py

* completers: readline, ptk, jupyter: Enable using contextual completers

Pass ``multiline_text`` and ``cursor_index`` to ``Completer.complete()``

* parsers: base: Refactor out a ``raise_parse_error`` function

* tokenize: Enable ``tolerant`` mode

If ``tolerant`` is True, yield ERRORTOKEN instead of
    throwing an exception when encountering an error.

* lexer: Enable ``tolerant`` mode

Tokenize without extra checks (e.g. paren matching).
When True, ERRORTOKEN contains the erroneous string instead of an error msg.

* tests: lexer: Test ``tolerant`` mode

* completion-context: Implement simple CommandContext parsing

* completion-context: tests: Test simple CommandContext parsing

* completion-context: Implement parsing sub-commands

* completion-context: tests: Test parsing sub-commands

* completion-context: Add news file

* completion-context: parser: Add parser table path to relevant locations

Code-coverage, mypy ignore list, etc.

* completion-context: Implement parsing partial strings and line continuations

* completion-context: tests: Test parsing partial strings and line continuations

* completion-context: Convert ``Span`` object to a ``slice``

* completion-context: Refactor out ``create_command`` and ``cursor_in_span``

* completion-context: Implement handling empty commands

* completion-context: tests: Test handling empty commands

* completion-context: Implement handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: tests: Test handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: Implement handling python context

* completion-context: tests: Test handling python context

* completers: tools: Add `contextual_command_completer`

* completers: Make `complete_skipper` contextual

* completers: Make `complete_from_man` contextual

* completers: Make `complete_from_bash` contextual and add test

* completers: Make `complete_pip` contextual and update tests

* completers: Keep opening string quote if it exists

* completion-context: Handle cursor after a closing quote

For example - cursor at the end of ``ls "/usr/"``.
1. The closing quote will be appended to all completions.
 I.e the completion ``/usr/bin`` will turn into ``/usr/bin"``
2. If not specified, lprefix will cover the closing prefix.
 I.e for ``ls "/usr/"``, the default lprefix will be 6 to include the closing quote.

* completion-context: tests: Test handling cursor after a closing quote

* completion-context: Fix bug with multiple empty commands

e.g. `;;;`

* completion-context: tests: Speed up tests

From ~15 seconds to ~500 ms

* completion-context: Expand commands and subcommands

* completion-context: Simplify `commands` rules

* completion-context: Simplify `sub_expression` rules

* completion-context: Simplify editing a multi-command token

* completion-context: Inline `create_command`

* completion-context: Implement `contextual_command_completer_for` helper

* completers: Make `complete_cd`/`complete_rmdir` contextual and add tests

* completers: path: Don't append a double-backslash in a raw string

When completing a path, if a raw string is used (e.g. `r"C:\Windows\"`),
there's no reason to append a double-backslash (e.g. `r"C:\Windows\\"`).

* completers: Make `complete_xonfig`/`complete_xontrib` contextual and add tests

* completers: Make `complete_completer` contextual and add tests

* completers: Make `complete_import` contextual and add tests

* completion-context: Add python `ctx` attribute

* completion: tools: Simplify `RichCompletion` attributes handling

* completers: Make `base`, `python`, and `commands` contextual

* Add tests
* No need for `python_mode` completer anymore

* completion: tools: Add `append_space` attribute to `RichCompletion`

* completion-context: Get all lines in a main python context

* xontrib: jedi: Make the `jedi` completer contextual

* completers: tools: Remove `get_ptk_completer` and `PromptToolkitCompleter.current_document`

These aren't needed anymore now that contextual completers can access the multiline code (via `PythonContext.multiline_code`).

* completion-context: ptk: Expand aliases

* completion-context: jupyter: Expand aliases and fix line handling

* completer: Preserve custom prefix after closing quote

* completers: bash: Ensure bash completion uses the complete prefix

* completers: pip: Append a space after a pip command

* completers: pip: Prevent bad package name completions

* completers: Remove a common prefix from `RichCompletion` if `display` wasn't provided

* completion-context: Treat cursor at edge of `&& || | ;` as normal args

This will be used for completing a space

* completers: Complete end proc keywords correctly
2021-03-30 13:37:56 -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
bhawkins
7168b262ae
Fix garbage collection of JSON history specified in seconds. (#4098)
* Fix garbage collection of JSON history specified in seconds.

* Add news entry.

* Avoid possible off-by-one error

* Make size_over return value easier to reason about.

* Update gc_seconds test cases.

Co-authored-by: bhawkins <bhawkins@github.com>
2021-03-22 16:20:36 -04:00
Andy Kipp
06ca2b0d13
Catch callable in the arguments list (#4191)
* catch callable

* news

* bump tests

Co-authored-by: a <a>
2021-03-22 16:17:54 -04:00
Andy Kipp
c30e4689c0
fix: and/or colorize (#4188)
* fix

* bump tests

Co-authored-by: a <a>
2021-03-22 16:13:21 -04:00
Andy Kipp
275b9e770d
fix: xpip sudo behavior in xonsh appimage (#4192)
* fix

* simplify

* black

Co-authored-by: a <a>
2021-03-22 16:07:30 -04:00
Daniel Shimon
4fffe2d1e5
Improve which output (#4196)
* xoreutils: which: Make `which` command aware of ExecAlias

* aliases: exec-alias: Remove unneeded newline at end of src

It isn't needed for the exec to work

* news: Improve `which` output for ExecAlias
2021-03-22 16:06:41 -04:00
Evgeny
90ac2f3865
update imphooks encoding regex to match the newer version at PEP 263 (#4162)
* update imphooks encoding regex to match the newer version at PEP 263

* fix: add proper backslash-escaping to the imphooks encoding regex

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

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-03-22 14:13:13 -04:00
Gyuri Horak
234c444f79
#4148 TITLE can be set to a function (#4190) 2021-03-22 13:40:12 -04:00
Andy Kipp
8ad8b043e8
feat: Added ability to set XONSH_HISTORY_FILE (#4175)
* Added ability to set XONSH_HISTORY_FILE before loading the history backend.

* black

* using XONSH_HISTORY_FILE

* tests

* black

* Convert WindowsPath to str

* Update xonsh/environ.py

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

* cleaning

* test sqlite

* test dummy

* typo

* fix 3.6

Co-authored-by: a <a>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-03-16 17:07:11 -04:00
Evgeny
1dfb947cf9
fix: use 'utf-8-sig' instead of 'utf-8' to allow importing user modules with a 'UTF-8 with BOM' encoding (#4161)
Closes #4160
2021-03-15 17:04:45 -04:00
Andy Kipp
8620976282
fix: Not load history in not interactive (#4178)
* fix history reading

* black

* clean

* make None

* unused

* back to DummyHistory

Co-authored-by: a <a>
2021-03-15 11:15:15 -04:00
Andy Kipp
f32c36b600
fix xonfig (#4173)
Co-authored-by: a <a>
2021-03-12 09:45:36 -05:00
Andy Kipp
2913ec7775
docs: Running xonsh AppImage on Alpine (#4159)
* xonsh AppImage on Alpine

* Create appimage_alpine.rst
2021-03-10 09:27:25 -05:00
Noorhteen Raja NJ
b7b2c9a916
fix: abbrevs with callback alters buffer text before expansion (#4156)
* fix: abbrevs with callback alters buffer text before expansion

fixes #3642

* docs: add news item
2021-03-09 09:07:53 -05:00
Gil Forsyth
095ea292e7
Clean up shell check aliases (#4145) 2021-03-08 10:56:06 -05:00
Daniel Shimon
165f882f6d
bash-completion: Update to 0.2.7 (#4153)
* bash-completion: Update to 0.2.7

* news: Update bash completion fix
2021-03-08 10:36:03 -05:00
Andy Kipp
a966438e37
Welcome message: fix color, add ptk warning (#4143)
* welcome message

* welcome message

* welcome message

* welcome message

* welcome message

* welcome message

* flake

Co-authored-by: a <a>
2021-03-07 09:51:07 -05:00
Andy Kipp
845b690408
starship (#4147)
Co-authored-by: a <a>
2021-03-07 09:50:02 -05:00
Andy Kipp
b5b88b18f1
Fix XONSH_HISTORY_FILE (#4146)
* XONSH_HISTORY_FILE

* bump tests

* docs

* type

* black

* bump tests

* bump tests

* black

* I will forever update black before black

Co-authored-by: a <a>
2021-03-06 10:14:11 -05:00
Evgeny
d1d3d754c3
feat: add xontrib-linuxbrew (#4139) 2021-03-05 10:15:08 -05:00
Walter A. Boring IV
c3246236e1
add lines changed and removed in gitstatus (#4133)
This patch adds the number of lines added and removed as part
of the gitstatus line.
2021-03-04 15:53:30 -05:00
Gil Forsyth
6876131607 Updated CHANGELOG for 0.9.27 2021-03-03 11:29:59 -05:00
anki-code
86c4dec1bb
New awesome landing (v3) (#4122)
* awesome landing

* text

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* Talks about xonsh

* Q&A

* xontribs from github

* xontribs from github

* Update docs/_templates_overwrite/index.html

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

* Update docs/_templates_overwrite/index.html

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

* xontribs from github

Co-authored-by: a <a>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-03-02 08:50:54 -05:00
Noorhteen Raja NJ
a5522dbb1e
Remove vended ptk (#4107)
* refactor: remove vended_ptk from project

* refactor: handle removal of ptk vendoring

* refactor: update usage of os.scandir

* fix: update incorrect import xonsh.platform.scandir

* test: update os.scandir

* test: update tests that check ptk version matrix

* fix: add missing import ctypes
2021-03-01 11:56:32 -05:00
Adam Schwalm
27ed9be301
Perform path completion filtering based on expanded path (#4115)
* Perform path completion filtering based on expanded path

This fixes issues with the cd and rmdir completers not working
correctly due to os.path.isdir returning false for paths like
'~/example'.

* Avoid running subsequent completers for cd/rmdir

Raise StopIteration in the cd and rmdir completers if nothing is
found. This prevents the later completers like the generic 'path'
completer from running and returning incorrect results.
2021-03-01 11:44:32 -05:00
anki-code
b862e0cec0
Strict permission for history file (json, sqlite) (#4121)
* history file permission

* rst

* rst

* rst

* lint

Co-authored-by: a <a>
2021-03-01 10:20:37 -05:00
anki-code
44b9ee115b
Added xontrib-history-encrypt (#4120)
* xontrib-history-encrypt

* black

Co-authored-by: a <a>
2021-02-26 10:01:41 -05:00
anki-code
aad1da7270
SQLite History Backend: show message instead of exiting when disk is full (#4116)
* SQLite History Backend: show message instead of exiting from xonsh when disk is full.

* a bit cleaning

Co-authored-by: a <a>
2021-02-25 09:33:55 -05:00
Evgeny
eacb2e5cc0
feat: add xontrib-cd (#4109) 2021-02-22 09:32:34 -05:00
Noorhteen Raja NJ
c2d5e60799
Py39 support (#4101)
* fix: handle ast.Index and ast.ExtSlice change while Parsing

related to #4100, #4099, #4068, #4038, #4028, #4005,

* fix: py39 raises when lineno & col not given

TypeError: required field "col_offset" missing from keyword

* fix: tuple inside scbscriptor support for py39

* chore: enable py39 ci checks

they were silently failing before

* test: a backlog test for attributes inside subscriptors

this would require debugging deep into the ply parser methods.

* docs: add news item

* test: skip test_rc_with_modified_path on windows

* Update tests/test_parser.py

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

* test: mark failing tests for py39 parser

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-02-17 12:31:33 -05: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
Gil Forsyth
ff8b470d02 Updated CHANGELOG for 0.9.26 2021-02-04 12:36:41 -05:00
Noorhteen Raja NJ
1622697194
feat: some python libraries depend on isatty to check for terminal capabilities (#4013)
related to #4008

style: linter rst fix

refactor: update isatty of proxy functions
2021-02-04 11:44:01 -05:00
Gao, Xiang
4779930806
Add tcg to xontrib (#4076)
* Add tcg to xontrib

* Create tcg.rst
2021-01-31 17:22:41 -05:00
Noorhteen Raja NJ
d50cf32f84
Feat abbrevs callback (#4031)
* feat: support callbacks in abbrevs dict

facilitate solving problems like #3642

fixes #3642

* test: add tests for abbrevs and news item

* fix: mypy error

* refactor: update imports for xontrib_meta module
2021-01-29 12:18:22 -05:00
Gil Forsyth
71fe9014d2 Updated CHANGELOG for 0.9.25 2021-01-29 08:58:58 -05:00
Aneesh Durg
1f7f33c93f
Add $HISTCONTROL=ignorespace support (#4062)
* Add $HISTCONTROL=ignorespace support

* Add news and fix formatting

* Move ignore space to happend in append and fix test bugs

* invert conditional

* remove leftover debug info
2021-01-25 16:37:29 -05:00
yggdr
432df061c6
Fix libc detection and uptime functionality on FreeBSD (#4049)
* Fix libc detection on FreeBSD

On FreeBSD /usr/lib/libc.so is an LDScript text file, ctypes.CDLL can't handle
those. So we hardcode the current version number, lest we'd need to use the less
efficient ctypes.util.find_library function. This should be alright, since the
last increase in libc version number on FreeBSD was over 10 years ago.

* sysctlbyname needs bytes, not unicode strs

* Add news item for FreeBSD libc fix
2021-01-06 10:34:22 -05:00
Danny Sepler
97cb072f9f
Add a better test suite for "vc.py", and fix "include_untracked" logic (#4041)
* move test_prompt to test_base

* move test_prompt to test_vc

* revamp test_vc file

* Add VC_GIT_INCLUDE_UNTRACKED variable, move test_prompt.py to test_base.py

* reduce test_base
2021-01-05 09:26:19 -05:00
anki-code
d0b22652b4
Welcome message cosmetic changes (#4036)
* welcome

* welcome

* Update xonsh/xonfig.py

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

Co-authored-by: a <a>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-01-05 09:21:10 -05:00
Asaf Fisher
f3240c9c6d
Add Open in google cloudshell in the readme. (#4040)
* README: Add `open in google cloud shell` button in the readme 🤩

* news: Add google cloud button news
2021-01-04 12:46:56 -05:00
Asaf Fisher
da415caf06
Add 'dict' merging operation for the aliases class (#4037)
* aliases: Add merging operation to the aliases dict

* tests: Add tests to the aliases merging operation

* news: Add summary about the Alias merging functionality
2021-01-04 12:44:21 -05:00
anki-code
92dd822502
Using ujson (if installed) in LazyJSON to loading json history 15% faster (#4025)
* faster json history

* news

* mypy

Co-authored-by: a <a>
2021-01-04 12:32:14 -05:00
Leandro Emmanuel Reina Kiperman
e7e6fd90a7
Edit sys.path while loading RC files (squashed) (#3950) 2021-01-04 12:31:05 -05:00
Noorhteen Raja NJ
17961e3c24
feat: add xontrib-powerline3 (#4009) 2021-01-04 12:22:29 -05:00
Noorhteen Raja NJ
bceaafae4d
Add groups to env vars (#4026)
* feat: add grouped-settings for env variables

fixes #4014

style: fix mypy errors

chore: update testing requirements versions

fix: update xonsh.tools import error

* chore: add news item

* fix: update Var.with_default handling env defaults

* fix: set env var.doc_default=DefaultNotGiven

there is a custom handler for it

* chore: update travis

speedup docs generation

* chore: add command to serve docs during development

* docs: add jinja2 helpers/renderers extension for sphinx

* docs: update envvars document

* docs: fix docs failing

* Update xonsh/environ.py

commit suggestion

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

* Update xonsh/environ.py

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

* Update xonsh/environ.py

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

* Update xonsh/environ.py

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

* Update xonsh/environ.py

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

* Update xonsh/environ.py

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

* refactor: update rst-extension

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-01-04 12:21:44 -05:00
Anthony Scopatz
17f86d359e
callable default skips validation (#3668)
* callable default skips validation

* default value

* black

* today func

* store called defaults
2020-12-18 14:42:18 -05:00
anki-code
eac1e29397
SQLite history backend now has the same logic of storing stdout to the memory like json history backend (#4006)
* fix logic

* bump tests

Co-authored-by: a <a>
2020-12-18 14:13:12 -05:00