Closed idkjs closed 6 years ago
this is probably because the subtle differences in the mac and gnu shells - it probably just needs a bit of tweaking to make it work on a mac - could you try the latest version on the development branch?
https://raw.githubusercontent.com/bill-auger/git-branch-status/development/git-branch-status
Same result except now I dont get the error. The bash window opens and then closes immediately.
i have it working on libertybsd now - that may satisfy a mac also
https://raw.githubusercontent.com/bill-auger/git-branch-status/development/git-branch-status
Alright, just for fun, we are back to the "The terminal process terminated with exit code: 1" error message. So not there yet on mac.
@idkjs I'm on MacOS as well (10.13.3) and latest linked script works fine. Can you add more info about your setup? How exactly are you running the script? Did you try different repository?
@knovoselic thanks for feedback, boss. Uncommenting the source line end up so that when you open iterm, it immediately shuts down.
...
source "${HOME}/dotfiles/git-branch-status"
...
dotifile/git-branch-status is cp of link above.
Probably did something stupid. Happy for the feedback!
@idkjs what exactly are you trying to accomplish? It fails for me as well is I source it. But it was never meant to be sourced like that.
I'm a bit confused as why you'd want to source the script. Do you want to run it each time you open up a new terminal? Or are you trying to do something else?
If you just want to be able to call it like git branch-status
from anywhere, you only need to put the script in some folder in your PATH and make sure it's executable. Also, it needs to be called git-branch-status (that's how when you call git branch-status
git knows what to execute).
this script is not intended to be "sourced" - it is run just a standalone command in a terminal - just like what is shown in the README screenshot
$ git-branch-status
sourcing this script is essentially evoking it - so probably what is happening is that the .bash_profile is evoking it in your HOME dir which is not a git repo; and so the script exits with a failure (here) - so because the script is sourced directly into the shell proc and not run a sub-shell, the script failure causes the entire shell to exit
$ cd /not/a/git/repo/
$ git-branch-status
not a git repo
$ echo $?
1
this is the same semantics as git itself - the same thing would happen if you put git status
in your bash init scripts
$ git status
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
$ echo $?
128
as knovoselic noted, the most straight-forward thing to do is to put the script in your PATH; or alternatively, you could create an alias in your .bash_profile or .bash_aliases like:
alias git-branch-status='/path/to/the/real/git-branch-status/git-branch-status'
or in the [alias] section of your ~/.gitconfig
[alias]
branch-status = !/path/to/the/real/git-branch-status/git-branch-status
the git alias would allow it to be used as a git "sub-command"
$ git branch-status
one other thing i forgot - on BSD i had to change #!/bin/bash to #!/usr/bin/env bash - if bash is not in /bin on a mac then that could be something to note
@bill-auger thank you so much for the detailed and didactic response. Learned a whole lot there. I will be studying your response. Again, thank you, sir.
@knovoselic i had in my mind that this was an alternative command that I would run like my other git shortcuts, which you and @bill-auger have graciously explained is not the case. Thanks, sir.
I tried adding the script to my dotfiles on macOS. Everytime i run
git-branch-status
the terminal window closes with something likeThe terminal process terminated with exit code: 1
. Sorry for rookie question. Thank you for sharing and helping if you can.