pull/750/head
sveneh 2016-07-14 23:25:48 +02:00
commit 445b0ed86b
61 changed files with 2125 additions and 292 deletions

View File

@ -2,4 +2,5 @@ cite 'about-alias'
about-alias 'docker-compose abbreviations' about-alias 'docker-compose abbreviations'
alias dco="docker-compose" alias dco="docker-compose"
alias dcofresh="docker-compose stop ; docker-compose rm -f ; docker-compose up -d ; docker-compose logs" alias dcofresh="docker-compose-fresh"
alias dcol="docker-compose logs -f --tail 100"

View File

@ -4,6 +4,7 @@ about-alias 'common git abbreviations'
# Aliases # Aliases
alias gcl='git clone' alias gcl='git clone'
alias ga='git add' alias ga='git add'
alias gap='git add -p'
alias gall='git add -A' alias gall='git add -A'
alias gf='git fetch --all --prune' alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags' alias gft='git fetch --all --prune --tags'

View File

@ -0,0 +1,561 @@
#!bash
#
# bash completion for docker-compose
#
# This work is based on the completion for the docker command.
#
# This script provides completion of:
# - commands and their options
# - service names
# - filepaths
#
# To enable the completions either:
# - place this file in /etc/bash_completion.d
# or
# - copy this file to e.g. ~/.docker-compose-completion.sh and add the line
# below to your .bashrc after bash completion features are loaded
# . ~/.docker-compose-completion.sh
__docker_compose_q() {
docker-compose 2>/dev/null $daemon_options "$@"
}
# Transforms a multiline list of strings into a single line string
# with the words separated by "|".
__docker_compose_to_alternatives() {
local parts=( $1 )
local IFS='|'
echo "${parts[*]}"
}
# Transforms a multiline list of options into an extglob pattern
# suitable for use in case statements.
__docker_compose_to_extglob() {
local extglob=$( __docker_compose_to_alternatives "$1" )
echo "@($extglob)"
}
# suppress trailing whitespace
__docker_compose_nospace() {
# compopt is not available in ancient bash versions
type compopt &>/dev/null && compopt -o nospace
}
# Extracts all service names from the compose file.
___docker_compose_all_services_in_compose_file() {
__docker_compose_q config --services
}
# All services, even those without an existing container
__docker_compose_services_all() {
COMPREPLY=( $(compgen -W "$(___docker_compose_all_services_in_compose_file)" -- "$cur") )
}
# All services that have an entry with the given key in their compose_file section
___docker_compose_services_with_key() {
# flatten sections under "services" to one line, then filter lines containing the key and return section name
__docker_compose_q config \
| sed -n -e '/^services:/,/^[^ ]/p' \
| sed -n 's/^ //p' \
| awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \
| awk -F: -v key=": +$1:" '$0 ~ key {print $1}'
}
# All services that are defined by a Dockerfile reference
__docker_compose_services_from_build() {
COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key build)" -- "$cur") )
}
# All services that are defined by an image
__docker_compose_services_from_image() {
COMPREPLY=( $(compgen -W "$(___docker_compose_services_with_key image)" -- "$cur") )
}
# The services for which containers have been created, optionally filtered
# by a boolean expression passed in as argument.
__docker_compose_services_with() {
local containers names
containers="$(__docker_compose_q ps -q)"
names=$(docker 2>/dev/null inspect -f "{{if ${1:-true}}}{{range \$k, \$v := .Config.Labels}}{{if eq \$k \"com.docker.compose.service\"}}{{\$v}}{{end}}{{end}}{{end}}" $containers)
COMPREPLY=( $(compgen -W "$names" -- "$cur") )
}
# The services for which at least one paused container exists
__docker_compose_services_paused() {
__docker_compose_services_with '.State.Paused'
}
# The services for which at least one running container exists
__docker_compose_services_running() {
__docker_compose_services_with '.State.Running'
}
# The services for which at least one stopped container exists
__docker_compose_services_stopped() {
__docker_compose_services_with 'not .State.Running'
}
_docker_compose_build() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--force-rm --help --no-cache --pull" -- "$cur" ) )
;;
*)
__docker_compose_services_from_build
;;
esac
}
_docker_compose_bundle() {
case "$prev" in
--output|-o)
_filedir
return
;;
esac
COMPREPLY=( $( compgen -W "--fetch-digests --help --output -o" -- "$cur" ) )
}
_docker_compose_config() {
COMPREPLY=( $( compgen -W "--help --quiet -q --services" -- "$cur" ) )
}
_docker_compose_create() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--force-recreate --help --no-build --no-recreate" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_docker_compose() {
case "$prev" in
--tlscacert|--tlscert|--tlskey)
_filedir
return
;;
--file|-f)
_filedir "y?(a)ml"
return
;;
$(__docker_compose_to_extglob "$daemon_options_with_args") )
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "$daemon_boolean_options $daemon_options_with_args --help -h --verbose --version -v" -- "$cur" ) )
;;
*)
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
;;
esac
}
_docker_compose_down() {
case "$prev" in
--rmi)
COMPREPLY=( $( compgen -W "all local" -- "$cur" ) )
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --rmi --volumes -v --remove-orphans" -- "$cur" ) )
;;
esac
}
_docker_compose_events() {
case "$prev" in
--json)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --json" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_exec() {
case "$prev" in
--index|--user)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-d --help --index --privileged -T --user" -- "$cur" ) )
;;
*)
__docker_compose_services_running
;;
esac
}
_docker_compose_help() {
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
}
_docker_compose_kill() {
case "$prev" in
-s)
COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) )
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help -s" -- "$cur" ) )
;;
*)
__docker_compose_services_running
;;
esac
}
_docker_compose_logs() {
case "$prev" in
--tail)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--follow -f --help --no-color --tail --timestamps -t" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_pause() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
__docker_compose_services_running
;;
esac
}
_docker_compose_port() {
case "$prev" in
--protocol)
COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) )
return;
;;
--index)
return;
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --index --protocol" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_ps() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help -q" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_pull() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures" -- "$cur" ) )
;;
*)
__docker_compose_services_from_image
;;
esac
}
_docker_compose_push() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_restart() {
case "$prev" in
--timeout|-t)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
;;
*)
__docker_compose_services_running
;;
esac
}
_docker_compose_rm() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--force -f --help -v" -- "$cur" ) )
;;
*)
__docker_compose_services_stopped
;;
esac
}
_docker_compose_run() {
case "$prev" in
-e)
COMPREPLY=( $( compgen -e -- "$cur" ) )
__docker_compose_nospace
return
;;
--entrypoint|--name|--user|-u|--workdir|-w)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-d --entrypoint -e --help --name --no-deps --publish -p --rm --service-ports -T --user -u --workdir -w" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_scale() {
case "$prev" in
=)
COMPREPLY=("$cur")
return
;;
--timeout|-t)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
;;
*)
COMPREPLY=( $(compgen -S "=" -W "$(___docker_compose_all_services_in_compose_file)" -- "$cur") )
__docker_compose_nospace
;;
esac
}
_docker_compose_start() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
__docker_compose_services_stopped
;;
esac
}
_docker_compose_stop() {
case "$prev" in
--timeout|-t)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
;;
*)
__docker_compose_services_running
;;
esac
}
_docker_compose_unpause() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
__docker_compose_services_paused
;;
esac
}
_docker_compose_up() {
case "$prev" in
--timeout|-t)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--abort-on-container-exit --build -d --force-recreate --help --no-build --no-color --no-deps --no-recreate --timeout -t --remove-orphans" -- "$cur" ) )
;;
*)
__docker_compose_services_all
;;
esac
}
_docker_compose_version() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--short" -- "$cur" ) )
;;
esac
}
_docker_compose() {
local previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob
local commands=(
build
bundle
config
create
down
events
exec
help
kill
logs
pause
port
ps
pull
push
restart
rm
run
scale
start
stop
unpause
up
version
)
# options for the docker daemon that have to be passed to secondary calls to
# docker-compose executed by this script
local daemon_boolean_options="
--skip-hostname-check
--tls
--tlsverify
"
local daemon_options_with_args="
--file -f
--host -H
--project-name -p
--tlscacert
--tlscert
--tlskey
"
COMPREPLY=()
local cur prev words cword
_get_comp_words_by_ref -n : cur prev words cword
# search subcommand and invoke its handler.
# special treatment of some top-level options
local command='docker_compose'
local daemon_options=()
local counter=1
while [ $counter -lt $cword ]; do
case "${words[$counter]}" in
$(__docker_compose_to_extglob "$daemon_boolean_options") )
local opt=${words[counter]}
daemon_options+=($opt)
;;
$(__docker_compose_to_extglob "$daemon_options_with_args") )
local opt=${words[counter]}
local arg=${words[++counter]}
daemon_options+=($opt $arg)
;;
-*)
;;
*)
command="${words[$counter]}"
break
;;
esac
(( counter++ ))
done
local completions_func=_docker_compose_${command//-/_}
declare -F $completions_func >/dev/null && $completions_func
eval "$previous_extglob_setting"
return 0
}
complete -F _docker_compose docker-compose

View File

@ -0,0 +1,252 @@
#
# bash completion file for docker-machine commands
#
# This script provides completion of:
# - commands and their options
# - machine names
# - filepaths
#
# To enable the completions either:
# - place this file in /etc/bash_completion.d
# or
# - copy this file to e.g. ~/.docker-machine-completion.sh and add the line
# below to your .bashrc after bash completion features are loaded
# . ~/.docker-machine-completion.sh
#
_docker_machine_active() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=()
fi
}
_docker_machine_config() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_create() {
# cheating, b/c there are approximately one zillion options to create
COMPREPLY=($(compgen -W "$(docker-machine create --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')" -- "${cur}"))
}
_docker_machine_env() {
case "${prev}" in
--shell)
# What are the options for --shell?
COMPREPLY=()
;;
*)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --shell --unset --no-proxy --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
esac
}
# See docker-machine-wrapper.bash for the use command
_docker_machine_use() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_inspect() {
case "${prev}" in
-f|--format)
COMPREPLY=()
;;
*)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--format --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
;;
esac
}
_docker_machine_ip() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_kill() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_ls() {
case "${prev}" in
--filter)
COMPREPLY=()
;;
*)
COMPREPLY=($(compgen -W "--quiet --filter --format --timeout --help" -- "${cur}"))
;;
esac
}
_docker_machine_regenerate_certs() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_restart() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_rm() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}"))
else
# For rm, it's best to be explicit
COMPREPLY=()
fi
}
_docker_machine_ssh() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_scp() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}"))
else
_filedir
# It would be really nice to ssh to the machine and ls to complete
# remote files.
COMPREPLY=($(compgen -W "$(docker-machine ls -q | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}")
fi
}
_docker_machine_start() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_status() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_stop() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_upgrade() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_url() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_version() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
}
_docker_machine_help() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}"))
fi
}
_docker_machine_docker_machine() {
if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then
_filedir
elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then
_filedir -d
elif [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "${flags[*]} ${wants_dir[*]} ${wants_file[*]}" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}"))
fi
}
_docker_machine() {
COMPREPLY=()
local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help)
local flags=(--debug --native-ssh --github-api-token --bugsnag-api-token --help --version)
local wants_dir=(--storage-path)
local wants_file=(--tls-ca-cert --tls-ca-key --tls-client-cert --tls-client-key)
# Add the use subcommand, if we have an alias loaded
if [[ ${DOCKER_MACHINE_WRAPPED} = true ]]; then
commands=("${commands[@]}" use)
fi
local cur prev words cword
_get_comp_words_by_ref -n : cur prev words cword
local i
local command=docker-machine
for (( i=1; i < ${cword}; ++i)); do
local word=${words[i]}
if [[ " ${wants_file[*]} ${wants_dir[*]} " =~ " ${word} " ]]; then
# skip the next option
(( ++i ))
elif [[ " ${commands[*]} " =~ " ${word} " ]]; then
command=${word}
fi
done
local completion_func=_docker_machine_"${command//-/_}"
if declare -F "${completion_func}" > /dev/null; then
${completion_func}
fi
return 0
}
complete -F _docker_machine docker-machine

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
BASH_IT="$(cd "$(dirname "$0")" && pwd)" # bash-it installer
case $OSTYPE in # Show how to use this installer
darwin*) function show_usage() {
CONFIG_FILE=.bash_profile echo -e "\n$0 : Install bash-it"
;; echo -e "Usage:\n$0 [arguments] \n"
*) echo "Arguments:"
CONFIG_FILE=.bashrc echo "--help (-h): Display this help message"
;; echo "--silent (-s): Install default settings without prompting for input";
esac echo "--interactive (-i): Interactively choose plugins"
exit 0;
BACKUP_FILE=$CONFIG_FILE.bak }
if [ -e "$HOME/$BACKUP_FILE" ]; then
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
while true
do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
break
;;
[nN]|"")
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
exit 1
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
fi
while true
do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in
[yY])
test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
break
;;
[nN]|"")
test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
# enable a thing
function load_one() { function load_one() {
file_type=$1 file_type=$1
file_to_enable=$2 file_to_enable=$2
@ -73,6 +26,7 @@ function load_one() {
fi fi
} }
# Interactively enable several things
function load_some() { function load_some() {
file_type=$1 file_type=$1
[ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled" [ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled"
@ -98,7 +52,102 @@ function load_some() {
done done
} }
if [[ "$1" == "--interactive" ]] # Back up existing profile and create new one for bash-it
function backup_new() {
test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
}
for param in "$@"; do
shift
case "$param" in
"--help") set -- "$@" "-h" ;;
"--silent") set -- "$@" "-s" ;;
"--interactive") set -- "$@" "-i" ;;
*) set -- "$@" "$param"
esac
done
OPTIND=1
while getopts "hsi" opt
do
case "$opt" in
"h") show_usage; exit 0 ;;
"s") silent=true ;;
"i") interactive=true ;;
"?") show_usage >&2; exit 1 ;;
esac
done
shift $(expr $OPTIND - 1)
if [[ $silent ]] && [[ $interactive ]]; then
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
exit 1;
fi
BASH_IT="$(cd "$(dirname "$0")" && pwd)"
case $OSTYPE in
darwin*)
CONFIG_FILE=.bash_profile
;;
*)
CONFIG_FILE=.bashrc
;;
esac
BACKUP_FILE=$CONFIG_FILE.bak
echo "Installing bash-it"
if [ -e "$HOME/$BACKUP_FILE" ]; then
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
while ! [ $silent ]; do
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
case $RESP in
[yY])
break
;;
[nN]|"")
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
exit 1
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
fi
while ! [ $silent ]; do
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
case $choice in
[yY])
test -w "$HOME/$CONFIG_FILE" &&
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
break
;;
[nN]|"")
backup_new
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
if [ $silent ]; then
# backup/new by default
backup_new
fi
if [[ $interactive ]] && ! [[ $silent ]] ;
then then
for type in "aliases" "plugins" "completion" for type in "aliases" "plugins" "completion"
do do

View File

@ -0,0 +1,20 @@
cite about-plugin
about-plugin 'Helper functions for using docker-compose'
function docker-compose-fresh() {
about 'Shut down, remove and start again the docker-compose setup, then tail the logs'
group 'docker-compose'
param '1: name of the docker-compose.yaml file to use (optional). Default: docker-compose.yaml'
example 'docker-compose-fresh docker-compose-foo.yaml'
local DCO_FILE_PARAM=""
if [ -n "$1" ]; then
echo "Using docker-compose file: $1"
DCO_FILE_PARAM="--file $1"
fi
docker-compose $DCO_FILE_PARAM stop
docker-compose $DCO_FILE_PARAM rm -f --all
docker-compose $DCO_FILE_PARAM up -d
docker-compose $DCO_FILE_PARAM logs -f --tail 100
}

View File

@ -35,4 +35,4 @@ function prompt_command() {
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]${white}\t \[$PURPLE\]\$(scm_prompt_info) \n\$ \[$RESET\]" PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]${white}\t \[$PURPLE\]\$(scm_prompt_info) \n\$ \[$RESET\]"
} }
PROMPT_COMMAND=prompt_command safe_append_prompt_command prompt_command

View File

@ -19,4 +19,4 @@ function prompt_command() {
PS1="\n${cyan}\h: ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}" PS1="\n${cyan}\h: ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}"
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -403,3 +403,12 @@ function aws_profile {
echo -e "default" echo -e "default"
fi fi
} }
function safe_append_prompt_command {
if [[ -n $1 ]] ; then
case $PROMPT_COMMAND in
*$1*) ;;
*) PROMPT_COMMAND="$1;$PROMPT_COMMAND";;
esac
fi
}

View File

@ -102,4 +102,4 @@ SCM_GIT_CHAR="${green}±${light_grey}"
SCM_SVN_CHAR="${bold_cyan}${light_grey}" SCM_SVN_CHAR="${bold_cyan}${light_grey}"
SCM_HG_CHAR="${bold_red}${light_grey}" SCM_HG_CHAR="${bold_red}${light_grey}"
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -16,4 +16,4 @@ function prompt_command() {
PS1="\n${yellow}$(python_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n${yellow}$(python_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -17,4 +17,4 @@ function prompt_command() {
PS1="\n$(battery_char) $(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n$(battery_char) $(clock_char) ${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -31,4 +31,4 @@ ${white}>${normal} "
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -3,4 +3,4 @@ function prompt_command() {
PS1="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} "; PS1="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -17,4 +17,4 @@ function prompt_command() {
RPROMPT='[\t]' RPROMPT='[\t]'
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -36,4 +36,4 @@ function prompt() {
PS1="\n${user_host}${prompt_symbol}${ruby} ${git_branch} ${return_status}\n${prompt_char}" PS1="\n${user_host}${prompt_symbol}${ruby} ${git_branch} ${return_status}\n${prompt_char}"
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -76,4 +76,4 @@ function prompt_command() {
} }
# Runs prompt (this bypasses bash_it $PROMPT setting) # Runs prompt (this bypasses bash_it $PROMPT setting)
PROMPT_COMMAND=prompt_command safe_append_prompt_command prompt_command

View File

@ -126,5 +126,5 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
} }
# Runs prompt (this bypasses bash_it $PROMPT setting) # Runs prompt (this bypasses bash_it $PROMPT setting)
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -56,7 +56,7 @@ $(doubletime_scm_prompt)$reset_color $ "
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
git_prompt_status() { git_prompt_status() {
local git_status_output local git_status_output

View File

@ -21,4 +21,4 @@ $(doubletime_scm_prompt)$reset_color $ "
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter

View File

@ -21,4 +21,4 @@ $(doubletime_scm_prompt)$reset_color $ "
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter

View File

@ -95,4 +95,4 @@ dulcie_prompt() {
PS1="${PS1}${DULCIE_PROMPTCHAR} " PS1="${PS1}${DULCIE_PROMPTCHAR} "
} }
PROMPT_COMMAND=dulcie_prompt safe_append_prompt_command dulcie_prompt

View File

@ -21,4 +21,4 @@ prompt() {
PS1="${yellow}# ${reset_color}$(last_two_dirs)$(scm_prompt_info)${reset_color}$(venv)${reset_color} ${cyan}\n> ${reset_color}" PS1="${yellow}# ${reset_color}$(last_two_dirs)$(scm_prompt_info)${reset_color}$(venv)${reset_color} ${cyan}\n> ${reset_color}"
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -31,4 +31,4 @@ function prompt_command() {
PS1="\n$(get_hour_color)$(date +%H) ${purple}\h ${reset_color}in ${prompt_color}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n$(get_hour_color)$(date +%H) ${purple}\h ${reset_color}in ${prompt_color}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -13,4 +13,4 @@ function prompt_command() {
PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -38,4 +38,4 @@ pure_prompt() {
esac esac
} }
PROMPT_COMMAND=pure_prompt; safe_append_prompt_command pure_prompt

View File

@ -197,4 +197,4 @@ function prompt() {
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -56,4 +56,4 @@ function prompt_command() {
PS1="${new_PS1}${green}${wrap_char}${reset_color} " PS1="${new_PS1}${green}${wrap_char}${reset_color} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -26,4 +26,4 @@ function prompt_command() {
$arrow $prompt" $arrow $prompt"
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -127,4 +127,4 @@ PS2="└─▪ "
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -31,4 +31,4 @@ function prompt() {
PS1="\n${n_commands} ${user_host} ${prompt_symbol} ${ruby} ${open}${current_path}${git_branch}${close}${return_status}\n${prompt_char}" PS1="\n${n_commands} ${user_host} ${prompt_symbol} ${ruby} ${open}${current_path}${git_branch}${close}${return_status}\n${prompt_char}"
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -9,4 +9,4 @@ prompt() {
PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} "
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -53,4 +53,4 @@ PS2="└─▪ "
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -53,4 +53,4 @@ PS2="└─▪ "
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -25,4 +25,4 @@ SCM_THEME_PROMPT_PREFIX="${green}("
SCM_THEME_PROMPT_SUFFIX="${green})${reset_color}" SCM_THEME_PROMPT_SUFFIX="${green})${reset_color}"
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -9,7 +9,7 @@ function prompt_command() {
PS1="${bold_blue}[$(hostname)]${normal} \w${normal} ${bold_white}[$(git_prompt_info)]${normal}» " PS1="${bold_blue}[$(hostname)]${normal} \w${normal} ${bold_white}[$(git_prompt_info)]${normal}» "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command
## git-theme ## git-theme
# feel free to change git chars. # feel free to change git chars.

View File

@ -37,7 +37,7 @@ prompt_setter() {
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}" SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"

View File

@ -102,7 +102,7 @@ prompt_setter() {
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}" SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}" SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"

View File

@ -10,7 +10,7 @@ prompt_setter() {
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓" SCM_THEME_PROMPT_CLEAN=" ✓"

View File

@ -240,4 +240,4 @@ function __powerline_prompt_command {
SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT
} }
PROMPT_COMMAND=__powerline_prompt_command safe_append_prompt_command __powerline_prompt_command

View File

@ -106,5 +106,5 @@ function powerline_prompt_command() {
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
} }
PROMPT_COMMAND=powerline_prompt_command safe_append_prompt_command powerline_prompt_command

View File

@ -120,5 +120,5 @@ function powerline_prompt_command() {
PS1="${SHELL_PROMPT}${GEMSET_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " PS1="${SHELL_PROMPT}${GEMSET_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
} }
PROMPT_COMMAND=powerline_prompt_command safe_append_prompt_command powerline_prompt_command

View File

@ -129,5 +129,5 @@ function powerline_prompt_command() {
PS1="${SHELL_PROMPT}${IN_VIM_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} " PS1="${SHELL_PROMPT}${IN_VIM_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
} }
PROMPT_COMMAND=powerline_prompt_command safe_append_prompt_command powerline_prompt_command

View File

@ -5,4 +5,4 @@ function prompt_command() {
PS1="${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} "; PS1="${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -19,4 +19,4 @@ function prompt() {
PS1="\h: \W $(scm_prompt_info)${reset_color} $ " PS1="\h: \W $(scm_prompt_info)${reset_color} $ "
} }
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -40,4 +40,4 @@ pure_prompt() {
esac esac
} }
PROMPT_COMMAND=pure_prompt; safe_append_prompt_command pure_prompt

View File

@ -18,7 +18,7 @@ prompt_setter() {
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
SCM_NONE_CHAR='·' SCM_NONE_CHAR='·'
SCM_THEME_PROMPT_DIRTY=" ${red}" SCM_THEME_PROMPT_DIRTY=" ${red}"

View File

@ -211,4 +211,4 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
} }
# Runs prompt (this bypasses bash_it $PROMPT setting) # Runs prompt (this bypasses bash_it $PROMPT setting)
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -97,4 +97,4 @@ PS2="└─$(my_prompt_char)"
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -14,4 +14,4 @@ function prompt_command() {
fi fi
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -43,4 +43,4 @@ function prompt_command() {
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
} }
PROMPT_COMMAND=prompt_command safe_append_prompt_command prompt_command

