Skip to content

Instantly share code, notes, and snippets.

@rafaelrosafu
Last active July 26, 2017 07:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrosafu/238116 to your computer and use it in GitHub Desktop.
Save rafaelrosafu/238116 to your computer and use it in GitHub Desktop.
Customized bash prompt, with tweaks to git, ls, grep. Save it to ~/.bashrc, should run automatically on new Ubuntu versions, but you cannot have a .bash_profile in the home dir
#=====================================================
# Personal environment variables and startup programs
#=====================================================
# If not running interactively, don't do anything
# vagrant breaks without this
case $- in
*i*) ;;
*) return;;
esac
# Setup some environment variables.
export HISTSIZE=1000
# Force /usr/local/bin to be first in the path search
export PATH=/usr/local/bin:$PATH
# Add colors to grep output
export GREP_OPTIONS='--color=auto'
# Set terminal colors to 256
if [ -n "$DISPLAY" -a "$TERM" == "xterm" ]; then
export TERM=xterm-256color
fi
# Linux specific configs
if [ "$(uname -s)" = "Linux" ] ; then
echo " "
fi
# Mac OS specific configs
if [ "$(uname -s)" = "Darwin" ] ; then
echo " "
fi
#================================
# Personal aliases and functions
#================================
# Inspired by topfunky from PeepCode Screencasts
# http://www.scrnshots.com/users/topfunky/screenshots/89842
# and discussion from http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt
# Source system wide bashrc, if it exists, before running personal configurations
if [ -f "/etc/bashrc" ] ; then
source /etc/bashrc
fi
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# Helper functions for git aware prompt
source $HOME/.bash/git_skull_prompt.sh
# Shows used space, uses current directory by default, sorted by size
function used_space() {
du --human-readable --max-depth=1 --total --exclude=./proc "$@" | sort --human-numeric-sort;
}
# Add json pretty print alias
alias jsonpp="python -m json.tool"
# Linux specific configs
if [ "$(uname -s)" = "Linux" ] ; then
# Make ls use list, show hidden and colors by default
alias ls="ls -lha --color=auto"
fi
# Mac OS specific configs
if [ "$(uname -s)" = "Darwin" ] ; then
# Make ls use list, show hidden and colors by default
alias ls="ls -lhaG"
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
if [ -n "$(which git)" -a "$(which git)" ]; then
git_status() {
untracked=$(git status | grep 'Untracked files' 2> /dev/null)
if [ -n "$untracked" ]; then
echo "☠"
else
to_commit=$(git status | grep 'nothing to commit' 2> /dev/null)
if [ -z "$to_commit" ]; then
echo "☠"
fi
fi
}
parse_git_branch ()
{
result=$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/[\1]/')
if [ -n "$result" ]; then
echo $result $(git_status)
fi
}
parse_host(){
echo \[\033[0;32m\]\h
}
export PS1='\u@\h \[\033[0;36m\]\w\[\033[00m\] $(parse_git_branch): '
else
export PS1='\u@\h \[\033[0;36m\]\w\[\033[00m\]: '
fi
#!/bin/sh
set -e
sudo apt-get upgrade
# Basic packages
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf \
libc6-dev ncurses-dev automake libtool
# For mac pros running Ubuntu
# Add repo for macfanctld
#sudo add-apt-repository ppa:mactel-support/ppa
#sudo apt-get upgrade
# Manages the macbook pro fan
#sudo apt-get install macfanctld
# Load indicator
#sudo apt-get install indicator-multiload
# Change F* keys to function actions https://help.ubuntu.com/community/AppleKeyboard
@brunoadacosta
Copy link

Uso assim..

PS1='[\u:[\033[1;33m]\W[\033[0m]] [\033[1;34m]~/.rvm/bin/rvm-prompt i v g[\033[0m] $(__git_ps1 "[\0331;32m[\033[0m]"): $ '

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