New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

Terminal: Smart tab completion


Post Reply New Thread Subscribe

 
Thread Tools
CaldwellYSR

 
CaldwellYSR's Avatar
 
Member Since: May 09, 2011
Location: Sewanee, TN
Posts: 98
CaldwellYSR will become famous soon enough
Mac Specs: MacBook 13" 2.4 Intel Core 2 Duo 2 GB

CaldwellYSR is offline
As a recent switcher from Ubuntu (Well recent switch backer if that's a word) I'm finding myself in the command line a lot more than when I was a mac user before. One thing I really loved about Ubuntu was when I was compiling and running java programs for class my tab completion was really smart. When I needed to compile my class if I had a directory that looked like:
Code:
Example.java
Example.class
Client.java
Client.class
and I needed to compile the Client.java to take into account the most recent changes I would type:

Code:
javac C [TAB]
and it would complete to
Code:
javac Client.java
ignoring the .class files because you can't run javac on a .class. Also when I wanted to run the file typing

Code:
java C [TAB]
would result in

Code:
java Client
with no period. This was a very smart way of doing the tab completion that I got so used to that now it's driving me crazy when I hit tab and it gives me the Client. without actually completing to what I need it to be.

So is there any way to make the Mac bash completion smarter so that it would have this same effect?



QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Hrm, I'd have to play with it. Ubuntu's method would drive me bananas.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Check out

Bash completion for Mac OS X | Me in IT

or

Getting <code>bash</code> Completion Magic on OS X &mdash; prb.io

I normally work in a korn shell, so I'm still sooo used to hitting esc twice, it's not even funny.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
CaldwellYSR

 
CaldwellYSR's Avatar
 
Member Since: May 09, 2011
Location: Sewanee, TN
Posts: 98
CaldwellYSR will become famous soon enough
Mac Specs: MacBook 13" 2.4 Intel Core 2 Duo 2 GB

CaldwellYSR is offline
I ended up getting bash-completion through homebrew and it works wonderfully thanks for the suggestion Dysfunction



QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,893
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
I'm not familiar with the intricacies of configuring bash beyond changing the PS1 env variable to change my prompt so I may not be able to help much here. That said, I tested your situation and as expected, tab completion stopped at the . (so, Client.). This makes sense since there are multiple possibilities after the period. I'm not sure if it's possible to have bash ignore certain file extensions especially if you're only trying to do it for certain binaries (javac in this case). Let me take a look into this.

EDIT: I seem to be really slow on the typing today. Glad to see you found a solution.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,638
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Quote:
Originally Posted by CaldwellYSR View Post
I ended up getting bash-completion through homebrew and it works wonderfully thanks for the suggestion Dysfunction
Awesome! Glad it's working for you, nothing's worse than having to change how you work! (now I REALLY wish GNU grep had the -p option)

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
CaldwellYSR

 
CaldwellYSR's Avatar
 
Member Since: May 09, 2011
Location: Sewanee, TN
Posts: 98
CaldwellYSR will become famous soon enough
Mac Specs: MacBook 13" 2.4 Intel Core 2 Duo 2 GB

CaldwellYSR is offline
Quote:
Originally Posted by vansmith View Post
I'm not familiar with the intricacies of configuring bash beyond changing the PS1 env variable to change my prompt so I may not be able to help much here. That said, I tested your situation and as expected, tab completion stopped at the . (so, Client.). This makes sense since there are multiple possibilities after the period. I'm not sure if it's possible to have bash ignore certain file extensions especially if you're only trying to do it for certain binaries (javac in this case). Let me take a look into this.

EDIT: I seem to be really slow on the typing today. Glad to see you found a solution.
The bash-completion solution really extends the power of bash in my opinion. Not only because of the java problem I was having, but it also makes the tab completion ignore files when using the cd command (since you can't cd into a file) and ignore directories and other, uneditable files with nano or vim.



QUOTE Thanks

Post Reply New Thread Subscribe


« Mac to windows for school | Best free music downloading app? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Automatically save log files of terminal sessions Stubaan OS X - Apps and Games 3 04-02-2013 11:24 AM
Show path at the tab title and the cmdline prompt in mac terminal ypsd OS X - Development and Darwin 0 07-25-2011 04:55 PM
Tab Key Issues jack963 OS X - Operating System 3 05-26-2007 03:49 PM
TAB question about IE, Firefox, or Safari dopey423 OS X - Apps and Games 4 02-21-2006 02:50 PM
David Hyatt on Tabbed Browsing schweb Apple Rumors and Reports 0 03-06-2003 10:24 PM

All times are GMT -4. The time now is 09:47 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?