Skip to content

Instantly share code, notes, and snippets.

@lrivallain
Last active August 29, 2015 14:01
Show Gist options
  • Save lrivallain/9a4cf9c24ece770b98c0 to your computer and use it in GitHub Desktop.
Save lrivallain/9a4cf9c24ece770b98c0 to your computer and use it in GitHub Desktop.
My custom dotfiles (⇨ ~/)
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
# Bash completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
########################################################################
# do nothing during non interactive session
[ -z "$PS1" ] && return
########################################################################
# completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
########################################################################
# completion for sudo
if [ "$PS1" ]; then
complete -cf sudo
fi
########################################################################
# ajouter ~/bin dans le path
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi
########################################################################
# very simple prompt
# PS1="\[\e[38;5;82m\]\u\[\e[00m\]:\[\e[38;5;33m\]\w\[\e[00m\]\$ "
########################################################################
# Full custom prompt
# display a flag when last command is failed
LastCommandResult='$([[ $? = 0 ]] && printf "➤" || printf "🚩 ")'
# display current git status if you are in a git repository
function getGitChanges() {
ret=$? # to keep last command result in prompt
[ -n "`git st -s 2>/dev/null`" ] && printf "* " || printf ""
return $ret # to keep last command result in prompt (bis)
}
CurrentGitChanges='$(getGitChanges)'
# display current git branch if you are in a git repository
function getGitBranch() {
ret=$? # to keep last command result in prompt
CurrentGitBranch="`git branch 2>/dev/null | awk '{print $2}'`"
[ -n "$CurrentGitBranch" ] && printf "($CurrentGitBranch) " || printf ""
return $ret # to keep last command result in prompt (bis)
}
CurrentGitBranch='$(getGitBranch)'
# build prompt
PS1="\[\e[38;5;250m\]\[\e[48;5;240m\]\u \[\e[48;5;31m\]\[\e[38;5;240m\]▶" # user part
PS1="$PS1\[\e[38;5;15m\]\[\e[48;5;31m\] \h \[\e[48;5;237m\]\[\e[38;5;31m\]▶" # host part
PS1="$PS1\[\e[38;5;254m\]\[\e[48;5;237m\] \w \[\e[0m\]\n" # current path
PS1="$PS1\[\e[38;5;208m\]$CurrentGitChanges\[\e[38;5;31m\]$CurrentGitBranch" # git infos (changes? branch?)
PS1="$PS1\[\e[38;1;32m\]$LastCommandResult\[\e[0m\] " # last command succeed?
##############
# no double in history
export HISTCONTROL=ignoredups
# max session history size
export HISTSIZE=5000
# max history size
export HISTFILESIZE=20000
# favorite editor
export EDITOR=vim
########################################################################
# resizable terms (xterm et screen -r)
shopt -s checkwinsize
# allow to send complex char to shell
bind 'set convert-meta off'
########################################################################
# list with details
alias ll='ls -l'
# list with colors
alias ls='ls -G'
# grep with colors
alias grep='grep --color=auto'
# agenda
alias c='var=$(cal -m); echo "${var/$(date +%-d)/$(echo -e "\033[1;31m$(date +%-d)\033[0m")}"'
# disk-usage human readable
alias du='du -h'
# sorted disk-usage
alias dusort='du -x --block-size=1048576 | sort -nr'
# df human readable
alias df='df -h'
# vim instead of vim
alias vi='vim'
# kept environment for sudo commands
alias sudo='sudo '
# defaut ps for current user
alias myps='ps ux'
########################################################################
# UTF-8 locales
export LANG=french
export LC_CTYPE="fr_FR.UTF-8"
export LC_NUMERIC="fr_FR.UTF-8"
export LC_TIME="fr_FR.UTF-8"
export LC_COLLATE="fr_FR.UTF-8"
export LC_MONETARY="fr_FR.UTF-8"
export LC_MESSAGES="fr_FR.UTF-8"
export LC_PAPER="fr_FR.UTF-8"
export LC_NAME="fr_FR.UTF-8"
export LC_ADDRESS="fr_FR.UTF-8"
export LC_TELEPHONE="fr_FR.UTF-8"
export LC_MEASUREMENT="fr_FR.UTF-8"
export LC_IDENTIFICATION="fr_FR.UTF-8"
export LC_ALL="fr_FR.UTF-8"
########################################################################
# other included rc files
if [ -f ~/bin/dockerrc ]; then
. ~/bin/dockerrc
fi
if [ -f ~/bin/custombashfunctionsrc ]; then
. ~/bin/custombashfunctionsrc
fi
" where vim store temparary files
set dir=~/.tmp
" not vi-compatible
set nocompatible
" current command
set showcmd
" highlight all the matches of search pattern
set hlsearch
" start searching when you type the first character of the search string
set incsearch
" UTF-8 by default
set fileencoding=utf-8
" syntax colors
syntax on
" work mainly on dark background
set background=dark
" 256 color mode
set t_Co=256
" favorite theme
colorscheme inkpot
" no-auto-indent
set noautoindent
" 4 spaces instead of <tab>
set expandtab
" 4 spaces tabs
set shiftwidth=4
" 4 spaces moves on < and >
set smarttab
" no bell on error
set noerrorbells
" visual bell on error instead sound one
set visualbell
" show corresponding (>) {>} [>]...
set showmatch
# How to get my dotfiles in your env?
cd ~
wget -q -O .bash_profile https://gist.github.com/lrivallain/9a4cf9c24ece770b98c0#file-bash_profile
wget -q -O .bashrc https://gist.github.com/lrivallain/9a4cf9c24ece770b98c0#file-bashrc
wget -q -O .vimrc https://gist.github.com/lrivallain/9a4cf9c24ece770b98c0#file-vimrc
# apply .bash_profile and .bashrc
. .bash_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment