LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-04-2012, 11:26 PM   #1
veetee
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Rep: Reputation: Disabled
bash tab variable expansion


Hi,
I have been using bash-tab variable expansion for a long time.
recently I upgraded my OS and with it came a newer version bash!

earlier I could do:

cd $WORK_ (tab) it would give me options like DIR SRC
(I had created variables like $WORK_DIR $WORK_SRC.

I am unable to emulate this behavior with
vi $WORK_
or cp $WORK_

and so forth

even with "cd" I get:
cd \$WORK_



how can I make my bash-tab completion friendly to ME!
I don't want to change my habit simply a version has changed. I find this "slash" and not giving completion is uncomfortable to me.
 
Old 01-05-2012, 05:35 AM   #2
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
OK, I didn't even know bash word completion worked on variables! (I use it a lot for filename completion.) That's good to know (and it works for me).

Do you have the file /etc/bash_completion? And do you enable it by calling it from ~/.bashrc or /etc/bash.bashrc or /etc/profile?

I suppose we should also check ... what version of bash? what distro are you on?
Code:
bash --version
 
Old 01-05-2012, 08:32 AM   #3
veetee
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
bash --version
GNU bash, version 4.2.8(1)-release

and

from header of bash_completion:
#
# bash_completion - programmable completion functions for bash 3.2+

BUT the corresponding lines /etc/bashrc were commented
# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi

I will try uncommenting the lines..... and give an update
 
Old 01-05-2012, 09:17 AM   #4
veetee
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
I uncommented but

bash completion still does not work for
cp $WO (tab and nothing happens)
vi $WO (tab and nothing happens)
 
Old 01-05-2012, 12:21 PM   #5
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
Hmm ... interesting ... doesn't work for me either with cp, but with echo it does. It looks like bash is being smart about where it accepts filename completion and where it accepts variable completion. Which is a bit too smart because a variable might contain a path.

Remember you need to open a new shell to see the results.
 
Old 01-05-2012, 12:32 PM   #6
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
Have a look at this: http://www.gnu.org/software/bash/man...ble-Completion - although it doesn't seem to say much about options to control it.

Also look at An Introduction to Programmable Completion - http://tldp.org/LDP/abs/html/tabexpansion.html
 
Old 01-05-2012, 02:44 PM   #7
veetee
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Yes, I did open a new shell.

looks like I will have to read a lot of stuff to do something which, (in my opinion) should work out of the box.
 
Old 01-05-2012, 05:59 PM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I see the same problem here. Something has apparently been changed in the completion scripts that came out with bash4 so that it no longer expands variables on tab. It's quite frustrating, as I have a set of variables set up for switching to various directories. I've noticed a few other errors too.

I've been hoping that a fix would come out, but it's been a couple of months now and there's nothing yet.
 
  


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
[SOLVED] Bash - brace expansion using variable student04 Linux - Software 3 03-07-2017 05:04 AM
[SOLVED] Bash variable expansion problem JulianTosh Programming 2 09-06-2009 03:54 AM
variable expansion in bash coolhandluke1 Programming 4 01-09-2008 03:45 PM
Variable expansion in BASH champak Programming 5 11-26-2007 02:44 AM
bash script $n variable expansion cortez Programming 6 12-08-2003 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:12 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