LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2012, 05:19 PM   #1
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
bash autocomplete space after match


Is there a way to prevent the autocomplete feature in the bash shell from appending a space to the match for certain commands?

My problem is this: I create a temporary file or two, call them file1 and file2, then want to remove them. Usually I'll do "rm fi<tab>*". This completes to "rm file*", which matches all of the file1, file2, etc that I want to remove.

The issue is that sometimes I'm in a rush, and I forget and do this when there's just one file to remove. The result is that "rm fi<tab>*" completes to "rm file *", which removes not only "file", but everything else in my CWD.

All I want is a programmable completion so that for "rm", autocomplete works like normal except that it does NOT append a space to the match. I can add the space myself if I want to specify more than one file.

I simply cannot find a way to do this...I thought nospace would work, but when I run "complete -o nospace rm", autocomplete seems to be completely disabled for rm, which obviously is not what I want. What am I missing here?

Last edited by suicidaleggroll; 08-06-2012 at 05:20 PM.
 
Old 08-06-2012, 11:18 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Well some searching I found the following page:

http://www.gnu.org/software/bash/man...etion-Builtins

And as a basic test I did the following:
Code:
$ compopt rm
compopt +o bashdefault +o default +o dirnames +o filenames +o nospace +o plusdirs rm
$ compopt -o nospace rm
$ compopt rm
compopt +o bashdefault +o default +o dirnames +o filenames -o nospace +o plusdirs rm
Now when I use rm I get no space after the completion. Didn't read far enough to make it permanent but sure it is in there somewhere
 
1 members found this post helpful.
Old 08-07-2012, 04:59 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Original Poster
Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Thanks, I was trying to use complete to set the nospace, and it was killing autocomplete entirely.

complete -o default rm
followed by
compopt -o nospace rm

has fixed the issue
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
partition space and disk space usage and free don't match nsic Linux - Newbie 3 02-22-2013 12:57 PM
Bash - match lines from two files LocoMojo Programming 8 01-25-2011 04:45 AM
Regular expression to match lines in a file that do not start with # or a blank space threeonethree Programming 3 12-25-2010 03:00 AM
Customizing Bash Autocomplete ramzak3k Linux - Software 2 01-07-2009 07:57 PM
VMWare Linux Kernel address space mis-match madiyaan Linux - Newbie 4 06-19-2006 09:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration