Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:24

    daniel-shimon on main

    aliases: Fix $__ALIAS_NAME for … (compare)

  • 12:24
    daniel-shimon closed #4325
  • 09:59
    anki-code commented #4325
  • 07:59
    agentzh2m starred xonsh/xonsh
  • 04:26
    codecov-commenter commented #4326
  • 04:18
    yaxollum opened #4326
  • 03:27
    luisg122 starred xonsh/xonsh
  • Jun 14 20:36
    billsioros starred xonsh/xonsh
  • Jun 14 20:25
    codecov-commenter commented #4317
  • Jun 14 20:14
    codecov-commenter commented #4316
  • Jun 14 20:12
    codecov-commenter commented #4325
  • Jun 14 20:12
    daniel-shimon review_requested #4316
  • Jun 14 20:11
    daniel-shimon commented #4324
  • Jun 14 20:10

    daniel-shimon on main

    chore: update mypy to 0.902 (#4… (compare)

  • Jun 14 20:10
    daniel-shimon closed #4324
  • Jun 14 20:08
    daniel-shimon synchronize #4317
  • Jun 14 20:06
    daniel-shimon synchronize #4316
  • Jun 14 20:04
    daniel-shimon edited #4325
  • Jun 14 20:03
    daniel-shimon opened #4325
  • Jun 14 20:02
    jnoortheen commented #4324
jan Swedneck
@swedneck:feneas.org
[m]
hey is it just me or does if/else shorthand not work in xonsh?
oh nvm apparently the websites just don't make it clear how that shorthand works
Thomas A Caswell
@tacaswell
I have a possibly silly question
I'm trying to do something like
    cmd = ['xclip', '-selection', 'clipboard', '-t', content_type]
    p = Popen(cmd, stdin=PIPE)
    p.communicate(content)
(after https://github.com/brandon-rhodes/homedir/blob/1878c32bb0546f8485b768cd8d8399f4c422e53e/.fvwm/z_transform.py) in xonsh and can not figure out how to pipe the contents of a variable into the stdin of a subprocess
2 replies
jan Swedneck
@swedneck:feneas.org
[m]
can i change what version of python xonsh uses?
2 replies
syntaxman
@syntaxman

I've been combing through the docs for xonsh and prompt-toolkit, as well as the source code, and haven't been able to figure this out: I would like to map the key sequence: ";;" to "escape" in ViInsertMode. I found where escape is defined in the prompt-toolkit code, but it doesn't seem to have a related function name like "event.current_buffer.open_in_editor". So I tried copying the code into my custom_keybindings() which causes a syntax error in unrelated lines. I expected more helpful errors.

@bindings.add(';', ';', filter=ViInsertMode())
def _back_to_navigation_mode(event):
      buffer = event.current_buffer
      vi_state = event.app.vi_state
     if vi_state.input_mode in (InputMode.INSERT, InputMode.REPLACE):
         buffer.cursor_position += buffer.document.get_cursor_left_position()
     vi_state.input_mode = InputMode.NAVIGATION
     if bool(buffer.selection_state):
         buffer.exit_selection()

The code I tried to adapt came from python-prompt-toolkit/prompt_toolkit/key_bindings/bindings/vi.py:421 I tried to see if I could make KEY_ALIASES work for this, but I obviously didn't understand it. Am I missing something obvious here?

syntaxman
@syntaxman
BTW, None of the posts here are showing up in the OFTC #xonsh channel. I think the bot is down.
Andrew Pashkin
@AndreiPashkin
I wonder - how it's possible to set an environment variable name of which is known only at runtime?
In other words - how to set an environment variable which name is also stored in a variable?
dyuri
@dyuri:horak.hu
[m]
> path = "PATH"
> __xonsh__.env[path][0]
"/usr/bin"
or ${variable} works too
Andrew Pashkin
@AndreiPashkin
@dyuri:horak.hu, nice, thanks!
1 reply
Andy Kipp
@anki-code
I prefer to use getter with default value like __xonsh__.env.get("ENVVAR", "value_if_var_does_not_exists")
Rit
@RitikShah
getting some wacky errors from xonsh
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 22504, in main
    args = premain(argv)
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 22440, in premain
    env = start_services(shell_kwargs, args)
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 22370, in start_services
    execer = Execer(
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 21467, in __init__
    self.parser = Parser(**parser_args)
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 400, in __call__
    obj = self._lazy_obj()
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 368, in _lazy_obj
    obj = d["load"]()
  File "/usr/local/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 3388, in Parser
    from xonsh.parsers.v39 import Parser as p
  File "/usr/local/lib/python3.9/site-packages/xonsh/parsers/v39.py", line 10, in <module>
    from xonsh.parsers.base import Index
ImportError: cannot import name 'Index' from 'xonsh.parsers.base' (/usr/local/lib/python3.9/site-packages/xonsh/parsers/base.py)
8 replies
Chris Braun
@cryzed
@dyuri:horak.hu you are right. The default prompt only uses "BOLD_" color keys, which many of the default themes don't seem to define or define as exactly the same values, so I thought the prompt didn't change
dyuri
@dyuri:horak.hu
[m]
indeed, BOLD_GREEN remained the same in my example too
Chris Braun
@cryzed
I've just made a really neat integration :). I bound Ctrl+F to a custom function, that uses history show all -0 and history show -0 to get all history and history for the current session, deduplicates the former and pipes all of it into fzf and then writes the selection into the place of the current prompt buffer
This allows me to fuzzy-search all commands I ever typed into xonsh and see similar ones in real time
Same for the output of the previous command (split on whitespace) on Ctrl+G. I am aware there is Ctrl+R and the xontrib-output-search, but I much prefer fzf
dyuri
@dyuri:horak.hu
[m]
could you share it as a gist or something?
Chris Braun
@cryzed
Sure, give me a second, let me try to split it out of the rest
@dyuri:horak.hu
Chris Braun
@cryzed
By the way, when using @bindings.add is it possible to use key combination not defined in the Keys enum? I wanted to use Ctrl+Shift+F, but when I pass "c-s-f" to @bindings.add I remember getting an error
dyuri
@dyuri:horak.hu
[m]
that part is prompt_toolkit related I think, and ctrl-shift-left/right is supported, i'm not sure about ctrl-shift-[other letters]
Cadair
@cadair:cadair.com
[m]
Some recent update to xonsh (I think) has broken my git pager. I can't quit from it or page in it.
Anyone have any idea of what that might be about
dyuri
@dyuri:horak.hu
[m]
might be related to subprocess threading
try $THREAD_SUBPROCS=False
(it may break other things though)
Cadair
@cadair:cadair.com
[m]
You are correct that fixed it
halloleo
@halloleo
Hi all! Simple question I have forgotten the answer to: In a xonsh script how can I check for the return code of the last subprocess mode command? I think _.rtn works only in the REPL.
dyuri
@dyuri:horak.hu
[m]
If _.rtn does not work, try __xonsh__.history[-1].rtn
Rit
@RitikShah
Had some fun with rich and pandas haha
2 replies
Rit
@RitikShah
Anyone use glow, the md viewer?
Maxim Yurchenkov
@ggdwbg
in pynvim, is there an easy way to pack several api queries in a single rpc request?
i will iterate over lines and for every line ask something
or well maybe that's impossible, yeah, because rpc request is by design atomic, but something tells me there's gotta be some io bottleneck or smth
how do people loop over stuff, i guess that's the question
diego-rapoport
@diego-rapoport
Hi xonsh enthusiasts! I'm wondering if there's a way to do something like a bash_profile in xonsh. Some configuration that only runs once after login. Does anybody knows anything about it?
dyuri
@dyuri:horak.hu
[m]
you might check $XONSH_LOGIN in .xonshrc to check if it was executed as a login shell
diego-rapoport
@diego-rapoport

you might check $XONSH_LOGIN in .xonshrc to check if it was executed as a login shell

thank you very much for this!

but how could I source a file just once? like a profile would do
dyuri
@dyuri:horak.hu
[m]
xonsh might not have that feature yet
halloleo
@halloleo
@diego-rapoport You can build this functionality yourself: In the .xonshrc check XONSH_LOGIN and conditionally source another file, say .xonsh_profile.
Mark Bestley
@bestlem
Or you can just adjust to thinking differently and just have the one file but parts of it are only executed once - parts that are in a block controlled by if $XONSH_LOGIN:
George Pantazes
@gwpantazes

When doing a multline input such as

>>> if True:
...     print(1)
... else:
...     print(2)
...
1

Is there a way to do SHIFT+TAB to unindent by 4 spaces, or any similar feature?
For example, to enter the else, I pressed backspace 4x, but I would have liked to unindent the cursor by hitting SHIFT+TAB.

1 reply
saeb
@saeb:mozilla.org
[m]
hey hi
can I have agnoster?