Results 1 to 7 of 7
  1. #1

    CaldwellYSR's Avatar
    Member Since
    May 09, 2011
    Location
    Sewanee, TN
    Posts
    98
    Specs:
    MacBook 13" 2.4 Intel Core 2 Duo 2 GB
    Terminal: Smart tab completion
    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?



  2. #2

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    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!

  3. #3

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    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!

  4. #4

    CaldwellYSR's Avatar
    Member Since
    May 09, 2011
    Location
    Sewanee, TN
    Posts
    98
    Specs:
    MacBook 13" 2.4 Intel Core 2 Duo 2 GB
    I ended up getting bash-completion through homebrew and it works wonderfully thanks for the suggestion Dysfunction



  5. #5

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,742
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    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

  6. #6

    Dysfunction's Avatar
    Member Since
    Mar 17, 2008
    Location
    Tucson, AZ
    Posts
    6,821
    Specs:
    Way... way too many specs to list.
    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!

  7. #7

    CaldwellYSR's Avatar
    Member Since
    May 09, 2011
    Location
    Sewanee, TN
    Posts
    98
    Specs:
    MacBook 13" 2.4 Intel Core 2 Duo 2 GB
    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.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Terminal tab autocomplete
    By stockdizzle in forum OS X - Operating System
    Replies: 5
    Last Post: 03-20-2015, 05:37 AM
  2. Find current tab in Terminal with Applescript
    By pbw in forum OS X - Operating System
    Replies: 1
    Last Post: 01-19-2014, 09:55 AM
  3. Force Open Terminal Shells in New Tab?
    By ejang in forum OS X - Operating System
    Replies: 1
    Last Post: 03-24-2013, 08:03 AM
  4. Show path at the tab title and the cmdline prompt in mac terminal
    By ypsd in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 07-25-2011, 05:55 PM
  5. Terminal Tab Colors
    By sunshinecrab in forum OS X - Apps and Games
    Replies: 1
    Last Post: 03-11-2011, 04:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •