Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
first try looking into each text file at /etc/bash_completion.d
then turn on hidden files and look at /home/yourname/bash"stuff" I have 6 files there
if none of that works and you know the exact phrase, since you only say it could be
$SOME_DIR....whatever it is ....try grep but that may take a long time or find
eg find /etc -type f -print |xargs grep -n "$SOME_DIR"
try a "zzz" first to see it should produce nil result...meaning it aint there.
I think I may not have described the problem clearly. The problem is that bash escapes the dollar sign of an environment variable when I use the cd command. $SOME_DIR was just an example. It could be any variable.
To explain again, say the environment variable points to some directory
Quote:
export SOME_DIR=/path/to/some/directory
Now if I type 'cd $SOME_D' and hit tab for autocompletion, I get this
Quote:
cd \$SOME_DIR
(note the slash appended by the shell) instead of this
Quote:
cd $SOME_DIR
So my question is, how I can modify shell's autocompletion so it doesn't escape the dollar sign with a slash?
I haven't found a proper solution to this, but there's a workaround. The escaping of environment variables can be disabled by pressing Esc followed by tab.
For example,
Code:
# cd $SO + [Esc] + [Tab]
# cd $SOME_DIR
If anyone knows a proper solution (i.e. without having to it Esc), please post it.
shopt -s cdable_vars
complete -v -F _cd $nospace $filenames cd
This will give an instant, but temporary solution.
Short Answer
Put "shopt -s cdable_vars" in a start-up script. -- This will give a permanent solution. I haven't done this yet, not sure which one to use.
Context
I am still running SimplyMEPIS 3.3.2 -- based on Debian Etch, back when it was "Testing", not "Stable" as it is now. All of this is based on what I found on my own system.
Notes
"cd $SO + [Esc] + [Tab]" didn't work for me.
I started w/ /etc/bash_completion, not its companion directory. It's a large file:
3000 if shopt -q cdable_vars; then
3001 complete -v -F _cd $nospace $filenames cd
3002 else
3003 complete -F _cd $nospace $filenames cd
3004 fi
References
Code:
$ help complete
Run man bash, then search for:
Completing
Programmable Completion
compgen [
complete [
Also from less -SN /etc/bash_completion:
Code:
5 # Copyright (C) Ian Macdonald <ian@caliban.org>
21 # The latest version of this software can be obtained here:
22 #
23 # http://www.caliban.org/bash/index.shtml#completion
Off Topic Discoveries
1. OMG, MEPIS has a "service" (ser<TAB>) cmd., & also "invoke-rc.d" (inv<TAB>). -- Check out their man pages.
Thanks for posting the solution. It worked perfectly well.
I think the complete command could do with more documentation. It has no man page or help output other than a two-line usage information.
Re:
Quote:
can /dev/pts, /dev/shm, /proc/*, or /sys be usefully umounted? -- I.E., is this a bug?
I've never tried or had to unmount any of them, but I did a quick search and found an interesting blog post that describes a situation where you would do that.
Also, from the man page:
Code:
-a All of the file systems described in /etc/mtab are unmounted.
(With umount version 2.7 and later: the proc filesystem is not
unmounted.)
AFAIK, only external commands (config files etc.) have man pages. Because it is a bashbuilt-in, complete is documented inside the (incredibly long) bash man page. That is why I gave you the following search phrases:
Quote:
Originally Posted by archtoad6
Run man bash, then search for:
Completing
Programmable Completion
compgen [
complete [
Each will take to an appropriate place in the bash man page. Use the whole phrase, I designed it to get you to the exact place I intended.
Code:
help complete
is only supposed to present a reminder on the command line when you need to jog your memory.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.