Git Product home page Git Product logo

Comments (10)

lacygoill avatar lacygoill commented on June 12, 2024 1

I don't have $FZF_DEFAULT_OPTS env var in xonsh nor in bash. Maybe my fzf version 0.39.0 (20230402) has better defaults or the setting is somewhere else.

It must be somewhere else, because I can reproduce on master in a freshly installed virtual machine.

So we have a workaround for this problem.

Yes, we might want to document this.

Not sure if anybody wants to introduce some method of escaping dollars/colons - if not I can close this issue.

IMO, it is definitely an issue. I encountered this as soon as I started using navi, but with the semicolon character. I sometimes write this kind of multi-line command:

command 1 \
; command 2 \
; command 3

For me, with the fish shell, the solution was to indent the subsequent commands:

command 1 \
    ; command 2 \
    ; command 3

Not sure about xonsh.

A similar issue might affect the angle bracket characters.

from navi.

welcome avatar welcome commented on June 12, 2024

Thanks for opening your first issue here! In case you're facing a bug, please update navi to the latest version first. Maybe the bug is already solved! :)

from navi.

Kossak-esky avatar Kossak-esky commented on June 12, 2024

I'm already on lastest version. Good bot :)

from navi.

lacygoill avatar lacygoill commented on June 12, 2024

Try to add a space in front of the command:

# envss
 $DISPLAY = ':0'
^

Ignore the caret. It's just there to point to the space above.


How can I escape either dollar or colon sign?

I suppose you meant "semicolon" instead of "colon".

Anyway, I agree that using the semicolon as the comment leader can be problematic.

navi had a similar issue when it had to find a syntax to separate a shell command producing default values for an argument, from optional parameters. It chose ---. I think the rationale is that it extends the -- syntax which is a widely used convention among a lof of Linux commands. FWIW, I would be in favor of doing the same with #, which is often used as a comment leader (navi itself uses it for the command descriptions). navi could use ## for meta-comments, and keep ; as a legacy syntax.

from navi.

lacygoill avatar lacygoill commented on June 12, 2024

and keep ; as a legacy syntax.

Never mind. Keeping ; as a legacy syntax would maintain the issue, unless it's hidden behind a configuration option. I guess it's too late to change that now without breaking people's cheats.

from navi.

Kossak-esky avatar Kossak-esky commented on June 12, 2024

I suppose you meant "semicolon" instead of "colon".

No, I meant escaping literal colon which is : char (or dollar $- either one should work), because it is used by navi to define snippet variables (eg: $ var: echo 'test') and it can also be used in shell variable as its value (eg for xonsh: $var = ':test'). Navi misbehaves in this case, because it probably thinks it is snippet/navi variable definition (since the line contains both $ and :) and doesn't let me insert my snippet into terminal :(

In other words, this snippet works:

# envss
$DISPLAY = '0'

but this one doesn't work:

# envss
$DISPLAY = ':0'

Anyway I just found a workaround: this snippet inserts what I want into the terminal:

# envss
$DISPLAY = '<colon>0'
$ colon: echo ':'

from navi.

lacygoill avatar lacygoill commented on June 12, 2024

Anyway I just found a workaround: this snippet inserts what I want into the terminal:

I still think that prefixing the command with a space is simpler to read and maintain. That said, if you want to bypass the fzf prompt, you might be interested in passing --select-1 to fzf(1):

# envss
$DISPLAY = '<colon>0'
$ colon: echo ':' --- --fzf-overrides --select-1

from navi.

Kossak-esky avatar Kossak-esky commented on June 12, 2024

I still think that prefixing the command with a space is simpler to read and maintain.

Yes, it would be simpler for other shells, but I if use multiline statements in xonsh and prefix them with space, it throws error:

$>  $TEST=':0'
 $TEST='a'

xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
  File "<stdin>", line 2
    $TEST='a'
SyntaxError: ('code:  ',)

Probably because it's python shell, so - like in python - every space prefix matters.

That said, if you want to bypass the fzf prompt, you might be interested in passing (...)

Fzf prompt is not invoked in $ colon: echo ':' (for me at least), because variable has only one value. If I added more values (separated by eg new line), then I would see fzf prompt.

Thank you.

from navi.

lacygoill avatar lacygoill commented on June 12, 2024

I if use multiline statements in xonsh and prefix them with space, it throws error:

Understood. I'm not familiar with xonsh.

Fzf prompt is not invoked here (for me at least)

OK, I guess --select-1 is included in your FZF_DEFAULT_OPTS, because by default fzf does give a prompt:

$ env --ignore-environment bash --noprofile --norc -c "echo ':' | $(type --path fzf)"

from navi.

Kossak-esky avatar Kossak-esky commented on June 12, 2024

I don't have $FZF_DEFAULT_OPTS env var in xonsh nor in bash. Maybe my fzf version 0.39.0 (20230402) has better defaults or the setting is somewhere else.

So we have a workaround for this problem. Not sure if anybody wants to introduce some method of escaping dollars/colons - if not I can close this issue.

from navi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.