Skip to content

Instantly share code, notes, and snippets.

@dmfrancisco
Last active September 24, 2017 06:11
Show Gist options
  • Save dmfrancisco/8dc4057a8585af2de0c9 to your computer and use it in GitHub Desktop.
Save dmfrancisco/8dc4057a8585af2de0c9 to your computer and use it in GitHub Desktop.
dotfiles for Unix and Unix-like Operating Systems

Super quick installation (for the lazy ones)

$ curl https://gist.githubusercontent.com/dmfrancisco/8dc4057a8585af2de0c9/raw/install.sh | sh

If you're running Linux replace curl with wget -qO-.
Restart your bash shell to put the changes in effect.


Installing this manually

Clone this repository to add these shared configurations to your system:

git clone https://gist.githubusercontent.com/8dc4057a8585af2de0c9.git
mv 8dc4057a8585af2de0c9 ~/.shared_dotfiles

Edit your .bashrc file and add the following to the top:

source ~/.shared_dotfiles/bashrc

# Other personal settings go here

Edit your .vimrc file and add the following to the top:

source ~/.shared_dotfiles/vimrc

" Other personal settings go here

Edit your .inputrc file and add the following to the top:

$include ~/.shared_dotfiles/inputrc

# Other personal settings go here

Restart your bash shell to put the changes in effect.


Grab updates

To pull new changes do as usual:

$ cd ~/.shared_dotfiles/ && git pull && cd -

You can also use the following alias: update-dotfiles


Uninstall (requires ruby >= 1.8.7)

$ curl https://gist.githubusercontent.com/dmfrancisco/8dc4057a8585af2de0c9/raw/uninstall.sh | sh

If you're running Linux replace curl with wget -qO-.
Restart your bash shell to complete the uninstallation.

