How to complete bash shell command (or command in path)?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to complete bash shell command (or command in path)?

Peng Yu
Hi,

I'm editing a bash script. It will be convenient if I can complete
command that find in PATH. I'm sure that there is a way to do so.
Could any expert let me know how to do it? Thanks!

--
Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to complete bash shell command (or command in path)?

Jean-Rene David-2
* Peng Yu [2011.11.08 12:20]:
> I'm editing a bash script. It will be convenient if I can complete
> command that find in PATH. I'm sure that there is a way to do so.
> Could any expert let me know how to do it? Thanks!

One way would be to generate a list of all the
programs in PATH and use dictionary completion.

On *nix platforms this would be one way to
generate the list:

--------------- %< ----------------
#!/bin/sh
IFS=:
for dir in $PATH
do
   ( cd $dir && printf "%s\n" * )
done > /tmp/program-list
--------------- %< ----------------

Then in vim:

:set dictionary=/tmp/program-list

And complete with CTRL-X_CTRL-K

--
JR

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to complete bash shell command (or command in path)?

Paul-425
In reply to this post by Peng Yu
On Tuesday, 08 November, 2011 at 17:14:20 GMT, Peng Yu wrote:
>I'm editing a bash script. It will be convenient if I can complete
>command that find in PATH. I'm sure that there is a way to do so.
>Could any expert let me know how to do it? Thanks!

It's not bash specific, but neocomplcache can complete on complete filepath. Might be helpful to you.

http://www.vim.org/scripts/script.php?script_id=2620

--

.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to complete bash shell command (or command in path)?

Peng Yu
In reply to this post by Jean-Rene David-2
On Tue, Nov 8, 2011 at 3:50 PM, Jean-Rene David <[hidden email]> wrote:

> * Peng Yu [2011.11.08 12:20]:
>> I'm editing a bash script. It will be convenient if I can complete
>> command that find in PATH. I'm sure that there is a way to do so.
>> Could any expert let me know how to do it? Thanks!
>
> One way would be to generate a list of all the
> programs in PATH and use dictionary completion.
>
> On *nix platforms this would be one way to
> generate the list:
>
> --------------- %< ----------------
> #!/bin/sh
> IFS=:
> for dir in $PATH
> do
>   ( cd $dir && printf "%s\n" * )
> done > /tmp/program-list
> --------------- %< ----------------
>
> Then in vim:
>
> :set dictionary=/tmp/program-list
>
> And complete with CTRL-X_CTRL-K

files like xxx.sh only shown as xxx after I press CTRL-X_CTRL-K. Is
there a way to show xxx.sh instead of xxx?

--
Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to complete bash shell command (or command in path)?

Jean-Rene David-2
* Peng Yu [2011.11.09 22:30]:
> files like xxx.sh only shown as xxx after I press CTRL-X_CTRL-K. Is
> there a way to show xxx.sh instead of xxx?

set isk+=.

However beware that this will affect all "word"
related commands (e.g. w, e, b, *, #, etc.)

--
JR

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to complete bash shell command (or command in path)?

Peng Yu
On Wed, Nov 9, 2011 at 9:52 PM, Jean-Rene David <[hidden email]> wrote:
> * Peng Yu [2011.11.09 22:30]:
>> files like xxx.sh only shown as xxx after I press CTRL-X_CTRL-K. Is
>> there a way to show xxx.sh instead of xxx?
>
> set isk+=.
>
> However beware that this will affect all "word"
> related commands (e.g. w, e, b, *, #, etc.)

This is not a desired behavior. I'd only like '.' be recognized using
CTRL-X_CTRL-K


--
Regards,
Peng

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php