Giter Site home page Giter Site logo

Comments (14)

tkossak avatar tkossak commented on May 27, 2024 1

Sure, If you tell me commit hash to install clifm from, I can try it

from clifm.

tkossak avatar tkossak commented on May 27, 2024 1

Works, thank you (also for the tip).

from clifm.

freijon avatar freijon commented on May 27, 2024 1

btw. same issue with nushell.
Nushell also supports back-ticks (`) as quote style, so maybe this could easily be added as well?

from clifm.

tkossak avatar tkossak commented on May 27, 2024

It actually is a problem with xonsh shell. It would work if eln was expanded using quotes, not slashes. Maybe I will just stop using xonsh inside clifm, and switch back to bash...

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

Hi @tkossak. First, the obvious thing: xonsh is quite unorthodox in this regard. Escaping (using backslashes), just as quoting (using either single or double quotes), is a standard method (POSIX indeed) to disable special meanings.

However, providing an option to choose among these escaping mechanisms (backslash, single, or double quotes) when auto-expanding file names, might be an interesting feature.

For the time being, you can still make it work using the ; character, which instructs clifm to pass the current command line verbatim to the system shell (in this case, xonsh). Example:

;vim 'a - a'

Far from perfect, but it does the trick.

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

A little improvement: vim 'a - a' should work (no need for leading semicolon anymore).

Btw, there are several open issues in the xonsh repo complaining about this: it cannot handle backslashes. See for example xonsh/xonsh#3595 and xonsh/xonsh#1432. Sadly, the devs do not seem to like the idea of supporting backslashes at all, despite the fact that it is a quite standard feature (and indeed the default quoting mechanism for most shells). As specified by POSIX, all the three quoting mechanisms (backslash, single, and double quotes) shall be supported by a compliant shell. Of course, xonsh do not need to be POSIX compliant (and probably it is not even intended to be so); but there are some drawbacks, mostly portability. This issue seems to be a good example.

from clifm.

tkossak avatar tkossak commented on May 27, 2024

Yes, xonsh does not try to be 100% POSIX compatible, instead it wants to be more PYTHON compatible.

vim 'a - a' works, but I need to write file name manually instead of expanding ELN (or manually remove all slashes and enclose it in quotes)

So it's feature request ticket :). If we could configure clifm to use single single (or double) quotes instead of slashes it would be awesome. I would use it even with bash, because slashes look ugly, especially when file name has more spaces and is long - it's difficult to find at first glance where file name ends, and where command arguments are.

Thank you very much for your hard work!

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

I have been playing around with this (cause I think is a feature to have) and have been able to make it work pretty nice, except for directories: TAB completion/suggestions is complex machinery. The thing is that I don't like to provide a non-complete feature because it looks weak (and it is it), but I could provide you with temporary snapshots hidden behind a non-documented option to make some tests.

EDIT: non-complete means that alternative quoting mechanisms (both single and double quotes) will work only for ELN expansions provided they do not point to directories.

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

The new feature (though highly experimental) is ready. This is how it works:

  1. Select the quoting style setting QuotingStyle in the config file (the COMMAND LINE section feels like the right place) to any of these values: backslash (default), single, or double (single would be the most natural choice in this case).
  2. Regular files (not dirs) expanded/completed from ELN's will use the desired quoting style.

Needles to say, this feature is completely undocumented (hidden) and might be modified (or even completely removed) in the (near) future.

from clifm.

tkossak avatar tkossak commented on May 27, 2024

Expanding eln works as it should (tried QuotingStyle=single), but using eln directly doesn't (because of xonsh), eg inside clifm:

$ n 'a - a'
$ vim 1<TAB>  # works, it changes into: vim 'a - a'
$ vim 1
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jul 08 2023 13:06:53)
Unknown option argument: "-\"
More info with: "vim -h"

clifm v1.13.9 with xonsh as $CLIFM_SHELL.

In bash both eln and expanded eln works.

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

Should be working now.

EDIT: A little tip: vim 1 (runs the command via the system shell, or whatever shell specified via CLIFM_SHELL); 1 vim, by contrast, runs the command bypassing the shell, directly via execv(3), in which case the quoting style doesn't make any difference: whatever 1 points to is passed to vim as is. The second command works no matter the quoting style.

from clifm.

tkossak avatar tkossak commented on May 27, 2024

Got another improvement for this feature: it would nice if quoting expansion worked also for tab completion! eg:

$ n 'a - a'
$ ls a<TAB>

Last command is expanded into: ls a\ -\ a, but should be ls 'a - a'

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

Hi @tkossak. Yes, I'm totally aware of this, and this is why I said that this feature is not complete. The thing is that 1<TAB> is one thing and a<TAB> is a completely different thing (or at least quite more complex): in the first case, we know we have an ELN, which could be either a directory or a file name (always in the current directory); in the second case, by contrast, none of these conditions can be given for granted, cause it may be anything, from a simple file name, to a directory name, to a path or any other completion type. This is why I limited this feature to ELN's in the first place.

I'll bear this in mind however.

from clifm.

leo-arch avatar leo-arch commented on May 27, 2024

Hi @freijon. Thanks for pointing this out. For the time being, the same trick used for xonsh can be used for nushell.

As to the backticks, that's quite unorthodox, and more importantly, dangerous: most shells (following the POSIX specification) use backticks for command substitution : now, if you're not running nushell and your quote style is backtick, the underlying shell will try to execute a command named as your file, which is clearly not what you intended, and also a security concern.

I'll take a look at it, however.

from clifm.

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.