Skip to content

Instantly share code, notes, and snippets.

@P4
Last active October 13, 2015 08:08
Show Gist options
  • Save P4/4165399 to your computer and use it in GitHub Desktop.
Save P4/4165399 to your computer and use it in GitHub Desktop.
.bashrc: custom prompt, aliases
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Handy aliases
alias diff='~/bin/diff.py'
alias documents='cd /d/Dokumenty/'
alias idle='python /c/Python3/Lib/idlelib/idle.pyw'
alias jihad='jhead -n%Y-%m-%d-%H%M%S'
alias ll='ls -lh --color=auto'
alias ls='ls --color=auto'
alias subl='/d/Program\ Files/Sublime\ Text\ 2/sublime_text.exe'
# Set title of current window
title() {
echo -ne "\e]0;${PWD##*/}\a"
}
# Git support:
source ~/bin/git-prompt.sh
__venv_name() {
# print name of current virtualenv
if [[ $VIRTUAL_ENV ]]; then
printf "${1:-%s}" $(basename "$VIRTUAL_ENV")
fi
}
# # Default command prompt
# PS1='\[\033]0;$MSYSTEM:\w\007
# \033[32m\]\u@\h \[\033[33m\w$(__git_ps1)\033[0m\]
# $ '
# # Simple gray prompt:
# # [?][user@host DIR]$
# PS1='\[\e[0;37m\][$?][\u@\h \W]\$ \[\e[m\]'
# Command prompt:
# [?] user@host DIR [branch] [venv]
# $
__ps1 () {
local NORMAL="\[\e[m\]"
local LIME="\[\e[1;32m\]"
local OLIVE="\[\e[0;33m\]"
local YELLOW="\[\e[1;33m\]"
local CYAN="\[\e[1;36m\]"
local GRAY="\[\e[0;37m\]"
echo -n $GRAY'[$?]' $LIME'\u@\h' $YELLOW'\w'
echo -n "\$(__git_ps1 ' $OLIVE[%s]')"
echo -n "\$(__venv_name ' $CYAN[%s]')"
echo -n $NORMAL'\n\$ '
}
PS1="$(__ps1)" && unset -f __ps1 # run and delete function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment