University of Oregon

An improved PS1 for Git in Bash

Last year I updated my bash prompt (PS1) to include the active git branch name.
A few months ago I added to the the active repository name.
So here’s an example of my PS1 when I’m in a git tracked directory on the master branch:

vid@server mydirectory (origin [master])$ 

And here it is when I have other remote repositories for the same project (bronze and heuristics);

vid@server mydirectory (bronze | heuristics | origin [master])$ 

And now once more when I’m on a branch (devel) that doesn’t exist on the available remotes:

vid@server mydirectory (bronze | origin [devel])$ 

That’s achieved with these functions: parse_git_branch and show-git-current-remotes-short.

Auto populate from History via up and down arrow keys

I posted a highlight of some bash code that Jason H shared last year in my git_bash_files repo on bitbucket. Auto_populate_from_History_via_up_and_down_arrow_keys

Branching with Git – Follow up on keeping remote and local sync’d

I saw a follow up comment on the article that I built my git-create-branch function on and so I updated the code. *Thanks goes to Olivier Clavel.
Here’s the update:
Here’s my original post:

In addition to updating the git functions used I improved the function itself by adding more feedback to the user.
Here are the new functions: git-create-branch() and git-delete-branch();

bash function – cddrush

This is a quick function that reduces the keystrokes for using ‘drush dd’ in a cd command like so:

cd `drush dd`

Which is great but this is simpler


Oh, that’s nice!

Drupal DB backup bash script with Drush and Git

I like to make incremental backups of my drupal databases. To do that I’ve tried combine the best practices* into one bash script that I can run periodically and easily.
The end result is a bash function that’s easy and user friendly.
It works by leveraging Drush aliases and the drush sql-dump command in combination with git.

Usage is simple. From the command line:

$ dg_db_backup drush.alias "commit message" 

Note: dg_db_backup -> drush git database backup

Branching with Git – keeping remote and local sync'd

Max pointing me to his method of branching, inspired by:

Which creates a branch on the remote origin and then pulls it down and tracks it locally.

The author created a bash script and I wanted to make that a function to keep in my .bashrc file;