View File

@ -22,4 +22,4 @@ SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX="(" SCM_THEME_PROMPT_PREFIX="("
SCM_THEME_PROMPT_SUFFIX=")" SCM_THEME_PROMPT_SUFFIX=")"
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -19,4 +19,4 @@ function prompt_command() {
PS1="$blue\W/$bold_blue$(rvm_version_prompt)$bold_green$(__git_ps1 " (%s)") ${normal}$ " PS1="$blue\W/$bold_blue$(rvm_version_prompt)$bold_green$(__git_ps1 " (%s)") ${normal}$ "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -83,4 +83,4 @@ PS2="> "
PROMPT_COMMAND=prompt safe_append_prompt_command prompt

View File

@ -21,4 +21,4 @@ function prompt_command() {
PROMPT='${green}\u${normal}@${green}\h${normal}:${blue}\w${normal}${red}$(prompt_char)$(git_prompt_info)${normal}\$ ' PROMPT='${green}\u${normal}@${green}\h${normal}:${blue}\w${normal}${red}$(prompt_char)$(git_prompt_info)${normal}\$ '
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -30,7 +30,7 @@ PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR "
} }
PROMPT_COMMAND=prompt_setter safe_append_prompt_command prompt_setter
export PS3=">> " export PS3=">> "

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX=" ${purple}"
SCM_THEME_PROMPT_SUFFIX=" ${normal}"
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_GIT_SHOW_DETAILS="false"
function prompt_command() {
PS1="${yellow}\u${normal}${cyan}@\h${normal}${purple} ${normal}${green}\w${normal}$(scm_prompt_info)> "
}
safe_append_prompt_command prompt_command

View File

@ -17,4 +17,4 @@ function prompt_command() {
PS1="\n${green}$(virtualenv_prompt)${red}$(ruby_version_prompt) ${reset_color}\h ${orange}in ${reset_color}\w\n${yellow}$(scm_char)$(scm_prompt_info) ${yellow}${white} " PS1="\n${green}$(virtualenv_prompt)${red}$(ruby_version_prompt) ${reset_color}\h ${orange}in ${reset_color}\w\n${yellow}$(scm_char)$(scm_prompt_info) ${yellow}${white} "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -21,4 +21,4 @@ function prompt_command() {
PS1="${no_color}\u:$(hostname)${normal}:${bold_yellow}\W/${normal} $(git_prompt_info)${reset_color}$ " PS1="${no_color}\u:$(hostname)${normal}:${bold_yellow}\W/${normal} $(git_prompt_info)${reset_color}$ "
} }
PROMPT_COMMAND=prompt_command; safe_append_prompt_command prompt_command

View File

@ -94,4 +94,4 @@ PS2="└─▪ "
PROMPT_COMMAND=prompt safe_append_prompt_command prompt