Skip to content

Instantly share code, notes, and snippets.

@ozh
Last active November 26, 2021 03:35
Show Gist options
  • Save ozh/4073789 to your computer and use it in GitHub Desktop.
Save ozh/4073789 to your computer and use it in GitHub Desktop.
.bash_profile for Git Bash
PS1='\[\033[32m$(pwd | sed -e 's!/d/home!-!')\033[36m $(__git_ps1 "%s")\033[0m\]
$ '
if [[ $(git rev-parse --git-dir 2> /dev/null) && -z "$GIT_MOTD" ]]; then
echo -e "\e[00;32m- \e[01;33mWelcome $(id -u -n)"
echo -e "\e[00;32m- \e[01;32mGIT BRANCH \e[00;32m-----------------------------------------------------\e[00m"
git branch
echo -e "\e[00;32m- \e[01;32mGIT STATUS \e[00;32m-----------------------------------------------------\e[00m"
git status
echo -e "\e[00;32m------------------------------------------------------------------\e[00m"
GIT_MOTD=1;
fi
alias pico="nano -w"
alias glog="git log --graph --pretty=format:'%Cred%h%Creset %C(cyan)%an%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias gcm="git checkout master"
alias npp="n++"
alias php="d:/online/xampp/php/php.exe"
alias phpunit="php d:/online/xampp/php/phpunit.phar"
alias composer="php /d/home/planetozh/composer.phar"
alias wp="php /d/home/planetozh/wp-cli.phar"
alias ls="ls --color=auto"
alias ll="ls -l"
alias cls="printf \"\ec\""
# Aliases can't be exported and made available in scripts -- functions can.
alias phantomjs_alias="d:/utils/phantomjs/phantomjs.exe"
function phantomjs {
phantomjs_alias
}
export -f phantomjs
alias mysqladmin_alias="d:/online/xampp/mysql/bin/mysqladmin.exe"
function mysqladmin {
mysqladmin_alias $@
}
export -f mysqladmin
function cdhere {
CDWHERE=$(d:/utils/cdhere/cdwhere.exe)
if [ "$CDWHERE" != "" ]; then
cd $CDWHERE
fi
}
alias wgetncc='/bin/wget --no-check-certificate'
function wget {
wgetncc $@
}
export -f wget
function histgrep {
history | grep $1
}
function syncapi {
/d/online/xampp/mysql/bin/mysqldump --opt --compress --user=yourls_api -p'cest lapi de YOURLS' --host=mysql.api.yourls.org yourls_api | /d/online/xampp/mysql/bin/mysql --user=root --host=127.0.0.1 -D yourls_api -C yourls_api
}
# For wp-cli phpunit tests
export WP_TESTS_DIR=/d/home/planetozh/wp-unittest-suite/wordpress-tests-lib
export WP_CORE_DIR=/d/home/planetozh/wp-unittest-suite/wordpress

My .bash_profile file for Git under Windows

Bash Prompt

The PS1 line adds a colored bash prompt with a trimmed down path (the htdoc root is removed) and the current branch if applicable

Dynamic MOTD

The if; then block is sort of a dynamic MOTD that performs a git branch and git status on logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment