1
0
mirror of https://github.com/kremalicious/dotfiles.git synced 2024-11-22 01:37:14 +01:00

reorg, switch to different bash_prompt

This commit is contained in:
Matthias Kretschmann 2012-06-18 21:46:35 +02:00
parent 382fb6ade9
commit 2509c1327d
7 changed files with 72 additions and 80 deletions

View File

@ -28,8 +28,18 @@ unset MAILCHECK
# PATH # PATH
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin";
PATH="/usr/local/bin:/usr/local/mysql/bin:$PATH"
# if these bins exist, then add them to the PATH
# Android SDK
ANDROID_HOME="/usr/local/Cellar/android-sdk/r18"
[ -d "$ANDROID_HOME" ] && PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools";
# add to beginning of PATH so that it always take precedence over /usr/bin
[ -d "/usr/local/bin" ] && PATH="/usr/local/bin:$PATH";
[ -d "/usr/local/mysql/bin" ] && PATH="/usr/local/mysql/bin:$PATH";
export PATH
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# ALIASES # ALIASES

View File

@ -1,86 +1,59 @@
######################################################################## ########################################################################
# bash_prompt, from @necolas # bash_prompt, from @mathiasbynens
# https://github.com/necolas/dotfiles/blob/master/bash/bash_prompt # https://github.com/mathiasbynens/dotfiles/blob/master/.bash_prompt
######################################################################## ########################################################################
# Based on @gf3s Sexy Bash Prompt: https://github.com/gf3/dotfiles # @gf3s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# iTerm2 prefs: import Solarized theme (disable bright colors for bold text) # Shamelessly copied from https://github.com/gf3/dotfiles
# Color ref: http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim # Screenshot: http://i.imgur.com/s0Blh.png
# More tips: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
# Screenshot: http://i.imgur.com/DSJ1G.png
# Example: if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
# nicolas@host: ~/.dotfiles on master[!?] export TERM=gnome-256color
# $ elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
# Check that terminfo exists before changing TERM var to xterm-256color
# Prevents prompt flashing in Mac OS X 10.6 Terminal.app
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
fi fi
tput sgr 0 0 if tput setaf 1 &> /dev/null; then
tput sgr0
# Base styles and color palette if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
# Solarized colors MAGENTA=$(tput setaf 9)
# https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized ORANGE=$(tput setaf 172)
BOLD=$(tput bold) GREEN=$(tput setaf 190)
RESET=$(tput sgr0) PURPLE=$(tput setaf 141)
SOLAR_YELLOW=$(tput setaf 136) WHITE=$(tput setaf 256)
SOLAR_ORANGE=$(tput setaf 166) else
SOLAR_RED=$(tput setaf 124) MAGENTA=$(tput setaf 5)
SOLAR_MAGENTA=$(tput setaf 125) ORANGE=$(tput setaf 4)
SOLAR_VIOLET=$(tput setaf 61) GREEN=$(tput setaf 2)
SOLAR_BLUE=$(tput setaf 33) PURPLE=$(tput setaf 1)
SOLAR_CYAN=$(tput setaf 37) WHITE=$(tput setaf 7)
SOLAR_GREEN=$(tput setaf 64) fi
SOLAR_WHITE=$(tput setaf 254) BOLD=$(tput bold)
RESET=$(tput sgr0)
style_user="\[${RESET}${SOLAR_ORANGE}\]" else
style_host="\[${RESET}${SOLAR_YELLOW}\]" MAGENTA="\033[1;31m"
style_path="\[${RESET}${SOLAR_GREEN}\]" ORANGE="\033[1;33m"
style_chars="\[${RESET}${SOLAR_WHITE}\]" GREEN="\033[1;32m"
style_branch="${SOLAR_CYAN}" PURPLE="\033[1;35m"
WHITE="\033[1;37m"
if [[ "$SSH_TTY" ]]; then BOLD=""
# connected via ssh RESET="\033[m"
style_host="\[${BOLD}${SOLAR_RED}\]"
elif [[ "$USER" == "root" ]]; then
# logged in as root
style_user="\[${BOLD}${SOLAR_RED}\]"
fi fi
export MAGENTA
export ORANGE
export GREEN
export PURPLE
export WHITE
export BOLD
export RESET
# Git status. function parse_git_dirty() {
# Adapted from: https://github.com/cowboy/dotfiles/ [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
function prompt_git() {
local status output flags
status="$(git status 2>/dev/null)"
[[ $? != 0 ]] && return;
output="$(echo "$status" | awk '/# Initial commit/ {print "(init)"}')"
[[ "$output" ]] || output="$(echo "$status" | awk '/# On branch/ {print $4}')"
[[ "$output" ]] || output="$(git branch | perl -ne '/^\* (.*)/ && print $1')"
flags="$(
echo "$status" | awk 'BEGIN {r=""} \
/^# Changes to be committed:$/ {r=r "+"}\
/^# Changes not staged for commit:$/ {r=r "!"}\
/^# Untracked files:$/ {r=r "?"}\
END {print r}'
)"
if [[ "$flags" ]]; then
output="$output[$flags]"
fi
echo -ne "${SOLAR_WHITE} on ${style_branch}${output}"
} }
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# Build the prompt PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
PS1="\n" # Newline
PS1+="${style_user}\u" # Username
PS1+="${style_chars}@" # @
PS1+="${style_host}\h" # Host
PS1+="${style_chars}: " # :
PS1+="${style_path}\w" # Working directory
PS1+="\$(prompt_git)" # Git details
PS1+="\n" # Newline
PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color)

1
bashrc Normal file
View File

@ -0,0 +1 @@
[ -n "$PS1" ] && source ~/.bash_profile

10
brew Normal file
View File

@ -0,0 +1,10 @@
# Make sure were using the latest Homebrew
brew update
# Upgrade any already-installed formulae
brew upgrade
# Install what we need
brew install git
brew install node
brew install android

View File

@ -14,7 +14,7 @@
# dotfiles directory # dotfiles directory
dir=~/.dotfiles dir=~/.dotfiles
# list of files/folders to symlink in homedir # list of files/folders to symlink in homedir
files="bash_profile bash_prompt gitconfig gitignore_global hushlogin private" files="bashrc bash_profile bash_prompt gitconfig gitignore_global hushlogin private"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# change to the dotfiles directory # change to the dotfiles directory

View File

@ -1,5 +1,3 @@
#!/bin/bash
#
# OS X defaults # OS X defaults
# #
# most of it taken from @mathiasbynens # most of it taken from @mathiasbynens

View File

@ -14,7 +14,7 @@
# dotfiles directory # dotfiles directory
dir=~/.dotfiles dir=~/.dotfiles
# list of files/folders to symlink in homedir # list of files/folders to symlink in homedir
files="bash_profile bash_prompt gitconfig gitignore_global hushlogin private" files="bashrc bash_profile bash_prompt gitconfig gitignore_global hushlogin private"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# change to the dotfiles directory # change to the dotfiles directory