Skip to content

Commit

Permalink
cleanning the house
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvlopes committed Jul 30, 2010
1 parent f3b8323 commit bc14e3f
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 10 deletions.
20 changes: 20 additions & 0 deletions README
@@ -0,0 +1,20 @@
h1. My DotFiles

This project holds all my custom binnary files and also non-default OSX like a2ensite, ssh-copy-id and etc. I also store all my configurations for my bash (including aliases, PS1, colors, etc), ssh and ruby rvm.

h3. Usage

My organization is a litle bit diferent because how I don't use the default .bashrc and .bashprofile you should require correct files.

In .bashrc place this:
<pre>
. ~/bin/dotfiles/bashrc
</pre>

In .bashprofile
<pre>
if [ -f ~/.bashrc ];
then
source ~/.bashrc
fi
</pre>
13 changes: 4 additions & 9 deletions bash/aliases
@@ -1,10 +1,10 @@
# Command Enhancements

# Utility
alias reload='source ~/bin/dotfiles/bash/aliases'
alias ea='mate -w ~/bin/dotfiles/bash/aliases && reload' # Edit aliases
alias ec='mate -w ~/bin/dotfiles/bash/config && reload' # Edit config
alias ee='mate -w ~/bin/dotfiles/bash/env && reload' # Edit env
alias reload='source ~/etc/bash/aliases'
alias ea='mate -w ~/etc/bash/aliases && reload' # Edit aliases
alias ec='mate -w ~/etc/bash/config && reload' # Edit config
alias ee='mate -w ~/etc/bash/env && reload' # Edit env

function ps1 {
PS1="\[$ESC[${DULL};${FG_GREEN}m\]\n\u:\[$ESC[${DULL};${FG_YELLOW}m\]$1 \$ \[$ESC[${DULL};${FG_WHITE};${BG_NULL}m\]"
Expand Down Expand Up @@ -63,11 +63,6 @@ alias gs='git status'
alias gru='git reset --hard HEAD'
alias eg='mate .git/config'

function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}

# Commit pending changes and quote all args as message
function gg() {
git commit -v -a -m "$*"
Expand Down
28 changes: 27 additions & 1 deletion bash/config
Expand Up @@ -43,4 +43,30 @@ BRIGHT_VIOLET="\[$ESC[${BRIGHT};${FG_VIOLET}m\]"
BRIGHT_CYAN="\[$ESC[${BRIGHT};${FG_CYAN}m\]"
BRIGHT_WHITE="\[$ESC[${BRIGHT};${FG_WHITE}m\]"

PS1="$BLUE\n\u:$GREEN\w $VIOLET\$(parse_git_branch)${NORMAL}\$ ${RESET}"
# works with rvm
__ruby_version() {
which ruby | cut -d/ -f6
}

__gemset() {
echo $GEM_PATH | cut -d@ -f2 | cut -d: -f1
}

__git_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}


####### history file
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
PROMPT_COMMAND='history -a'
export HISTSIZE=100000


PS1="$BLUE\n\u:$GREEN\w $RED(\$(__gemset)) $VIOLET\$(__git_branch) ${NORMAL}\$ ${RESET}"
24 changes: 24 additions & 0 deletions bash/env
Expand Up @@ -2,4 +2,28 @@ export EDITOR="mate -w"
export LC_CTYPE=en_US.UTF-8
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:~/etc/bin:~/.rvm/scripts:${PATH}

# preserve last path on new tabs
cd () {
builtin cd "$@";
local cwd;
cwd=$(pwd);
while :; do
if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]]; then
if [[ "$rvm_project_rvmrc_default" = 1 ]]; then
rvm default > /dev/null 2>&1;
fi;
break;
else
if [[ -f "$cwd/.rvmrc" ]]; then
source "$cwd/.rvmrc";
break;
else
cwd=$(dirname "$cwd");
fi;
fi;
done

echo $PWD > ~/.pwd;
}

if [[ -f ~/.pwd ]] ; then cd `cat ~/.pwd` ; fi
90 changes: 90 additions & 0 deletions bash/irbrc
@@ -0,0 +1,90 @@
require "irb/completion" # activate default completion
require 'irb/ext/save-history' # activate default history
require "tempfile" # used for Vim integration
require 'pp'

# save history using built-in options
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"

# auto-indent
IRB.conf[:AUTO_INDENT]=true

# try to load rubygems
begin
require "rubygems"
rescue LoadError => e
puts "Seems you don't have Rubygems installed: #{e}"
end

# let there be colors
# just use Wirble for colors, since some enviroments dont have
# rubygems and wirble installed
begin
require "wirble"
Wirble.init(:skip_prompt=>true,:skip_history=>true)
Wirble.colorize
rescue LoadError => e
end

# enabling Hirb
begin
require 'hirb'
Hirb.enable
rescue LoadError => e
end

# configure vim
@irb_temp_code = nil

def vim(file=nil)
file = file || @irb_temp_code || Tempfile.new("irb_tempfile").path+".rb"
system("vim #{file}")
if(File.exists?(file) && File.size(file)>0)
Object.class_eval(File.read(file))
@irb_temp_code = file
else
"No file loaded."
end
rescue => e
puts "Error on vim: #{e}"
end

class Object
# get all the methods for an object that aren't basic methods from Object
def my_methods
(methods - Object.instance_methods).sort
end
end

# from http://themomorohoax.com/2009/03/27/irb-tip-load-files-faster
def ls
%x{ls}.split("\n")
end

def cd(dir)
Dir.chdir(dir)
Dir.pwd
end

def pwd
Dir.pwd
end

# also from http://themomorohoax.com/2009/03/27/irb-tip-load-files-faster
def rl(file_name = nil)
if file_name.nil?
if !@recent.nil?
rl(@recent)
else
puts "No recent file to reload"
end
else
file_name += '.rb' unless file_name =~ /\.rb/
@recent = file_name
load "#{file_name}"
end
end

alias p pp
alias quit exit

0 comments on commit bc14e3f

Please sign in to comment.