diff options
author | Karel Kočí <cynerd@email.cz> | 2017-10-05 23:37:03 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-10-05 23:38:36 +0200 |
commit | e79776c14c86e37f89087504f765638f2c20eb96 (patch) | |
tree | 3f8ff371c7ecf8b3f3a0eb509ce269c180476b77 /bashrc | |
parent | 3bf384e3ee04e3a82cfb65a73b11cce9f0320519 (diff) | |
parent | 2fc8d93ef509f583f6977588c7b3fb2cf8ebd332 (diff) | |
download | myconfigs-e79776c14c86e37f89087504f765638f2c20eb96.tar.gz myconfigs-e79776c14c86e37f89087504f765638f2c20eb96.tar.bz2 myconfigs-e79776c14c86e37f89087504f765638f2c20eb96.zip |
Merge branch 'master' into server
Diffstat (limited to 'bashrc')
-rw-r--r-- | bashrc | 36 |
1 files changed, 32 insertions, 4 deletions
@@ -10,14 +10,19 @@ if [ -f /etc/bashrc ]; then . /etc/bashrc fi +# Source all completions +if [ -d ~/.bash_completions ]; then + for F in $(find ~/.bash_completions -type f); do + . "$F" + done +fi + +# PROMPT ####################################################### PS1='$( if [ `id -u` -eq "0" ]; then echo -n "\[\e[1;31m\]\u@\h:\[\e[1;34m\]\W\[\e[1;31m\]\$\[\e[0m\] " else - if ls ~/.annoyme/*.pid 2>/dev/null >/dev/null; then - ANNOYME_PS="\[\e[1;31m\]!\[\e[0m\]" - fi - echo -n "$ANNOYME_PS\[\e[1;32m\]\u@\h:\[\e[1;34m\]\W\[\e[1;32m\]\$\[\e[0m\] " + echo -n "\[\e[1;32m\]\u@\h:\[\e[1;34m\]\W\[\e[1;32m\]\$\[\e[0m\] " fi)' PROMPT_COMMAND=' @@ -37,3 +42,26 @@ case "$TERM" in ;; esac +# Completions ################################################## + +_gitbmerge() { + local cur prev + _init_completion || return + [ $COMP_CWORD -gt 1 ] && return # Complete only single dependency + COMPREPLY=() + local GDIR="$(pwd)" + while [ ! -d "$GDIR/.git" ]; do + [ -z "$GDIR" ] && return + GDIR="${GDIR%/*}" + done + GDIR="$GDIR/.git" + [ -f "$GDIR" ] && GDIR="$(cat "$GDIR")" # This just points to some other directory + [ -d "$GDIR/refs/heads" ] || return # No completion if there is no local branch + local ops="" + for B in "$GDIR"/refs/heads/*; do + # TODO skip branch on HEAD + ops="$ops ${B#$GDIR/refs/heads/}" + done + COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) +} +complete -F _gitbmerge gitbmerge |