Skip to content

Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'

So you have a private Bitbucket Repo and you want to utilize it in your project composer.json. You may find that when you run the composer install you get an error pulling your private Bitbucket repo with messages about Oauth failure that may include "Invalid OAuth consumer provided"

Continue reading "Composer install of Private Bitbucket VCS "aka" 'Invalid OAuth consumer provided'"

More git prompt - Does it work on a Mac?

So a few years ago I wrote this article about setting a custom shell prompt that is "Git aware" and shows you your current branch.

The question came up as to whether or not this works on a Mac under OS/X.

I have always advocated avoiding things like WAMP or MAMP because I don't like a bunch of services running on my workstation. I prefer using virtualization to run a *nix distro matching whatever target deployment server I'm going to run under. VMWare, Virtualbox etc. along with the popularity of Vagrant and Docker have tremendous advantages over something like MAMP in my experience. You start the environment when you need it, and stop it when you don't, and there's no problem having 5 different VM's with different stacks and php versions.

For this reason, I have never been all that concerned with setting a git aware shell prompt up on my macbook. But as it's a *nix-like operating system, it has the basics you need to make the shell prompt code work, albeit with 2 required tweaks.

First you have to edit the /etc/profile script so that it will look for and read scripts in an /etc/profile.d directory. sudo vi, nano or whatever you want to edit the /etc/profile script and add this at the bottom:


for sh in /etc/profile.d/*.sh ; do
        [ -r "$sh" ] && . "$sh"
done
unset sh
 


This is simple bourne shell code to read in scripts in the /etc/profile.d directory when you login to a shell. It is a system-wide script, so when you change this, you change it for all users on the system.

Now you just have to create the /etc/profile.d directory.


sudo mkdir /etc/profile.d
 


Once this is done, you can use the same simple method described in the original article.



Defined tags for this entry: , ,

Showing your git branch in your shell prompt

At some point I found some code to get the git branch name and insert it into the shell prompt. As it was some years ago, sadly I've forgotten the original source, but it wasn't exactly the type of prompt I'm used to, so I tweaked it until I got it the way I prefer. In the first set of brackets, I display the user@host:directory.

Once I cd into a git initialized directory a colored prompt appears with the branch name displayed in gold. For my purposes, this is simple, functional and doesn't result in overly long prompts. Here's what you can expect from any terminal that supports ansi color codes.



To implement the prompt on your server or workstation, simply cut this snippet and paste it into the end of the /etc/bashrc file.

The current way to do this is to create a new file named "gitprompt.sh" in the /etc/profile.d directory, and paste the code below into it. Using vim is a good way to accomplish this task. You need to be root or sudo for this to work of course.

Once the file exists, all the system users will benefit from the prompt in their shell sessions.

Using this prompt, whenever you're in your bash shell, there will be no question of whether or not you are in a git initialized directory, or what your currently checked out branch name is.


# Custom aliases and functions
function parse_git_branch_and_add_brackets {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
PS1="[\u@\h:\W]\[\033[0;33m\]\$(parse_git_branch_and_add_brackets)\[\033[0m\]\$ "
 


Does this work on a Mac? Yes of course!




Defined tags for this entry: , , ,