# Update the shared dotfiles repository
alias update-dotfiles="cd ~/.shared_dotfiles/ && git pull && cd -"
# Set the default editor
# export EDITOR="subl -w" # -w forces sublime text to wait until the user exits
export EDITOR="vim"
#
# Aliases
#
# Python and Django
alias workon="pythonbrew venv use"
alias workoff="deactivate"
alias newdjango="django-admin.py startproject"
alias shell="python manage.py shell"
alias runserver="python manage.py runserver"
alias syncdb="python manage.py syncdb"
alias compilemsg="django-admin.py compilemessages"
alias cleanpyc="find . -name '*.pyc' -delete" # Recursively delete `.pyc` files
# Ruby
alias b="bundle exec"
# Git
alias ga="git add"
alias gd="git diff"
alias gc="git commit" # Suggestion: Don't use '-m'. Git will open Vim so you can check if your message < 50 chars
alias gs="git status"
alias gl="git log --pretty=format:'%h%x09%an%x09%ad%x09%s'"
alias gg="git log --all --graph --decorate --oneline -n60" # Suggestion: Add an alias 'git graph' to your '.gitconfig' as well
# Others
alias desk="cd ~/Desktop/"
alias o="open"
alias c="clear"
# Check out the last commands that were executed and run one with: !<entry-number>
#
# Example:
# $ hist
# 550 vim .bash_profile
# 551 ssh test
# 552 ssh prod
# 553 hist
# $ !550
# # This runs `vim .bash_profile`
#
alias hist="history | tail"
# More aliases from git.io/dotfiles
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# List all files colorized in long format
alias l="ls -l ${colorflag}"
# List all files colorized in long format, including dot files
alias la="ls -la ${colorflag}"
# List only directories
alias lsd='ls -l ${colorflag} | grep "^d"'
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
# Enable aliases to be sudo’ed
alias sudo='sudo '
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[B": history-search-forward
"\e[A": history-search-backward
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
# Use Alt/Meta + Delete to delete the preceding word
"\e[3;3~": kill-word
#!/bin/sh
# Clone the repo
git clone https://gist.githubusercontent.com/8dc4057a8585af2de0c9.git ~/.shared_dotfiles
# Load dotfiles
echo "source ~/.shared_dotfiles/bashrc" >> ~/.bashrc
echo "source ~/.shared_dotfiles/vimrc" >> ~/.vimrc
echo "\$include ~/.shared_dotfiles/inputrc" >> ~/.inputrc
# That's it
echo "Done."
#!/bin/sh
# .-""""""-.
# .' '.
# / O O \
# : ` :
# | | sad
# : .------. :
# \ ' ' /
# '. .'
# '-......-'
# Backup all dotfiles
mkdir -p ~/.backup_dotfiles
cp ~/.bashrc ~/.backup_dotfiles/bashrc.backup
cp ~/.vimrc ~/.backup_dotfiles/vimrc.backup
cp ~/.inputrc ~/.backup_dotfiles/inputrc.backup
# Remove the echoed lines to new dotfiles
ruby -ne "puts \$_ unless \$_.include? 'source ~/.shared_dotfiles/bashrc'" ~/.bashrc > ~/.bashrc.new
ruby -ne "puts \$_ unless \$_.include? 'source ~/.shared_dotfiles/vimrc'" ~/.vimrc > ~/.vimrc.new
ruby -ne "puts \$_ unless \$_.include? '$include ~/.shared_dotfiles/inputrc'" ~/.inputrc > ~/.inputrc.new
# Replace the old dotfiles with the new ones
mv ~/.bashrc.new ~/.bashrc
mv ~/.vimrc.new ~/.vimrc
mv ~/.inputrc.new ~/.inputrc
echo "Done. Backups of each dotfile were saved into ~/.backup_dotfiles"
echo "You can now delete the repo like this:"
echo "rm -rf ~/.shared_dotfiles"
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Turn on syntax highlighting and set up the theme
syntax on
" colorscheme Tomorrow-Night " Color scheme available at http://git.io/TTM8GQ
" General configurations
set number " Line numbers are good
set backspace=indent,eol,start " Allow backspace in insert mode
set history=1000 " Store lots of :cmdline history
set showcmd " Show incomplete cmds down the bottom
set showmode " Show current mode down the bottom
set gcr=a:blinkon0 " Disable cursor blink
set visualbell " No sounds
set autoread " Reload files changed outside vim
" This makes vim act like all other editors, buffers can
" exist in the background without being in a window.
" http://items.sjbach.com/319/configuring-vim-right
set hidden
" Search settings
set incsearch " Find the next match as we type the search
set hlsearch " Hilight searches by default
set viminfo='100,f1 " Save up to 100 marks, enable capital marks
" Turn off swap files
" set noswapfile
" set nobackup
" set nowb
" Persistent undo
" Keep undo history across sessions, by storing in file.
" Only works all the time.
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
" Indentation
" set autoindent
" set smartindent
" set smarttab
" set shiftwidth=2
set softtabstop=2
set tabstop=2
" set expandtab
" filetype plugin on
" filetype indent on
" Display tabs and trailing spaces visually
" set list listchars=tab:\ \ ,trail:·
set nowrap " Don't wrap lines
set linebreak " Wrap lines at convenient points
" Folds
set foldmethod=indent " Fold based on indent
set foldnestmax=3 " Deepest fold is 3 levels
set nofoldenable " Dont fold by default
" Scrolling
set scrolloff=8 " Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
" Display a vertical ruler (from stackoverflow.com/a/3765575/543293)
if exists('+colorcolumn')
" 50 is useful for git commit messages
" 72 is the recommended length for the body of a git commit message
" 90 is what I use for code (some people prefer 80)
set colorcolumn=50,72,90
endif
@dmfrancisco
Copy link
Author

@rjfv If you find a fix for the one-line command bug that happens to the prompt, let me know! 😉

@dmfrancisco
Copy link
Author

Added some new aliases for Git:

ga="git add"
gd="git diff"
gc="git commit" # Tip: Don't use -m. Git will open Vim so you can check if the message < 50 chars
gs="git status"
gl="git log --pretty=format:'%h%x09%an%x09%ad%x09%s'"
gg="git log --all --graph --decorate --oneline -n60" # Tip: Add 'git graph' to .gitconfig as well

Example output for gg:

Git graph

@rjvitorino
Copy link

@dpflucas
Copy link

Why wasn't I using this? :)

Btw, I also use this for git:

gr="git rebase"
gpl="git pull"
gps="git push"

@dmfrancisco
Copy link
Author

I just found out about this gem called git-smart. I find git smart-pull to be extremely helpful 😃 It also has a git smart-log that is similar to our git graph but better, with relative timestamps and author.

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