Last active
December 7, 2016 13:37
-
-
Save maliMirkec/0830c8ba1e3f936aab03f7b60f98dfcf to your computer and use it in GitHub Desktop.
My bash shortcuts
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
# add git flow completion shortcuts | |
source ~/git-flow-completion.bash | |
# reload source | |
alias brc="source ~/.bashrc" | |
# open explorer in current folder | |
alias e.="explorer ." | |
# git: log pretty | |
alias gl="git log --oneline --graph" | |
# git: status condensed | |
alias gs="git status -s" | |
# git: add all | |
alias ga.="git add ." | |
# git: tag display all | |
alias gt="git tag" | |
# git: tag display latest | |
alias gtl="git describe --abbrev=0 --tags" | |
# git: branch all local and remote | |
alias gba="git branch -a" | |
# git: fetch all branches and tags | |
alias gfa="git fetch --all" | |
# git: fetch and purge old data | |
alias gfp="git fetch -p" | |
# git: push all | |
alias gpa="git push --all" | |
# git: push tags | |
alias gpt="git push --tags" | |
# git: reset --hard | |
alias gr="git reset --hard" | |
# git: commit with message | |
commitWithMessage() { | |
git commit -m "$*" | |
} | |
alias gc=commitWithMessage | |
# git flow: init | |
alias gfi="git flow init" | |
# git flow: feature start | |
flowFeatureStart() { | |
git flow feature start "$*" | |
} | |
alias gfs=flowFeatureStart | |
# git flow: feature finish | |
flowFeatureFinish() { | |
git flow feature finish "$*" | |
} | |
alias gff=flowFeatureFinish | |
# git flow: hotfix start | |
flowHotfixStart() { | |
git flow hotfix start "$*" | |
} | |
alias ghs=flowHotfixStart | |
# git flow: hotfix finish | |
flowHotfixFinish() { | |
git flow hotfix finish "$*" | |
} | |
alias ghf=flowHotfixFinish | |
# git flow: release start | |
flowReleaseStart() { | |
git flow release start "$*" | |
} | |
alias grs=flowReleaseStart | |
# git flow: release finish | |
flowReleaseFinish() { | |
git flow release finish "$*" | |
} | |
alias grf=flowReleaseFinish | |
# bower: install | |
alias bi="bower install" | |
# bower: install force | |
alias bi="bower install --force" | |
# bower: update | |
alias bu="bower update" | |
# bower: update force | |
alias bu="bower update --force" | |
# native: ls -la | |
alias ll="ls -la" | |
# native: rm -rf | |
alias rr="rm -rf" | |
# ssh: add new ssh key | |
alias sshkey=sshAddKey | |
sshAddKey() { | |
ssh-keygen -t rsa -C "$*" | |
} | |
# ssh: start agent and add farmeron key | |
alias sshuser=sshStart | |
sshStart() { | |
eval `ssh-agent -s` && ssh-add ~/.ssh/"$*" | |
} | |
# ssh: test connection to github | |
alias sshpingg="ssh -T [email protected]" | |
# ssh: test connection to bitbucket | |
alias sshpingb="ssh -Tv [email protected]" | |
# switch to farmeron github ssh user | |
alias sshfg="sshuser farmeron_github_id_rsa" | |
# switch to farmeron bitbucket ssh user | |
alias sshfb="sshuser farmeron_bitbucket_id_rsa" | |
# switch to private github ssh user | |
alias sshpg="sshuser private_github_id_rsa" | |
# switch to private bitbucket ssh user | |
alias sshpb="sshuser private_bitbucket_id_rsa" |
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
#!bash | |
# | |
# git-flow-completion | |
# =================== | |
# | |
# Bash completion support for [git-flow](http://github.com/nvie/gitflow) | |
# | |
# The contained completion routines provide support for completing: | |
# | |
# * git-flow init and version | |
# * feature, hotfix and release branches | |
# * remote feature, hotfix and release branch names | |
# | |
# | |
# Installation | |
# ------------ | |
# | |
# To achieve git-flow completion nirvana: | |
# | |
# 0. Install git-completion. | |
# | |
# 1. Install this file. Either: | |
# | |
# a. Place it in a `bash-completion.d` folder: | |
# | |
# * /etc/bash-completion.d | |
# * /usr/local/etc/bash-completion.d | |
# * ~/bash-completion.d | |
# | |
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in | |
# your .bashrc: | |
# | |
# source ~/.git-flow-completion.sh | |
# | |
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant | |
# $command case in _git: | |
# | |
# flow) _git_flow ;; | |
# | |
# | |
# The Fine Print | |
# -------------- | |
# | |
# Copyright (c) 2010-2015 [Justin Hileman](http://justinhileman.com) | |
# | |
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) | |
_git_flow () | |
{ | |
local subcommands="init feature release hotfix support help version" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
case "$subcommand" in | |
init) | |
__git_flow_init | |
return | |
;; | |
feature) | |
__git_flow_feature | |
return | |
;; | |
release) | |
__git_flow_release | |
return | |
;; | |
hotfix) | |
__git_flow_hotfix | |
return | |
;; | |
support) | |
__git_flow_support | |
return | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
__git_flow_init () | |
{ | |
local subcommands="help" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
} | |
__git_flow_feature () | |
{ | |
local subcommands="list start finish publish track diff rebase checkout pull help" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
case "$subcommand" in | |
pull) | |
__gitcomp "$(__git_remotes)" | |
return | |
;; | |
checkout|finish|diff|rebase) | |
__gitcomp "$(__git_flow_list_branches 'feature')" | |
return | |
;; | |
publish) | |
__gitcomp "$(comm -23 <(__git_flow_list_branches 'feature') <(__git_flow_list_remote_branches 'feature'))" | |
return | |
;; | |
track) | |
__gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'feature') <(__git_flow_list_branches 'feature'))" | |
return | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
__git_flow_release () | |
{ | |
local subcommands="list start finish track publish help" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
case "$subcommand" in | |
finish) | |
__gitcomp "$(__git_flow_list_branches 'release')" | |
return | |
;; | |
publish) | |
__gitcomp "$(comm -23 <(__git_flow_list_branches 'release') <(__git_flow_list_remote_branches 'release'))" | |
return | |
;; | |
track) | |
__gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'release') <(__git_flow_list_branches 'release'))" | |
return | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
__git_flow_hotfix () | |
{ | |
local subcommands="list start finish track publish help" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
case "$subcommand" in | |
finish) | |
__gitcomp "$(__git_flow_list_branches 'hotfix')" | |
return | |
;; | |
publish) | |
__gitcomp "$(comm -23 <(__git_flow_list_branches 'hotfix') <(__git_flow_list_remote_branches 'hotfix'))" | |
return | |
;; | |
track) | |
__gitcomp "$(comm -23 <(__git_flow_list_remote_branches 'hotfix') <(__git_flow_list_branches 'hotfix'))" | |
return | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
__git_flow_support () | |
{ | |
local subcommands="list start help" | |
local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands" | |
return | |
fi | |
case "$subcommand" in | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
__git_flow_prefix () | |
{ | |
case "$1" in | |
feature|release|hotfix) | |
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/" | |
return | |
;; | |
esac | |
} | |
__git_flow_list_branches () | |
{ | |
local prefix="$(__git_flow_prefix $1)" | |
git branch --no-color 2> /dev/null | tr -d ' |*' | grep --color=never "^$prefix" | sed s,^$prefix,, | sort | |
} | |
__git_flow_list_remote_branches () | |
{ | |
local prefix="$(__git_flow_prefix $1)" | |
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")" | |
git branch --no-color -r 2> /dev/null | sed "s/^ *//g" | grep --color=never "^$origin/$prefix" | sed s,^$origin/$prefix,, | sort | |
} | |
# alias __git_find_on_cmdline for backwards compatibility | |
if [ -z "`type -t __git_find_on_cmdline`" ]; then | |
alias __git_find_on_cmdline=__git_find_subcommand | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment