Skip to content

Instantly share code, notes, and snippets.

@ro-fdm
Last active August 3, 2017 15:33
Show Gist options
  • Save ro-fdm/45a62607d72a3f9aadeb to your computer and use it in GitHub Desktop.
Save ro-fdm/45a62607d72a3f9aadeb to your computer and use it in GitHub Desktop.
Git desde inicio en nueva maquina
alias bash='bash --login'
alias ls='ls --color'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias t='tailf'
alias c='ccze -A'
alias ag='ack-grep'
alias g='git'
alias e='gvim '
alias 'e.'='e .'
alias ..='cd ..;'
alias f='find . -iname'
alias sv="svn"
alias ack=ack-grep
alias nox='xset dpms force off'
alias tmux='tmux -2 -u '
alias r='rails '
alias shl="/usr/bin/source-highlight -fesc -oSTDOUT -i "
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
function show-empty-folders {
find . -depth -type d -empty
}
function kill-empty-folders {
find . -depth -type d -empty -exec rmdir "{}" \;
}
function rubyVersion {
rvm current
}
## Tab Completions
set completion-ignore-case On
## Custom prompt
# Colors
RED="\[\033[0;31m\]"
PINK="\[\033[1;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
LT_GREEN="\[\033[1;32m\]"
BLUE="\[\033[0;34m\]"
LT_BLUE="\[\033[1;34m\]"
WHITE="\[\033[1;37m\]"
PURPLE="\[\033[1;35m\]"
CYAN="\[\033[1;36m\]"
BROWN="\[\033[0;33m\]"
COLOR_NONE="\[\033[0m\]"
LIGHTNING_BOLT="⚡"
UP_ARROW="↑"
DOWN_ARROW="↓"
UD_ARROW="↕"
FF_ARROW="→"
RECYCLE="♺"
MIDDOT="•"
PLUSMINUS="±"
function parse_git_branch {
branch_pattern="^On branch ([^${IFS}]*)"
remote_pattern_ahead="Your branch is ahead of"
remote_pattern_behind="Your branch is behind"
remote_pattern_ff="Your branch (.*) can be fast-forwarded."
diverge_pattern="Your branch and (.*) have diverged"
git_status="$(LANG=en_US git status 2> /dev/null)"
if [[ ! ${git_status} =~ ${branch_pattern} ]]; then
# Rebasing?
toplevel=$(git rev-parse --show-toplevel 2> /dev/null)
[[ -z "$toplevel" ]] && return
[[ -d "$toplevel/.git/rebase-merge" || -d "$toplevel/.git/rebase-apply" ]] && {
sha_file="$toplevel/.git/rebase-merge/stopped-sha"
[[ -e "$sha_file" ]] && {
sha=`cat "${sha_file}"`
}
echo "${PINK}(rebase in progress)${COLOR_NONE} ${sha}"
}
return
fi
last_commit_date=$(git log -1 --date=short --pretty=format:%ad)
branch=${BASH_REMATCH[1]}
# Dirty?
if [[ ! ${git_status} =~ "working directory clean" ]]; then
[[ ${git_status} =~ "modified:" ]] && {
git_is_dirty="${RED}${LIGHTNING_BOLT}"
}
[[ ${git_status} =~ "Untracked files" ]] && {
git_is_dirty="${git_is_dirty}${WHITE}${MIDDOT}"
}
[[ ${git_status} =~ "new file:" ]] && {
git_is_dirty="${git_is_dirty}${GREEN}+"
}
[[ ${git_status} =~ "deleted:" ]] && {
git_is_dirty="${git_is_dirty}${RED}-"
}
[[ ${git_status} =~ "renamed:" ]] && {
git_is_dirty="${git_is_dirty}${BROWN}→"
}
fi
# Are we ahead of, beind, or diverged from the remote?
if [[ ${git_status} =~ ${remote_pattern_ahead} ]]; then
remote="${BROWN}${UP_ARROW}"
elif [[ ${git_status} =~ ${remote_pattern_ff} ]]; then
remote_ff="${WHITE}${FF_ARROW}"
elif [[ ${git_status} =~ ${remote_pattern_behind} ]]; then
remote="${BROWN}${DOWN_ARROW}"
elif [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="${BROWN}${UD_ARROW}"
fi
echo "${remote}${remote_ff}${PURPLE}(${branch} ${last_commit_date})${COLOR_NONE}${git_is_dirty} ${COLOR_NONE}"
}
function setWindowTitle {
case $TERM in
*xterm*|ansi)
echo -n -e "\033]0;$*\007"
;;
esac
}
function set_prompt {
[[ -n $HOMEBREW_DEBUG_INSTALL ]] && \
homebrew_prompt="${BROWN}Homebrew:${COLOR_NONE} debugging ${HOMEBREW_DEBUG_INSTALL}\n"
git_prompt="$(parse_git_branch)"
ruby_prompt="$(rubyVersion)"
export PS1="${BROWN}\u${COLOR_NONE}@${GREEN}\h ${BLUE}\w${COLOR_NONE} ${git_prompt} ${COLOR_NONE}${homebrew_prompt}$RED[${ruby_prompt}]$COLOR_NONE\n\$ "
# Domain is stripped from hostname
case $HOSTNAME in
adamv-desktop.local|Flangymobile08.local)
this_host=
;;
*)
this_host="${HOSTNAME%%.*}:"
;;
esac
setWindowTitle "${this_host}${PWD/$HOME/~}"
}
export PROMPT_COMMAND=set_prompt
function git-root {
root=$(git rev-parse --git-dir 2> /dev/null)
[[ -z "$root" ]] && root="."
dirname $root
}
# Reveal current or provided folder in Path Finder
function pf {
target_path="$(cd ${1:-"$PWD"} && PWD)"
osascript<<END
tell app "Path Finder"
reveal POSIX file("$target_path")
activate
end tell
END
}
# Open a manpage in Preview, which can be saved to PDF
function pman {
man -t "${1}" | open -f -a /Applications/Preview.app
}
# Open a manpage in the browser
function bman {
man "${1}" | man2html | browser
}
function pgrep {
local exclude="\.svn|\.git|\.swp|\.coverage|\.pyc|_build"
find . -maxdepth 1 -mindepth 1 | egrep -v "$exclude" | xargs egrep -lir "$1" | egrep -v "$exclude" | xargs egrep -Hin --color "$1"
}
Pasos de git set
https://help.github.com/articles/set-up-git/
pasos de ssh
https://help.github.com/articles/generating-ssh-keys/
luego git clone ssh repositorio, SI LO HACES DESDE HTTPS TE PEDIRA CONTRASEÑA ALL TIME
@ro-fdm
Copy link
Author

ro-fdm commented Jul 1, 2015

En ~/.bashrc debe poner:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

if [ -f ~/.bash_prompt ]; then
    . ~/.bash_prompt
fi

@ro-fdm
Copy link
Author

ro-fdm commented Jul 1, 2015

los archivos van dentro de home/user
en debian: instalar curl (que es un cliente http para la consola) y rvm
rvm: seguir las instrucciones de
http://rubyonrails.org.es/instala.html

@ro-fdm
Copy link
Author

ro-fdm commented Aug 3, 2017

si te has copiado las llaves ssh de otro ordenador les pueden faltar los permisos.
Hacer chmod +600 ~/.ssh/*
y luego probar con ssh -v git@github.com para ver si te devuelvt un you ve succesfully authenticated

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