You are not logged in.

#1 2013-11-07 20:35:26

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

[Solved] Bash completion of paths from a set of 'fake' paths

Hey guys,

I've been working on a bash-completion for a dot file management script I've been polishing off.

I'd like to do completion from a specific list of file paths like they were real paths, but can't seem to figure out how.

Here's the StackOverflow question I asked a few days ago

Any ideas?

Last edited by EvanPurkhiser (2013-11-14 09:41:54)

Offline

#2 2013-11-08 04:02:53

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,156

Re: [Solved] Bash completion of paths from a set of 'fake' paths

Have you looked at how e.g. the completion for subversion works with SVN_BASH_COMPL_EXT is set to allow the options described as "expensive"? If you have svn installed, /usr/share/bash-completion/completions/svn* document the different settings etc. I don't know if this will help at all but I guess it must get stuff to be seen as paths, if you see what I mean?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-11-09 02:27:48

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] Bash completion of paths from a set of 'fake' paths

Hey thanks cfr.

I took a look at how SVN completes things like `svn status` and the such when `SVN_BASH_COMPL_EXT` is set to one of the expensive options.

It's very close to what I want.

If I do a svn status and complete the file paths it looks pretty good (aside from listing folders twice)

$ svn status [tab][tab]
test/  test  second_dir/  second_dir

However..

$ svn status test/[tab][tab]
test/somefile  test/otherfile

If this was normal path completion it would look more like

$ svn status test/[tab][tab]
somefile  otherfile

I have a few ideas such as adding a / to COMP_WORDBREAKS, but that's tricky because you need to reset it.

If anyone knows of any other utilities that come with custom path completion please let me know!

Offline

#4 2013-11-09 02:48:09

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,156

Re: [Solved] Bash completion of paths from a set of 'fake' paths

Hmm... Yes. I see what you mean. For svn, that's actually pretty useful but I can see it would not always be so.

EDIT: Maybe one of the other version control systems does it in a way which would match what you want? I was going to look at the completion for git but I don't understand git well enough so I looked at subversion which I use all the time (at least try to!). Solved a query I had about getting better completions for svn, anyway. (I realise that doesn't help you but it made me happy. Obviously, I'd be happier if it provided a solution for you as well.)

Last edited by cfr (2013-11-09 02:51:19)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-11-12 03:53:32

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] Bash completion of paths from a set of 'fake' paths

Alright! I found a utility with bash-completions that does what I would like! It's called pass.

Here's the relevant file that handles the file completion. I haven't looked through it enough but I think this should solve my problem! I'll update the thread and mark it as solved (as well as answer my SO question) if this solves it.

Edit: Looking a little more into this maybe this won't solve it sad. This only works for existing file paths.

Last edited by EvanPurkhiser (2013-11-12 03:55:21)

Offline

#6 2013-11-14 09:41:39

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] Bash completion of paths from a set of 'fake' paths

I've solved it! Check out my answer on the stack overflow question.

Offline

#7 2013-11-15 04:22:46

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,156

Re: [Solved] Bash completion of paths from a set of 'fake' paths

Llongyfarchiadau! smile


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB