Last active
December 4, 2016 12:23
-
-
Save MIchaelMainer/1c495b1ad6398fd168bd to your computer and use it in GitHub Desktop.
Bash setup. Alias for git commands, easy chooser for repos, cd shortcuts, open current repo in browser
This file contains 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
# Set the default path. | |
ppath="/c/repos" #TODO - change to your repo dir | |
# openInRepoDir() { cd $ppath ; } | |
###### Alias ##### | |
### Git; this should probably go into the .gitconfig | |
alias gs='git status -s' | |
alias cma='git commit -a -m' | |
alias cm='git commit -m' | |
alias r='git remote -v' | |
alias diffup='git diff origin' #compare with upstream branch | |
### Change dir | |
## get rid of command not found ## | |
alias cd..='cd ..' | |
## a quick way to get out of current directory, I can't recall where I came across this. ## | |
alias ..='cd ..' | |
alias ...='cd ../../../' | |
alias ....='cd ../../../../' | |
alias .....='cd ../../../../' | |
alias .4='cd ../../../../' | |
alias .5='cd ../../../../..' | |
### Misc alias | |
alias c='clear' | |
alias l='chooser' | |
alias startup='code ~/.bashrc &' | |
alias setup='code ~/.bashrc &' | |
alias gitsetup='notepad ~/.gitsetup &' | |
# This is from Jonathan Callen, http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files | |
alias apply-gitignore='git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached' #I'd | |
###### End Alias ##### | |
###### Make opening repos faster ############ | |
# This is from Chris Johnson, http://stackoverflow.com/questions/3200252/prompt-user-to-select-a-directory-with-a-bash-script-and-read-result. Thank you. | |
function chooser { | |
cd $ppath | |
printf "Select folder:\n" | |
select d in */; do test -n "$d" && break; echo ">>> Invalid Selection"; done | |
cd "$d" && pwd | |
} | |
# Open the chooser after the shell loads. | |
chooser | |
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app' | |
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app' | |
# Opens the web view of the git repo. Works so far against GH and VSO | |
alias openVSO='openGH' | |
alias opengh='openGH' | |
function openGH { | |
remote=$(git config --get remote.origin.url) | |
# in case I'm using ssh on GH | |
gh="https://github.com/" | |
remote="${remote/git@github.com:/$gh}" | |
# On Mac I can use open cmd to use default browser. | |
if [[ $(uname) == *"Darwin"* ]] | |
then | |
open $remote | |
else | |
# I'm using MINGW in this case | |
start $remote | |
fi | |
} | |
# Open my Gist for this .bashrc | |
alias gistbash='gistBash' | |
function gistBash { | |
if [[ $(uname) == *"Darwin"* ]] | |
then | |
open https://gist.github.com/MIchaelMainer/1c495b1ad6398fd168bd/edit | |
else | |
# I'm using MINGW in this case | |
start https://gist.github.com/MIchaelMainer/1c495b1ad6398fd168bd/edit | |
fi | |
} | |
# Start web server in current directory and open browser. | |
alias servehere='serveHere' | |
function serveHere { | |
if [[ $(uname) == *"Darwin"* ]] | |
then | |
python -m SimpleHTTPServer 8080 | |
open http://localhost:8080 | |
else | |
# I'm using MINGW in this case | |
python -m SimpleHTTPServer 8080 | |
start http://localhost:8080 | |
fi | |
} |
Brackets over VS Code?! Why?! 😋
@AndrewJByrne, thank you for writing up instructions. @martellaj, no good answer at this point. 😏
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great tool. Thanks for sharing! Here's what I did to get it working in about 2 minutes.
notepad ~/.bashrc