Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bash completion #278

Closed
wants to merge 3 commits into from

4 participants

Oliver Schrenk Roland Warmerdam Haralan Dobrev Mathias Bynens
Oliver Schrenk

I suggest to move the completion scripts to ~/.bash_completion and install bash-completion via homebrew. I believe it does not exist on a default OS X installation, so sourcing /etc/bash_completion always fails.

oschrenk added some commits
Oliver Schrenk oschrenk Move user completions to .bash_completion
From the Bash Completion FAQ:
Q. How can I insert my own local completions without having to
reinsert them every time you issue a new release?

A. Put them in ~/.bash_completion, which is parsed at the end of the
main completion script.
735112c
Oliver Schrenk oschrenk Use homebrew's bash-completion if available 9f77ea9
Oliver Schrenk

Good idea. I also share (most) of the configs between Ubuntu and OS X.

Haralan Dobrev

BTW I don't have a file here: $(brew --prefix)/etc/bash_completion, but I have a directory $(brew --prefix)/etc/bash_completion.d with the following symlinks:

  • ag.bashcomp.sh
  • git-completion.bash
  • git-extras
  • git-prompt.sh
  • go-completion.bash
  • hg-completion.bash
  • hub.bash_completion.sh
  • tmux

Do you have any idea why is that? Right now I need to load the hub completion manually in my .bash_profile.

Roland Warmerdam

Points to a script that's part of Brew for me:

$ ls -l $(brew --prefix)/etc/bash_completion
> lrwxr-xr-x  1 Roland.Warmerdam  admin  49 19 Jul 20:03 /usr/local/etc/bash_completion -> ../Cellar/bash-completion/1.3/etc/bash_completion

$ ls -l /usr/local/Cellar/bash-completion/1.3/etc/bash_completion
> -rw-r--r--  1 Roland.Warmerdam  admin  58379 19 Jul 20:03 /usr/local/Cellar/bash-completion/1.3/etc/bash_completion
Roland Warmerdam

Do you have bash-completion installed? i.e: brew install bash-completion

Oliver Schrenk

@hkdobrev These are bash completion scripts that get installed as contrib from their respective projects. They won't be loaded automatically though if you don't install bash-completion.

@Rowno Yes, I have. It's also part of this pull request.

Dom H. ribmo referenced this pull request from a commit in ribmo/dotfiles
Dom H. ribmo bash-completion via homebrew (based on mathiasbynens#278) 146fcf2
Mathias Bynens mathiasbynens referenced this pull request from a commit
Oliver Schrenk oschrenk .bash_profile: Enable Bash completion if `/etc/bash_completion` exist…
…s too

This is useful on Linux.

Ref. #278.
0a38d10
Mathias Bynens

Thanks!

Andrew Marcinkevičius ifdattic referenced this pull request from a commit in ifdattic/dotfiles-old
Oliver Schrenk oschrenk .bash_profile: Enable Bash completion if `/etc/bash_completion` exist…
…s too

This is useful on Linux.

Ref. #278.
5dba360
Thorsten Rinne thorsten referenced this pull request from a commit in thorsten/dotfiles
Oliver Schrenk oschrenk .bash_profile: Enable Bash completion if `/etc/bash_completion` exist…
…s too

This is useful on Linux.

Ref. #278.
8a00a24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 3, 2013
  1. Oliver Schrenk

    Move user completions to .bash_completion

    oschrenk authored
    From the Bash Completion FAQ:
    Q. How can I insert my own local completions without having to
    reinsert them every time you issue a new release?
    
    A. Put them in ~/.bash_completion, which is parsed at the end of the
    main completion script.
  2. Oliver Schrenk
Commits on Nov 4, 2013
  1. Oliver Schrenk
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 11 deletions.
  1. +9 −0 .bash_completion
  2. +5 −11 .bash_profile
  3. +1 −0  .brew
9 .bash_completion
View
@@ -0,0 +1,9 @@
+# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
+[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh
+
+# Add tab completion for `defaults read|write NSGlobalDomain`
+# You could just use `-g` instead, but I like being explicit
+complete -W "NSGlobalDomain" defaults
+
+# Add `killall` tab completion for common apps
+complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
16 .bash_profile
View
@@ -25,15 +25,9 @@ for option in autocd globstar; do
shopt -s "$option" 2> /dev/null
done
-# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
-[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh
-
-# Add tab completion for `defaults read|write NSGlobalDomain`
-# You could just use `-g` instead, but I like being explicit
-complete -W "NSGlobalDomain" defaults
-
-# Add `killall` tab completion for common apps
-complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
-
# If possible, add tab completion for many more commands
-[ -f /etc/bash_completion ] && source /etc/bash_completion
+if [ -f /etc/bash_completion ]; then
+ source /etc/bash_completion
+elif [ -f $(brew --prefix)/etc/bash_completion ]; then
+ source $(brew --prefix)/etc/bash_completion
+fi
1  .brew
View
@@ -13,6 +13,7 @@ echo "Don’t forget to add $(brew --prefix coreutils)/libexec/gnubin to \$PATH.
brew install findutils
# Install Bash 4
brew install bash
+brew install bash-completion
# Install wget with IRI support
brew install wget --enable-iri
Something went wrong with that request. Please try again.