Skip to content

Instantly share code, notes, and snippets.

@xenda
Created October 1, 2009 01:30
Show Gist options
  • Save xenda/198630 to your computer and use it in GitHub Desktop.
Save xenda/198630 to your computer and use it in GitHub Desktop.
My .irbrc and .bash_profile files with some changes
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$BLUE[$RED\$(date +%H:%M)$BLUE]\
$BLUE[$LIGHT_RED\w$GREEN\$(parse_git_branch)$BLUE]\
$GREEN\$ "
PS2='> '
PS4='+ '
}
proml
export PATH=/usr/local/git:/usr/local/git/bin:/opt/local/bin/:/usr/local/mysql/bin:$PATH
alias skykids_ssh="ssh [email protected] -p 30000"
alias server="ssh [email protected]"
alias tailn="tail -f -n 100"
##
# Your previous /Users/alvaropereyrarabanal/.bash_profile file was backed up as /Users/alvaropereyrarabanal/.bash_profile.macports-saved_2009-08-30_at_08:12:49
##
# MacPorts Installer addition on 2009-08-30_at_08:12:49: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegebabagacad
begin
# load wirble
require 'rubygems'
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
require 'Hirb'
Hirb.enable
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
rescue LoadError => err
warn "Couldn't load Wirble: #{err}"
end
set autoindent
set multibuffer
set tabsize 4
Autocompletado de branch con GIT:
Descargar: http://kernel.org/pub/software/scm/git/git-1.5.4.3.tar.bz2
Copiar: - git-1.5.4.3/contrib/completion/git-completion.bash
- /opt/local/etc/bash_completion.d/git-completion
Done!
require 'readline'
def git_branch
`git branch | grep "*"`.strip[2..-1]
end
def compare_git_ver
m = /git version (\d+).(\d+).(\d+)/.match(`git version`.strip)
return true if m[1].to_i > 1
return false if m[1].to_i < 1
return true if m[2].to_i > 5
return false if m[2].to_i < 5
return true if m[3].to_i >= 3
return false
end
def check_git_ver
raise "Invalid git version, use at least 1.5.3" unless compare_git_ver
end
namespace :git do
desc "Show the current status of the checkout"
task :status do
system "git status"
end
desc "Create a new topic branch"
task :topic do
total = `git branch`.scan("quick").size
if total == 0
default = "quick"
else
default = "quick#{total + 1}"
end
name = Readline.readline "Topic name (default #{default}): "
if name.strip.empty?
name = default
end
sh "git checkout -b #{name}"
end
desc "Push all changes to the repository"
task :push => :update do
branch = git_branch()
if branch != "master"
`git diff-files --quiet`
if $?.exitstatus == 1
puts "You have outstanding changes. Please commit them first."
exit 1
end
puts "* Merging topic '#{branch}' back into master..."
`git checkout master`
sh "git merge #{branch}"
switch = true
else
switch = false
end
puts "* Pushing changes..."
sh "git push"
if switch
puts "* Switching back to #{branch}..."
`git checkout #{branch}`
end
end
desc "Pull new commits from the repository"
task :update do
check_git_ver
`git diff-files --quiet`
if $?.exitstatus == 1
stash = true
clear = `git stash list`.scan("\n").size == 0
puts "* Saving changes..."
`git stash save`
else
stash = false
end
branch = git_branch()
if branch != "master"
switch = true
`git checkout master`
puts "* Switching back to master..."
else
switch = false
end
puts "* Pulling in new commits..."
sh "git fetch"
sh "git rebase origin"
if switch
puts "* Porting changes into #{branch}..."
`git checkout #{branch}`
sh "git rebase master"
end
if stash
puts "* Applying changes..."
sh "git stash apply"
`git stash clear` if clear
end
end
task :pull => :update
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment