Skip to content

Commit

Permalink
Merge pull request #1 from Bash-it/master
Browse files Browse the repository at this point in the history
Update from upstream
  • Loading branch information
mimoralea committed May 12, 2015
2 parents 16bc784 + 7f8e2c2 commit 2b99e43
Show file tree
Hide file tree
Showing 24 changed files with 326 additions and 73 deletions.
18 changes: 18 additions & 0 deletions aliases/available/clipboard.aliases.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cite 'about-alias'
about-alias 'pbcopy and pbpaste shortcuts to linux'

case $OSTYPE in
linux*)
XCLIP=$(command -v xclip)
[[ $XCLIP ]] && alias pbcopy="$XCLIP -selection clipboard" && alias pbpaste="$XCLIP -selection clipboard -o"
;;
esac

# to use it just install xclip on your distribution and it would work like:
# $ echo "hello" | pbcopy
# $ pbpaste
# hello

# very useful for things like:
# cat ~/.ssh/id_rsa.pub | pbcopy
# have fun!
3 changes: 3 additions & 0 deletions aliases/available/fuck.aliases.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/nvbn/thefuck
alias fuck='eval $(thefuck $(fc -ln -1))'
alias please='fuck'
2 changes: 1 addition & 1 deletion aliases/available/homebrew.aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cite 'about-alias'
about-alias 'homebrew abbreviations'

alias bup='brew update && brew upgrade'
alias bup='brew update && brew upgrade --all'
alias bout='brew outdated'
alias bin='brew install'
alias brm='brew uninstall'
Expand Down
6 changes: 3 additions & 3 deletions bash_it.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ done

unset config_file
if [[ $PROMPT ]]; then
export PS1=$PROMPT
export PS1="\["$PROMPT"\]"
fi

# Adding Support for other OSes
Expand All @@ -81,7 +81,7 @@ PREVIEW="less"

# Load all the Jekyll stuff

if [ -e $HOME/.jekyllconfig ]
if [ -e "$HOME/.jekyllconfig" ]
then
. $HOME/.jekyllconfig
. "$HOME/.jekyllconfig"
fi
15 changes: 15 additions & 0 deletions completion/available/dirs.completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Bash completion support for the 'dirs' plugin (commands G, R).

_dirs-complete() {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"

# parse all defined shortcuts from ~/.dirs
if [ -r "$HOME/.dirs" ]; then
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
fi

return 0
}

complete -o default -o nospace -F _dirs-complete G R
109 changes: 79 additions & 30 deletions completion/available/git.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
#
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
# 2) Add the following line to your .bashrc/.zshrc:
# source ~/.git-completion.sh
# source ~/.git-completion.bash
# 3) Consider changing your PS1 to also show the current branch,
# see git-prompt.sh for details.
#
# If you use complex aliases of form '!f() { ... }; f', you can use the null
# command ':' as the first command in the function body to declare the desired
# completion style. For example '!f() { : git commit ; ... }; f' will
# tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".

case "$COMP_WORDBREAKS" in
*:*) : great ;;
Expand Down Expand Up @@ -180,7 +186,7 @@ fi

__gitcompappend ()
{
local i=${#COMPREPLY[@]}
local x i=${#COMPREPLY[@]}
for x in $1; do
if [[ "$x" == "$3"* ]]; then
COMPREPLY[i++]="$2$x$4"
Expand Down Expand Up @@ -275,16 +281,12 @@ __gitcomp_file ()
# argument, and using the options specified in the second argument.
__git_ls_files_helper ()
{
(
test -n "${CDPATH+set}" && unset CDPATH
cd "$1"
if [ "$2" == "--committable" ]; then
git diff-index --name-only --relative HEAD
else
# NOTE: $2 is not quoted in order to support multiple options
git ls-files --exclude-standard $2
fi
) 2>/dev/null
if [ "$2" == "--committable" ]; then
git -C "$1" diff-index --name-only --relative HEAD
else
# NOTE: $2 is not quoted in order to support multiple options
git -C "$1" ls-files --exclude-standard $2
fi 2>/dev/null
}


Expand Down Expand Up @@ -382,7 +384,8 @@ __git_refs ()
;;
*)
echo "HEAD"
git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
git for-each-ref --format="%(refname:short)" -- \
"refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
;;
esac
}
Expand All @@ -408,12 +411,9 @@ __git_refs_remotes ()

__git_remotes ()
{
local i IFS=$'\n' d="$(__gitdir)"
local d="$(__gitdir)"
test -d "$d/remotes" && ls -1 "$d/remotes"
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
i="${i#remote.}"
echo "${i/.url*/}"
done
git --git-dir="$d" remote
}

__git_list_merge_strategies ()
Expand Down Expand Up @@ -516,7 +516,7 @@ __git_complete_index_file ()
;;
esac

__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
}

__git_complete_file ()
Expand Down Expand Up @@ -781,6 +781,10 @@ __git_aliased_command ()
-*) : option ;;
*=*) : setting env ;;
git) : git itself ;;
\(\)) : skip parens of shell function definition ;;
{) : skip start of shell helper function ;;
:) : skip null command ;;
\'*) : skip opening quote after sh -c ;;
*)
echo "$word"
return
Expand Down Expand Up @@ -973,7 +977,7 @@ _git_branch ()

case "$cur" in
--set-upstream-to=*)
__gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
__gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
;;
--*)
__gitcomp "
Expand Down Expand Up @@ -1041,7 +1045,7 @@ _git_checkout ()

_git_cherry ()
{
__gitcomp "$(__git_refs)"
__gitcomp_nl "$(__git_refs)"
}

_git_cherry_pick ()
Expand Down Expand Up @@ -1165,8 +1169,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--full-index --binary --abbrev --diff-filter=
--find-copies-harder
--text --ignore-space-at-eol --ignore-space-change
--ignore-all-space --exit-code --quiet --ext-diff
--no-ext-diff
--ignore-all-space --ignore-blank-lines --exit-code
--quiet --ext-diff --no-ext-diff
--no-prefix --src-prefix= --dst-prefix=
--inter-hunk-context=
--patience --histogram --minimal
Expand Down Expand Up @@ -1197,7 +1201,7 @@ _git_diff ()
}

__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
"

_git_difftool ()
Expand Down Expand Up @@ -1298,7 +1302,7 @@ _git_gitk ()
}

__git_match_ctag() {
awk "/^${1////\\/}/ { print \$1 }" "$2"
awk "/^${1//\//\\/}/ { print \$1 }" "$2"
}

_git_grep ()
Expand Down Expand Up @@ -1418,7 +1422,7 @@ __git_log_gitk_options="
# Options that go well for log and shortlog (not gitk)
__git_log_shortlog_options="
--author= --committer= --grep=
--all-match
--all-match --invert-grep
"

__git_log_pretty_formats="oneline short medium full fuller email raw format:"
Expand Down Expand Up @@ -1457,6 +1461,7 @@ _git_log ()
--abbrev-commit --abbrev=
--relative-date --date=
--pretty= --format= --oneline
--show-signature
--cherry-pick
--graph
--decorate --decorate=
Expand Down Expand Up @@ -1611,12 +1616,33 @@ _git_pull ()

__git_push_recurse_submodules="check on-demand"

__git_complete_force_with_lease ()
{
local cur_=$1

case "$cur_" in
--*=)
;;
*:*)
__gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
;;
*)
__gitcomp_nl "$(__git_refs)" "" "$cur_"
;;
esac
}

_git_push ()
{
case "$prev" in
--repo)
__gitcomp_nl "$(__git_remotes)"
return
;;
--recurse-submodules)
__gitcomp "$__git_push_recurse_submodules"
return
;;
esac
case "$cur" in
--repo=*)
Expand All @@ -1627,11 +1653,16 @@ _git_push ()
__gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
return
;;
--force-with-lease=*)
__git_complete_force_with_lease "${cur##--force-with-lease=}"
return
;;
--*)
__gitcomp "
--all --mirror --tags --dry-run --force
--force-with-lease --verbose --receive-pack= --repo=
--set-upstream --recurse-submodules=
--all --mirror --tags --dry-run --force --verbose
--quiet --prune --delete --follow-tags
--receive-pack= --repo= --set-upstream
--force-with-lease --force-with-lease= --recurse-submodules=
"
return
;;
Expand Down Expand Up @@ -1659,6 +1690,7 @@ _git_rebase ()
--committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace=
--autosquash --fork-point --no-fork-point
--autostash
"

return
Expand Down Expand Up @@ -1841,6 +1873,10 @@ _git_config ()
__gitcomp "$__git_send_email_suppresscc_options"
return
;;
sendemail.transferencoding)
__gitcomp "7bit 8bit quoted-printable base64"
return
;;
--get|--get-all|--unset|--unset-all)
__gitcomp_nl "$(__git_config_get_set_variables)"
return
Expand Down Expand Up @@ -1975,6 +2011,7 @@ _git_config ()
color.status.changed
color.status.header
color.status.nobranch
color.status.unmerged
color.status.untracked
color.status.updated
color.ui
Expand Down Expand Up @@ -2149,6 +2186,7 @@ _git_config ()
pull.octopus
pull.twohead
push.default
push.followTags
rebase.autosquash
rebase.stat
receive.autogc
Expand Down Expand Up @@ -2308,6 +2346,7 @@ _git_show ()
;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --oneline
--show-signature
$__git_diff_common_options
"
return
Expand Down Expand Up @@ -2513,6 +2552,16 @@ _git_tag ()
__gitcomp_nl "$(__git_refs)"
;;
esac

case "$cur" in
--*)
__gitcomp "
--list --delete --verify --annotate --message --file
--sign --cleanup --local-user --force --column --sort
--contains --points-at
"
;;
esac
}

_git_whatchanged ()
Expand Down
10 changes: 5 additions & 5 deletions completion/available/ssh.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ _sshcomplete() {


# parse all defined hosts from .ssh/config
if [ -r $HOME/.ssh/config ]; then
COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" ${OPTIONS}) )
if [ -r "$HOME/.ssh/config" ]; then
COMPREPLY=($(compgen -W "$(grep ^Host "$HOME/.ssh/config" | awk '{print $2}' )" ${OPTIONS}) )
fi

# parse all hosts found in .ssh/known_hosts
if [ -r $HOME/.ssh/known_hosts ]; then
if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) )
if [ -r "$HOME/.ssh/known_hosts" ]; then
if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) )
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion completion/available/todo.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _todo()
mv prepend prep pri p replace report"

# Add custom commands from add-ons, if installed.
COMMANDS="$COMMANDS $('ls' ${TODO_ACTIONS_DIR:-$HOME/.todo.actions.d}/ 2>/dev/null)"
COMMANDS="$COMMANDS $('ls' ${TODO_ACTIONS_DIR:-"$HOME/.todo.actions.d"}/ 2>/dev/null)"

OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"

Expand Down
Loading

0 comments on commit 2b99e43

Please sign in to comment.