diff --git a/README b/README new file mode 100644 index 0000000..667fa55 --- /dev/null +++ b/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: +
+  . ~/bin/dotfiles/bashrc
+
+ +In .bashprofile +
+  if [ -f ~/.bashrc ];
+  then
+      source ~/.bashrc
+  fi    
+
\ No newline at end of file diff --git a/bash/aliases b/bash/aliases index 0bd32b1..5f60ac8 100755 --- a/bash/aliases +++ b/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\]" @@ -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 "$*" diff --git a/bash/config b/bash/config index e70aa60..858436e 100755 --- a/bash/config +++ b/bash/config @@ -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}" \ No newline at end of file +# 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}" diff --git a/bash/env b/bash/env index 79633f9..18b7ba9 100755 --- a/bash/env +++ b/bash/env @@ -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 \ No newline at end of file diff --git a/bash/irbrc b/bash/irbrc index e69de29..e3f318b 100755 --- a/bash/irbrc +++ b/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