Last active
April 17, 2019 19:40
-
-
Save dgoguerra/c753bd6699f57ded7cc3 to your computer and use it in GitHub Desktop.
My dotfiles (.gitconfig with git aliases, .bash_profile, etc.). Old! Now at: https://github.com/dgoguerra/dotfiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LC_ALL=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export HISTCONTROL=ignorespace | |
# http://unix.stackexchange.com/a/81699 | |
alias wanip='dig +short myip.opendns.com @resolver1.opendns.com' | |
# http://stackoverflow.com/a/13322549 | |
alias lanip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'" | |
# https://twitter.com/tnorthcutt/status/1037850747474309120 | |
alias ocr="screencapture -i /tmp/screenshot.png && tesseract /tmp/screenshot.png stdout | pbcopy && rm -f /tmp/screenshot.png" | |
# Sync Bluetooth "Diego's Trackpad" and "Diego's Keyboard" devices. | |
# Install blueutil with Homebrew: "brew install blueutil". | |
alias bluesync="blueutil --connect 8c-85-90-f3-9b-b8 && blueutil --connect c0-a5-3e-09-07-c7" | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash | |
source ~/.git-completion.bash | |
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh | |
source ~/.git-prompt.sh | |
# enable git prompt | |
GIT_PS1_SHOWDIRTYSTATE=true | |
export PS1='[\u@mbp \w$(__git_ps1)]\$ ' | |
[[ -s ~/.bashrc ]] && source ~/.bashrc | |
export PATH="~/.composer/vendor/bin:$PATH" | |
# Run Vagrant commands on the Homestead machine | |
function homestead() { | |
case "$1" in | |
# ssh directly into the current directory | |
ssh) | |
local absPath="$PWD" | |
local prefix="$HOME/" | |
local relPath="${absPath#$prefix}" | |
# try to cd into the relative path. fail silently if not found | |
( cd ~/code/homestead && vagrant ssh -- -t "cd \"$relPath\" 2>/dev/null; exec \$SHELL --login" ) | |
;; | |
# open Homestead.yaml to edit it | |
edit) | |
open ~/code/homestead/Homestead.yaml | |
;; | |
*) | |
( cd ~/code/homestead && vagrant $* ) | |
;; | |
esac | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically normalize line endings for all text-based files | |
* text=auto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Diego Guerra | |
email = [email protected] | |
[alias] | |
# Text-based graph of all branches | |
graph = log --graph --decorate | |
# Compress the project's working tree | |
tar = !sh -c 'git archive --format=tar HEAD | gzip > project_`date +"%d%m%Y-%H%M"`.tar.gz' | |
# Show the diff between the latest commit and the current state | |
d = !"git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat" | |
# local side of a diff with another commit | |
my-diff = "!s() { git diff `git merge-base HEAD $1`; }; s" | |
# remote side of a diff with another commit | |
his-diff = "!s() { git diff `git merge-base HEAD $1` $1; }; s" | |
# Interactive rebase with the given number of latest commits. e.g. 'get reb 4' | |
reb = "!r() { git rebase -i HEAD~$1; }; r" | |
# Merge fast-forward shortcut | |
ff = merge --ff-only | |
# Force creating a merge commit even if the merge can be resolved as a fast-forward | |
noff = merge --no-ff | |
# git status shortcut | |
s = status | |
# fetch branch from remote and rebase into it, autostashing local changes | |
up = pull --rebase=preserve --autostash | |
# current branch name | |
curr-branch = !git symbolic-ref --short HEAD | |
# push to the current branch | |
pushb = !git push origin `git curr-branch` | |
# setup branch tracking to origin | |
set-upstream = !git branch --set-upstream-to=origin/`git curr-branch` | |
# get hash of the current commit | |
hash = rev-parse --verify HEAD | |
# undo the previous local commit, keeping changes in the index | |
undo-commit = reset --soft HEAD^ | |
# run a perl replace on all the files in the index. eg: git replace 's/old-method-name/new-method-name/g' | |
perl = "!s() { git ls-files -z | xargs -0 perl -p -i -e \"$1\"; }; s" | |
# verbose colored grep, grouping matches in the same file and without wrapping long lines | |
lgrep = "!s() { git grep --color=always --break --heading --line-number \"$@\" | less --chop-long-lines --RAW-CONTROL-CHARS; }; s" | |
# get current branch name | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# push current branch to origin, set it to track upstream | |
publish = "!git push -u origin $(git branch-name)" | |
# delete remote version of current branch | |
unpublish = "!git push origin :$(git branch-name)" | |
# first project's empty commit | |
first-commit = commit -m 'initial empty commit' --allow-empty | |
# purge file from a repository's history. | |
# see: https://help.github.com/articles/removing-sensitive-data-from-a-repository/ | |
purge = "!s() { git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all; }; s" | |
# compare commits in one branch but not in the other | |
compare = "!s() { git log --left-right --graph --cherry-pick --oneline $1...$2; }; s" | |
[color] | |
ui = true | |
[core] | |
excludesfile = ~/.gitignore_global | |
[commit] | |
verbose = true | |
[diff] | |
tool = meld | |
[difftool] | |
prompt = false | |
[difftool "meld"] | |
trustExitCode = true | |
cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\" | |
[merge] | |
tool = meld | |
[mergetool] | |
prompt = false | |
[mergetool "meld"] | |
trustExitCode = true | |
cmd = open -W -a Meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*~ | |
.DS_Store |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Old! Now at: https://github.com/dgoguerra/dotfiles