Revisions My Bash Profile For Mac

16.07.2019

I installed git using on my new Snow Leopard installation. After MacPorts is installed from the.dmg image, these would be the commands in Terminal.app: sudo port selfupdate sudo port install git-core +bashcompletion If you also want support for pulling from SVN repositories and docs, use this instead of the second line: sudo port install git-core +bashcompletion +doc +svn Then add the following to your /.profile or /.bashprofile: # MacPorts Bash shell command completion if -f /opt/local/etc/bashcompletion ; then. /opt/local/etc/bashcompletion fi or for MacPorts since version 2.1.2 on Mountain Lion: # MacPorts Bash shell command completion if -f /opt/local/etc/profile.d/bashcompletion.sh ; then. /opt/local/etc/profile.d/bashcompletion.sh fi or for MacPorts with newer versions of git: if -f /opt/local/share/git-core/git-prompt.sh ; then. /opt/local/share/git-core/git-prompt.sh fi Note: bash 4.1 or higher is required by bashcompletion.sh.

Mac

Open your terminal, and create.bash_profile file if it does not exist. Vim.bash_profile And write the following: export JAVA_HOME = $ (/usr/ libexec/java_home). How to set JAVA_HOME on Mac OS X. Posted by Daniel Lanza on March 21, 2016. If you are planing to develop Java Apps on your Mac.

Bash
  • From my experience as UNIX/Linux user, system administrator and trainer, I know that people can have years of daily. New versions, translations and availability. ~/.bash_profile, ~/.bash_login or ~/.profile: first existing readable file is read.
  • From what I gather from the bash man file,.bash_profile is for and interactive login shell and.bashrc is for a non-login interactive shell. I adjusted.bashrc to add to my path and add an alias and opened a new Terminal window and nothing happened.

If completion doesn't work try echo $BASHVERSION to see if that's the issue. If so, enter MacPorts bash by typing bash and try git completion again. Because /opt/local/etc/profile.d/bashcompletion.sh needs $BASHVERSION 4.1 or better, I had to do the following on a Mac OS X 10.8.3 with MacPorts 2.1.3: Switch the Mac OS X login shell from its default /bin/bash (3.2.48(1)-release) to MacPorts /opt/local/bin/bash (4.2.42(2)-release) like its described here: stackoverflow.com/a/784. Basically if `grep /opt/local/bin/bash /etc/shells` ; then echo /opt/local/bin/bash chsh -s /opt/local/bin/bash; else echo /opt/local/bin/bash sudo tee -a /etc/shells; chsh -s /opt/local/bin/bash; fi – Mar 15 '13 at 21:25. If you installed git using homebrew than you might adjust the MacPorts advice a little and add this to your.bashprofile and.bashrc if -f `brew -prefix`/etc/bashcompletion.d/git-completion.bash ; then. `brew -prefix`/etc/bashcompletion.d/git-completion.bash fi The best way to check if you have git correctly installed using homebrew ist to execute brew info git and check the output for the install directory of the git bash completion Latest version of Git (1.7.12) also requires the following to enable the prompt. If -f `brew -prefix`/etc/bashcompletion.d/git-prompt.sh ; then.

`brew -prefix`/etc/bashcompletion.d/git-prompt.sh fi. All you need to do is place the git-completion.bash file in your user home bin directory and place the following in you.profile or.bashprofile file: export PATH='$HOME/bin:$PATH' source /bin/git-completion.bash PS1=' u@ h w$(gitps1 ' (%s)') $ ' What this does is make sure that your local bin is in the PATH and the source command gets things going. Then of course the PS1 change puts the currently checked out branch in the prompt. So, no MacPort install to then install a the 'completion' version of GIT (especially irritating if you already have it installed). Annoyingly this has been broken yet again.

This time its the git folks with version 1.7.12-1. To allow people to have just the prompt functionality without the completion functionality (which can slows things down), they refactored the prompt functionality out of bashcompletion/git and into its own file git-prompt.sh.

Mac Osx Bash Profile

So adding bashcompletion as described by @Lara will only get you completion (hitting tab completes tag/branch names). To get the gitps1 so you can use it in your PS1 prompt you also need to add the following to your /.profile. /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh Some background is here. I use brew, so a master bashcompletion script which runs all the ones in bashcompletion.d seems not to be provided. The solutions which propose just running a single script to add git completions aren't extensible, because different packages will add different completion scripts, and you probably want to run them all. Therefore I added this (adapted from Arch Linux) to the end of /etc/bashrc: # source compat completion directory definitions BASHCOMPLETIONCOMPATDIR=/usr/local/etc/bashcompletion.d if -d $BASHCOMPLETIONCOMPATDIR && -r $BASHCOMPLETIONCOMPATDIR && -x $BASHCOMPLETIONCOMPATDIR ; then for i in $(LCALL=C command ls '$BASHCOMPLETIONCOMPATDIR'); do i=$BASHCOMPLETIONCOMPATDIR/$i -f $i && -r $i &&. '$i' done fi.

While the answer above by grundprinzip from 2011 still works fine, I wanted to add a more recent answer now that there's now a Homebrew package (, ) that makes this even easier. (This includes completion for git as well as other common tools.) Today macOS ships with Bash 3, but you can brew install bash to get Bash 4. If you're running Bash 4, then install the newer 2.x branch of bash-completion.

Bash 4. Run: brew install bash-completion@2. Add to /.bashprofile: if -f /usr/local/share/bash-completion/bashcompletion ; then.

Bash profile file

Mac Bash Profile

/usr/local/share/bash-completion/bashcompletion fi Bash 3 If you want to stick with stock bash 3.x on macOS then follow these directions instead. Run: brew install bash-completion. Add to /.bashprofile: echo ' -f /usr/local/etc/bashcompletion &&. /usr/local/etc/bashcompletion' /.bashprofile Reference.

Comments are closed.