pull/1237/head
Ari Mourao 2018-10-02 10:16:56 -03:00
commit aa4e57cd67
63 changed files with 4860 additions and 1781 deletions

View File

@ -200,7 +200,7 @@ export BASH_IT_THEME="powerline-multiline"
export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash"
```
You can easily preview the themes in your own shell using `BASH_PREVIEW=true reload`.
You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`.
If you've created your own custom prompts, we'd love it if you shared with everyone else! Just submit a Pull Request.
You can see theme screenshots on [wiki/Themes](https://github.com/Bash-it/bash-it/wiki/Themes).

View File

@ -4,7 +4,9 @@ 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"
[[ $XCLIP ]] && \
alias pbcopy="$XCLIP -selection clipboard" && \
alias pbpaste="$XCLIP -selection clipboard -o"
;;
esac

View File

@ -30,6 +30,7 @@ alias gup='git fetch && git rebase'
alias gp='git push'
alias gpo='git push origin'
alias gpu='git push --set-upstream'
alias gpuo='git push --set-upstream origin'
alias gpom='git push origin master'
alias gr='git remote'
alias grv='git remote -v'

View File

@ -7,7 +7,6 @@ alias bcin='brew cask install'
alias bcrm='brew cask uninstall'
alias bczp='brew cask zap'
alias bccl='brew cask cleanup'
alias bcsr='brew cask search'
alias bcls='brew cask list'
alias bcinf='brew cask info'
alias bcdr='brew cask doctor'

View File

@ -0,0 +1,24 @@
#!/bin/bash
#
# -binaryanomaly
cite 'about-alias'
about-alias 'kubectl aliases'
# set apt aliases
function _set_pkg_aliases()
{
if [ -x $(which kubectl) ]; then
alias kc='kubectl'
alias kcgp='kubectl get pods'
alias kcgd='kubectl get deployments'
alias kcgn='kubectl get nodes'
alias kcdp='kubectl describe pod'
alias kcdd='kubectl describe deployment'
alias kcdn='kubectl describe node'
alias kcgpan='kubectl get pods --all-namespaces'
alias kcgdan='kubectl get deployments --all-namespaces'
fi
}
_set_pkg_aliases

View File

@ -3,9 +3,12 @@ about-alias 'maven abbreviations'
alias mci='mvn clean install'
alias mi='mvn install'
alias mcp='mvn clean package'
alias mp='mvn package'
alias mrprep='mvn release:prepare'
alias mrperf='mvn release:perform'
alias mrrb='mvn release:rollback'
alias mdep='mvn dependency:tree'
alias mpom='mvn help:effective-pom'
alias mcisk='mci -Dmaven.test.skip=true'
alias mcpsk='mcp -Dmaven.test.skip=true'

View File

@ -18,5 +18,5 @@ alias nod='npm outdated'
alias nrb='npm rebuild'
alias nud='npm update'
alias nr='npm run'
alias nls='npm list'
alias nlsg='npm list --global'
alias nls='npm list --depth=0 2>/dev/null'
alias nlsg='npm list -g --depth=0 2>/dev/null'

View File

@ -11,5 +11,5 @@ alias vasrv="vault server"
alias vas="vault status"
alias vav="vault version"
alias vaw="vault write"
alias vag="vault auth -method=github"
alias vag="vault login -method=github"
alias varv="vault read -field=value"

View File

@ -5,15 +5,18 @@ about-alias 'yarn package manager aliases'
alias ya='yarn'
alias yai='yarn init'
alias yaa='yarn add'
alias yaga='yarn global add'
alias yaad='yarn add --dev'
alias yau='yarn upgrade'
alias yarm='yarn remove'
alias yagrm='yarn global remove'
alias yaod='yarn outdated'
alias yapa='yarn pack'
alias yap='yarn publish'
alias yasu='yarn self-update'
alias yaru='yarn run'
alias yat='yarn test'
alias yas='yarn serve'
alias yacc='yarn cache clean'
alias yack='yarn check'
alias yals='yarn list'

View File

@ -1,23 +1,14 @@
#!/usr/bin/env bash
# Initialize Bash It
# Reload Library
case $OSTYPE in
darwin*)
alias reload='source ~/.bash_profile'
;;
*)
alias reload='source ~/.bashrc'
;;
esac
# Only set $BASH_IT if it's not already set
if [ -z "$BASH_IT" ];
then
# Setting $BASH to maintain backwards compatibility
# TODO: warn users that they should upgrade their .bash_profile
export BASH_IT=$BASH
export BASH="$(bash -c 'echo $BASH')"
BASH="$(bash -c 'echo $BASH')"
export BASH
fi
# For backwards compatibility, look in old BASH_THEME location
@ -25,7 +16,7 @@ if [ -z "$BASH_IT_THEME" ];
then
# TODO: warn users that they should upgrade their .bash_profile
export BASH_IT_THEME="$BASH_THEME";
unset $BASH_THEME;
unset BASH_THEME;
fi
# Load composure first, so we support function metadata
@ -40,9 +31,9 @@ LIB="${BASH_IT}/lib/*.bash"
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
for config_file in $LIB
do
if [ $config_file != $APPEARANCE_LIB ]; then
if [ "$config_file" != "$APPEARANCE_LIB" ]; then
# shellcheck disable=SC1090
source $config_file
source "$config_file"
fi
done
@ -60,12 +51,14 @@ done
source "${BASH_IT}/themes/colors.theme.bash"
# shellcheck source=./themes/githelpers.theme.bash
source "${BASH_IT}/themes/githelpers.theme.bash"
# shellcheck source=./themes/p4helpers.theme.bash
source "${BASH_IT}/themes/p4helpers.theme.bash"
# shellcheck source=./themes/base.theme.bash
source "${BASH_IT}/themes/base.theme.bash"
# appearance (themes) now, after all dependencies
# shellcheck source=./lib/appearance.bash
source $APPEARANCE_LIB
source "$APPEARANCE_LIB"
# Load custom aliases, completion, plugins
for file_type in "aliases" "completion" "plugins"
@ -83,7 +76,7 @@ for config_file in $CUSTOM
do
if [ -e "${config_file}" ]; then
# shellcheck disable=SC1090
source $config_file
source "$config_file"
fi
done
@ -110,5 +103,17 @@ then
. "$HOME/.jekyllconfig"
fi
# BASH_IT_RELOAD_LEGACY is set.
if ! command -v reload &>/dev/null && [ -n "$BASH_IT_RELOAD_LEGACY" ]; then
case $OSTYPE in
darwin*)
alias reload='source ~/.bash_profile'
;;
*)
alias reload='source ~/.bashrc'
;;
esac
fi
# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040
set +T

View File

@ -65,7 +65,7 @@ _bash-it-comp()
prev="${COMP_WORDS[COMP_CWORD-1]}"
chose_opt="${COMP_WORDS[1]}"
file_type="${COMP_WORDS[2]}"
opts="disable enable help migrate search show update version"
opts="disable enable help migrate reload search show update version"
case "${chose_opt}" in
show)
local show_args="aliases completions plugins"
@ -82,7 +82,7 @@ _bash-it-comp()
return 0
fi
;;
update | search | migrate | version)
migrate | reload | search | update | version)
return 0
;;
enable | disable)

View File

View File

@ -120,7 +120,7 @@ _docker_compose_build() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--build-arg --force-rm --help --no-cache --pull" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--build-arg --force-rm --help --memory --no-cache --pull" -- "$cur" ) )
;;
*)
__docker_compose_services_from_build
@ -403,14 +403,14 @@ _docker_compose_run() {
__docker_compose_nospace
return
;;
--entrypoint|--name|--user|-u|--volume|-v|--workdir|-w)
--entrypoint|--label|-l|--name|--user|-u|--volume|-v|--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 --volume -v --workdir -w" -- "$cur" ) )
COMPREPLY=( $( compgen -W "-d --entrypoint -e --help --label -l --name --no-deps --publish -p --rm --service-ports -T --user -u --volume -v --workdir -w" -- "$cur" ) )
;;
*)
__docker_compose_services_all

View File

@ -14,71 +14,160 @@
# . ~/.docker-machine-completion.sh
#
_docker_machine_active() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
# --- helper functions -------------------------------------------------------
_docker_machine_q() {
docker-machine 2>/dev/null "$@"
}
# suppresses trailing whitespace
_docker_machine_nospace() {
# compopt is not available in ancient bash versions (OSX)
# so only call it if it's available
type compopt &>/dev/null && compopt -o nospace
}
_docker_machine_machines() {
_docker_machine_q ls --format '{{.Name}}' "$@"
}
_docker_machine_drivers() {
local drivers=(
amazonec2
azure
digitalocean
exoscale
generic
google
hyperv
openstack
rackspace
softlayer
virtualbox
vmwarefusion
vmwarevcloudair
vmwarevsphere
)
echo "${drivers[@]}"
}
_docker_machine_value_of_option() {
local pattern="$1"
for (( i=2; i < ${cword}; ++i)); do
if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then
echo ${words[$i + 1]}
break
fi
done
}
# Returns `key` if we are currently completing the value of a map option
# (`key=value`) which matches the glob passed in as an argument.
# This function is needed for key-specific argument completions.
_docker_machine_map_key_of_current_option() {
local glob="$1"
local key glob_pos
if [ "$cur" = "=" ] ; then # key= case
key="$prev"
glob_pos=$((cword - 2))
elif [[ $cur == *=* ]] ; then # key=value case (OSX)
key=${cur%=*}
glob_pos=$((cword - 1))
elif [ "$prev" = "=" ] ; then
key=${words[$cword - 2]} # key=value case
glob_pos=$((cword - 3))
else
COMPREPLY=()
return
fi
[ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
[[ ${words[$glob_pos]} == $glob ]] && echo "$key"
}
# --- completion functions ---------------------------------------------------
_docker_machine_active() {
case "${prev}" in
--timeout|-t)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --timeout -t" -- "${cur}"))
fi
}
_docker_machine_config() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}"))
COMPREPLY=($(compgen -W "--help --swarm" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${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}"))
case "${prev}" in
--driver|-d)
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur}"))
return
;;
esac
# driver specific options are only included in help output if --driver is given,
# so we have to pass that option when calling docker-machine to harvest options.
local driver="$(_docker_machine_value_of_option '--driver|-d')"
local parsed_options="$(_docker_machine_q create ${driver:+--driver $driver} --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')"
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${parsed_options} -d --help" -- "${cur}"))
fi
}
_docker_machine_env() {
case "${prev}" in
--shell)
# What are the options for --shell?
COMPREPLY=()
COMPREPLY=($(compgen -W "cmd fish powershell tcsh" -- "${cur}"))
return
;;
*)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --shell --unset --no-proxy --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
fi
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --no-proxy --shell --swarm --unset -u" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
# See docker-machine-wrapper.bash for the use command
_docker_machine_use() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}"))
COMPREPLY=($(compgen -W "--help --swarm --unset" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${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
--format|-f)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--format -f --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_ip() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -86,26 +175,52 @@ _docker_machine_kill() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_ls() {
case "${prev}" in
--filter)
COMPREPLY=()
local key=$(_docker_machine_map_key_of_current_option '--filter')
case "$key" in
driver)
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur##*=}"))
return
;;
*)
COMPREPLY=($(compgen -W "--quiet --filter --format --timeout --help" -- "${cur}"))
state)
COMPREPLY=($(compgen -W "Error Paused Running Saved Starting Stopped Stopping" -- "${cur##*=}"))
return
;;
esac
case "${prev}" in
--filter)
COMPREPLY=($(compgen -W "driver label name state swarm" -S= -- "${cur}"))
_docker_machine_nospace
return
;;
--format|-f|--timeout|-t)
return
;;
esac
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--filter --format -f --help --quiet -q --timeout -t" -- "${cur}"))
fi
}
_docker_machine_provision() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
_docker_machine_regenerate_certs() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force" -- "${cur}"))
COMPREPLY=($(compgen -W "--force -f --help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
@ -113,16 +228,15 @@ _docker_machine_restart() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_rm() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}"))
COMPREPLY=($(compgen -W "--force -f --help -y" -- "${cur}"))
else
# For rm, it's best to be explicit
COMPREPLY=()
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -130,18 +244,18 @@ _docker_machine_ssh() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
_docker_machine_scp() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}"))
COMPREPLY=($(compgen -W "--delta -d --help --recursive -r" -- "${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[@]}")
COMPREPLY=($(compgen -W "$(_docker_machine_machines | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}")
fi
}
@ -149,7 +263,7 @@ _docker_machine_start() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Stopped)" -- "${cur}"))
fi
}
@ -157,7 +271,7 @@ _docker_machine_status() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -165,7 +279,7 @@ _docker_machine_stop() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
fi
}
@ -173,7 +287,7 @@ _docker_machine_upgrade() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -181,7 +295,7 @@ _docker_machine_url() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -189,7 +303,7 @@ _docker_machine_version() {
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
else
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
fi
}
@ -215,7 +329,7 @@ _docker_machine_docker_machine() {
_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 commands=(active config create env inspect ip kill ls provision 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)
@ -249,4 +363,4 @@ _docker_machine() {
return 0
}
complete -F _docker_machine docker-machine
complete -F _docker_machine docker-machine docker-machine.exe

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
# Invoke (pyinvoke.org) tab-completion script to be sourced with Bash shell.
# https://github.com/pyinvoke/invoke/blob/master/completion/bash
_complete_invoke() {
local candidates
# COMP_WORDS contains the entire command string up til now (including
# program name).
# We hand it to Invoke so it can figure out the current context: spit back
# core options, task names, the current task's options, or some combo.
candidates=`invoke --complete -- ${COMP_WORDS[*]}`
# `compgen -W` takes list of valid options & a partial word & spits back
# possible matches. Necessary for any partial word completions (vs
# completions performed when no partial words are present).
#
# $2 is the current word or token being tabbed on, either empty string or a
# partial word, and thus wants to be compgen'd to arrive at some subset of
# our candidate list which actually matches.
#
# COMPREPLY is the list of valid completions handed back to `complete`.
COMPREPLY=( $(compgen -W "${candidates}" -- $2) )
}
# Tell shell builtin to use the above for completing 'inv'/'invoke':
# * -F: use given function name to generate completions.
# * -o default: when function generates no results, use filenames.
# * positional args: program names to complete for.
complete -F _complete_invoke -o default invoke inv

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# minikube (Local Kubernetes) completion
if command -v minikube &>/dev/null
then
eval "$(minikube completion bash)"
fi

View File

@ -1 +1 @@
[[ -x "$(which pipenv)" ]] && source <(env _PIPENV_COMPLETE="source-bash" pipenv)
[[ -x "$(which pipenv)" ]] && eval "$(pipenv --completion)"

View File

@ -27,10 +27,14 @@ _sdkman_complete()
esac
elif [ $COMP_CWORD -eq 3 ]; then
case "${COMP_WORDS[COMP_CWORD-2]}" in
"install" | "uninstall" | "rm" | "use" | "default" )
"uninstall" | "rm" | "use" | "default" )
_sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) )
;;
"install")
_sdkman_candidate_not_installed_versions ${COMP_WORDS[COMP_CWORD-1]}
COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) )
;;
*)
;;
esac
@ -51,6 +55,14 @@ _sdkman_candidate_versions(){
}
_sdkman_candidate_not_installed_versions(){
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1)
if [ "$SDKMAN_OFFLINE_MODE" = "false" ]; then
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 6-)"
CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS | tr ' ' '\n' | sort | uniq -u) "
fi
}
__sdkman_cleanup_local_versions(){
__sdkman_build_version_csv $1 | tr ',' ' '

View File

@ -11,11 +11,16 @@ _sshcomplete() {
local OPTIONS=" -- ${CURRENT_PROMPT}"
fi
# parse all defined hosts from .ssh/config
if [ -r "$HOME/.ssh/config" ]; then
COMPREPLY=($(compgen -W "$(grep -i ^Host "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
# parse all defined hosts from .ssh/config and files included there
for fl in "$HOME/.ssh/config" \
$(grep "^\s*Include" "$HOME/.ssh/config" |
awk '{for (i=2; i<=NF; i++) print $i}' |
sed "s|^~/|$HOME/|")
do
if [ -r "$fl" ]; then
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$(grep -i ^Host "$fl" |grep -v '[*!]' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
fi
done
# parse all hosts found in .ssh/known_hosts
if [ -r "$HOME/.ssh/known_hosts" ]; then

View File

@ -21,7 +21,7 @@ if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then
fi
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
if [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then
if [ "${BASH_VERSINFO}" -ge 4 ] && [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then
. "$BREW_PREFIX"/share/bash-completion/bash_completion
fi
fi

View File

@ -1,26 +1,65 @@
#!/usr/bin/env bash
# Bash Terraform completion
#
# Bash completion for the terraform command
#
# Copyright (C) 2018 Vangelis Tasoulas
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
_terraform()
{
local cmds cur colonprefixes
cmds="apply destroy fmt get graph import init \
output plan push refresh remote show taint \
untaint validate version state"
local cur prev words cword opts
_get_comp_words_by_ref -n : cur prev words cword
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
# Work-around bash_completion issue where bash interprets a colon
# as a separator.
# Work-around borrowed from the darcs work-around for the same
# issue.
colonprefixes=${cur%"${cur##*:}"}
COMPREPLY=( $(compgen -W '$cmds' -- $cur))
local i=${#COMPREPLY[*]}
while [ $((--i)) -ge 0 ]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
done
opts=""
if [[ ${cword} -eq 1 ]] ; then
# Options that do not start with a hyphen, are always starting with four spaces.
opts="$(terraform --help | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
opts="${opts} --help --version"
elif [[ ${cword} -gt 1 ]] ; then
if [[ ${cword} -eq 2 && ${prev} == '--help' ]] ; then
opts="$(terraform --help | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
elif [[ ${words[1]} != "--help" && ${words[1]} != "--version" && ${words[1]} != "version" ]] ; then
# Some commands accept hyphened parameters, ...
opts="$(terraform --help "${words[1]}" | grep -E '^\s+-' | awk '{print $1}' | awk -F '=' '{ if ($0 ~ /=/) {print $1"="} else {print $1} }')"
# but some other commands accept non-hyphened parameters.
opts="${opts} $(terraform --help "${words[1]}" | grep -E '^\s\s\s\s\S' | awk '{print $1}')"
# All of the commands accept the --help parameter which is not listed
# by the 'terraform --help <command>
opts="${opts} --help"
fi
fi
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
if [[ ${#COMPREPLY[*]} -eq 1 ]] ; then
if [[ ${COMPREPLY[0]} == *= ]] ; then
# When only one completion is left, check if there is an equal sign.
# If an equal sign, then add no space after the autocompleted word.
compopt -o nospace
fi
fi
return 0
} &&
}
complete -F _terraform terraform

View File

@ -0,0 +1,148 @@
#!/usr/bin/env bash
# bash completion for virsh - main CLI of libvirt
# This script provides bash completion for virsh,
# borrowed from https://github.com/LuyaoHuang/virsh-bash-completion
_contain_cmd()
{
local e f
local array1=($1) array2=($2)
for e in "${array1[@]}"
do
for f in "${array2[@]}"
do
if [[ "$e" == "$f" ]] ; then
echo $e
return
fi
done
done
echo "notfound"
return
}
_virsh_list_networks()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q net-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_domains()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q list $flags | cut -d\ -f7 | awk '{print $1}'
}
_virsh_list_pools()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q pool-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_ifaces()
{
local flag_all=$1 flags
if [ "$flag_all" -eq 1 ]; then
flags="--all"
else
flags="--inactive"
fi
virsh -q iface-list $flags | cut -d\ -f2 | awk '{print $1}'
}
_virsh_list_nwfilters()
{
virsh -q nwfilter-list | cut -d\ -f4 | awk '{print $1}'
}
_virsh()
{
local cur prev cmds doms options nets pools cmds_help
local flag_all=1 array ret a b ifaces nwfilters files
# not must use bash-completion now :)
# _init_completion -s || return
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmds=$( echo "$(virsh -h| grep '^ ' | cut -d\ -f5)" \
"$(virsh -h| grep '\--' | cut -d\ -f7 | cut -d= -f1)")
cmds_help=$(virsh help| grep '^ ' | cut -d\ -f5)
case "$prev" in
--domain)
doms=$(_virsh_list_domains "$flag_all")
COMPREPLY=( $(compgen -W "$doms" -- "$cur") )
return 0
;;
--network)
nets=$(_virsh_list_networks "$flag_all")
COMPREPLY=( $(compgen -W "$nets" -- "$cur") )
return 0
;;
--pool)
pools=$(_virsh_list_pools "$flag_all")
COMPREPLY=( $(compgen -W "$pools" -- "$cur") )
return 0
;;
--interface)
ifaces=$(_virsh_list_ifaces "$flag_all")
COMPREPLY=( $(compgen -W "$ifaces" -- "$cur") )
return 0
;;
--nwfilter)
nwfilters=$(_virsh_list_nwfilters)
COMPREPLY=( $(compgen -W "$nwfilters" -- "$cur") )
return 0
;;
--file|--xml)
files=$(ls)
COMPREPLY=( $(compgen -W "$files" -- "$cur") )
return 0
;;
esac
array=$(IFS=$'\n'; echo "${COMP_WORDS[*]}")
ret=$(_contain_cmd "$array" "$cmds_help")
if [[ "$ret" != "notfound" && "$ret" != "$cur" ]]; then
a=$(virsh help "$ret" |grep '^ --'|cut -d\ -f5)
b=$(virsh help "$ret" |grep '^ \[--'|cut -d\ -f5|cut -d[ -f2|cut -d] -f1)
options=$( echo $a $b )
COMPREPLY=( $(compgen -W "$options" -- "$cur") )
return 0
fi
case "$cur" in
*)
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
return 0
;;
esac
} &&
complete -o default -F _virsh virsh

View File

@ -167,7 +167,7 @@ then
done
else
echo ""
echo -e "\033[0;32mEnabling sane defaults\033[0m"
echo -e "\033[0;32mEnabling reasonable defaults\033[0m"
_enable-completion bash-it
_enable-completion system
_enable-plugin base

View File

@ -61,7 +61,7 @@ function reload_plugins() {
bash-it ()
{
about 'Bash-it help and maintenance'
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version ] '
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] '
param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)'
param '3: specific component [optional]'
example '$ bash-it show plugins'
@ -72,6 +72,7 @@ bash-it ()
example '$ bash-it update'
example '$ bash-it search ruby [[-]rake]... [--enable | --disable]'
example '$ bash-it version'
example '$ bash-it reload'
typeset verb=${1:-}
shift
typeset component=${1:-}
@ -95,6 +96,8 @@ bash-it ()
func=_bash-it-migrate;;
version)
func=_bash-it-version;;
reload)
func=_bash-it-reload;;
*)
reference bash-it
return;;
@ -184,7 +187,7 @@ _bash-it_update() {
_bash-it-migrate
echo ""
echo "All done, enjoy!"
reload
bash-it reload
else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi
@ -248,6 +251,25 @@ _bash-it-version() {
echo "Current git SHA: $BASH_IT_GIT_VERSION_INFO"
echo "$BASH_IT_GIT_URL/commit/$BASH_IT_GIT_SHA"
echo "Compare to latest: $BASH_IT_GIT_URL/compare/$BASH_IT_GIT_SHA...master"
cd - &> /dev/null || return
}
_bash-it-reload() {
_about 'reloads a profile file'
_group 'lib'
cd "${BASH_IT}" || return
case $OSTYPE in
darwin*)
source ~/.bash_profile
;;
*)
source ~/.bashrc
;;
esac
cd - &> /dev/null || return
}

View File

@ -29,7 +29,7 @@ function alias_completion {
(( ${#completions[@]} == 0 )) && return 0
# create temporary file for wrapper functions and completions
local tmp_file; tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXX.tmp")" || return 1
local tmp_file; tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
local completion_loader; completion_loader="$(complete -p -D 2>/dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')"
@ -56,7 +56,7 @@ function alias_completion {
continue
fi
fi
local new_completion="$(complete -p "$alias_cmd")"
local new_completion="$(complete -p "$alias_cmd" 2>/dev/null)"
# create a wrapper inserting the alias arguments if any
if [[ -n $alias_args ]]; then
@ -77,8 +77,10 @@ function alias_completion {
fi
# replace completion trigger by alias
if [[ -n $new_completion ]]; then
new_completion="${new_completion% *} $alias_name"
echo "$new_completion" >> "$tmp_file"
fi
done < <(alias -p | sed -Ene "s/$alias_regex/\2 '\3' '\4'/p")
source "$tmp_file" && rm -f "$tmp_file"
}; alias_completion

View File

@ -5,7 +5,7 @@ explain () {
about 'explain any bash command via mankier.com manpage API'
param '1: Name of the command to explain'
example '$ explain # interactive mode. Type commands to explain in REPL'
example '$ explain 'cmd -o | ...' # one quoted command to explain it.'
example '$ explain '"'"'cmd -o | ...'"'"' # one quoted command to explain it.'
group 'explain'
if [ "$#" -eq 0 ]; then

View File

@ -6,6 +6,10 @@ about-plugin 'load fzf, if you are using it'
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
if [ -z ${FZF_DEFAULT_COMMAND+x} ]; then
command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f'
fi
fe() {
about "Open the selected file in the default editor"
group "fzf"
@ -18,11 +22,11 @@ fe() {
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
}
fd() {
fcd() {
about "cd to the selected directory"
group "fzf"
param "1: Directory to browse, or . if omitted"
example "fd aliases"
example "fcd aliases"
local dir
dir=$(find ${1:-.} -path '*/\.*' -prune \

View File

@ -33,8 +33,14 @@ function v2gif {
# Parse the options
local args=$(getopt -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@")
if [ $? -ne 0 ]; then
echo 'Terminating...' >&2
return 2
fi
eval set -- "$args"
local use_gifski=""
local del_after=""
local opt_del_after=""
local maxsize=""
local lossiness=""
local maxwidthski=""
@ -45,7 +51,6 @@ function v2gif {
local fps=""
local make_webm=""
local alert=5000
eval set -- "$args"
while [ $# -ge 1 ]; do
case "$1" in
--)
@ -55,7 +60,7 @@ function v2gif {
;;
-d|--del|--delete)
# Delete after
del_after="true"
opt_del_after="true"
shift
;;
-h|--high)
@ -100,10 +105,7 @@ function v2gif {
esac
done
# Done Parsing, all that's left are the filenames
local movies="$*"
if [[ -z "$movies" ]]; then
if [[ -z "$*" ]]; then
echo "$(tput setaf 1)No input files given. Example: v2gif file [file...] [-w <max width (pixels)>] [-l <lossy level>] < $(tput sgr 0)"
return 1
fi
@ -112,14 +114,15 @@ function v2gif {
[[ -z "$giftag" ]] && giftag="-default"
[[ -z "$giftagopt" ]] && giftag=""
for file in $movies ; do
for file ; do
local output_file="${file%.*}${giftag}.gif"
local del_after=$opt_del_after
if [[ "$make_webm" ]] ; then
ffmpeg -loglevel panic -i "$file" \
-c:v libvpx -crf 4 -threads 0 -an -b:v 2M -auto-alt-ref 0 -quality best \
"${file%.*}.webm" || return 2
-c:v libvpx -crf 4 -threads 0 -an -b:v 2M -auto-alt-ref 0 \
-quality best -loop 0 "${file%.*}.webm" || return 2
fi
# Set FPS to match the video if possible, otherwise fallback to default.
@ -151,7 +154,8 @@ function v2gif {
if [[ $alert -gt 0 ]] ; then
local out_size=$(wc --bytes < "$output_file")
if [[ $out_size -gt $(( alert * 1000 )) ]] ; then
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size/1000))kb, keeping '$file' even if --del requested.$(tput sgr 0)"
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size/1000))kb.$(tput sgr 0)"
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
del_after=""
fi
fi
@ -179,7 +183,13 @@ function any2webm() {
# Parse the options
local args=$(getopt -l alert -l "bandwidth:" -l "width:" -l del,delete -l tag -l "fps:" -l webm -o "a:b:w:f:dt" -- "$@")
local del_after=""
if [ $? -ne 0 ]; then
echo 'Terminating...' >&2
return 2
fi
eval set -- "$args"
local opt_del_after=""
local size=""
local webmtagopt=""
local webmtag=""
@ -187,7 +197,6 @@ function any2webm() {
local fps=""
local bandwidth="2M"
local alert=5000
eval set -- "$args"
while [ $# -ge 1 ]; do
case "$1" in
--)
@ -197,7 +206,7 @@ function any2webm() {
;;
-d|--del|--delete)
# Delete after
del_after="true"
opt_del_after="true"
shift
;;
-s|--size)
@ -230,10 +239,7 @@ function any2webm() {
esac
done
# Done Parsing, all that's left are the filenames
local movies="$*"
if [[ -z "$movies" ]]; then
if [[ -z "$*" ]]; then
echo "$(tput setaf 1)No input files given. Example: any2webm file [file...] [-w <max width (pixels)>] < $(tput sgr 0)"
return 1
fi
@ -242,21 +248,23 @@ function any2webm() {
[[ -z "$webmtag" ]] && webmtag="-default"
[[ -z "$webmtagopt" ]] && webmtag=""
for file in $movies ; do
for file ; do
local output_file="${file%.*}${webmtag}.webm"
local del_after=$opt_del_after
echo "$(tput setaf 2)Creating '$output_file' ...$(tput sgr 0)"
ffmpeg -loglevel panic -i "$file" \
-c:v libvpx -crf 4 -threads 0 -an -b:v $bandwidth -auto-alt-ref 0 \
-quality best $fps $size -pix_fmt yuva420p "$output_file" || return 2
-quality best $fps $size -loop 0 -pix_fmt yuva420p "$output_file" || return 2
# Checking if the file is bigger than Twitter likes and warn
if [[ $alert -gt 0 ]] ; then
local out_size=$(wc --bytes < "$output_file")
if [[ $out_size -gt $(( alert * 1000 )) ]] ; then
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size/1000))kb, keeping '$file' even if --del requested.$(tput sgr 0)"
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size/1000))kb.$(tput sgr 0)"
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
del_after=""
fi
fi

View File

@ -0,0 +1,47 @@
cite about-plugin
about-plugin 'Maven jgitflow build helpers'
function hotfix-start {
about 'helper function for starting a new hotfix'
group 'jgitflow'
mvn jgitflow:hotfix-start ${JGITFLOW_MVN_ARGUMENTS}
}
function hotfix-finish {
about 'helper function for finishing a hotfix'
group 'jgitflow'
mvn jgitflow:hotfix-finish -Darguments="${JGITFLOW_MVN_ARGUMENTS}" && git push && git push origin master && git push --tags
}
function feature-start {
about 'helper function for starting a new feature'
group 'jgitflow'
mvn jgitflow:feature-start ${JGITFLOW_MVN_ARGUMENTS}
}
function feature-finish {
about 'helper function for finishing a feature'
group 'jgitflow'
mvn jgitflow:feature-finish ${JGITFLOW_MVN_ARGUMENTS}
echo -e '\033[32m----------------------------------------------------------------\033[0m'
echo -e '\033[32m===== REMEMBER TO CREATE A NEW RELEASE TO DEPLOY THIS FEATURE ====\033[0m'
echo -e '\033[32m----------------------------------------------------------------\033[0m'
}
function release-start {
about 'helper function for starting a new release'
group 'jgitflow'
mvn jgitflow:release-start ${JGITFLOW_MVN_ARGUMENTS}
}
function release-finish {
about 'helper function for finishing a release'
group 'jgitflow'
mvn jgitflow:release-finish -Darguments="${JGITFLOW_MVN_ARGUMENTS}" && git push && git push origin master && git push --tags
}

View File

@ -0,0 +1,9 @@
cite about-plugin
about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump)'
__init_jump() {
command -v jump &> /dev/null || return
eval "$(jump shell --bind=z)"
}
__init_jump

View File

@ -0,0 +1,10 @@
cite about-plugin
about-plugin 'load nodenv, if you are using it'
export NODENV_ROOT="$HOME/.nodenv"
pathmunge "$NODENV_ROOT/bin"
[[ `which nodenv` ]] && eval "$(nodenv init -)"
# Load the auto-completion script if nodenv was loaded.
[[ -e $NODENV_ROOT/completions/nodenv.bash ]] && source $NODENV_ROOT/completions/nodenv.bash

View File

@ -5,7 +5,7 @@ about-plugin 'osx-specific functions'
if [ $(uname) = "Darwin" ]; then
if type update_terminal_cwd > /dev/null 2>&1 ; then
if ! [[ $PROMPT_COMMAND =~ (^|;)update_terminal_cwd($|;) ]] ; then
PROMPT_COMMAND="$PROMPT_COMMAND;update_terminal_cwd"
PROMPT_COMMAND="${PROMPT_COMMAND%;};update_terminal_cwd"
declared="$(declare -p PROMPT_COMMAND)"
[[ "$declared" =~ \ -[aAilrtu]*x[aAilrtu]*\ ]] 2>/dev/null
[[ $? -eq 0 ]] && export PROMPT_COMMAND
@ -98,5 +98,18 @@ function prevcurl() {
curl "$*" | open -fa $PREVIEW
}
function refresh-launchpad() {
about 'Reset launchpad layout in macOS'
example '$ refresh-launchpad'
group 'osx'
if [ $(uname) = "Darwin" ];then
defaults write com.apple.dock ResetLaunchPad -bool TRUE
killall Dock
else
echo "Sorry, this only works on Mac OS X"
fi
}
# Make this backwards compatible
alias pcurl='prevcurl'

View File

@ -35,7 +35,10 @@ if command -v percol>/dev/null; then
bind -x '"\C-r": _replace_by_history'
# bind zz to percol if fasd enable
if [[ $(type -t zz) == 'alias' ]]; then
unalias zz
fi
if command -v fasd>/dev/null; then
function zz() {
local l=$(fasd -d | awk '{print $2}' | percol)

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
cite about-plugin
about-plugin 'enables powerline daemon'
command -v powerline-daemon &>/dev/null || return
powerline-daemon -q
#the following should not be executed if bashit powerline themes in use
case "$BASH_IT_THEME" in
*powerline*)
return
;;
esac
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
bashPowerlineInit=$(python -c \
"import os; \
import powerline;\
print(os.path.join(os.path.dirname(\
powerline.__file__),\
'bindings', \
'bash', \
'powerline.sh'))")
[ -e $bashPowerlineInit ] || return
. $bashPowerlineInit

View File

@ -236,11 +236,11 @@ svn-show-proxy ()
about 'Shows SVN proxy settings'
group 'proxy'
if $(command -v svn &> /dev/null) && $(command -v python &> /dev/null) ; then
if $(command -v svn &> /dev/null) && $(command -v python2 &> /dev/null) ; then
echo ""
echo "SVN Proxy Settings"
echo "=================="
python - <<END
python2 - <<END
import ConfigParser, os
config = ConfigParser.ConfigParser()
config.read(os.path.expanduser('~/.subversion/servers'))
@ -266,8 +266,8 @@ svn-disable-proxy ()
about 'Disables SVN proxy settings'
group 'proxy'
if $(command -v svn &> /dev/null) && $(command -v python &> /dev/null) ; then
python - <<END
if $(command -v svn &> /dev/null) && $(command -v python2 &> /dev/null) ; then
python2 - <<END
import ConfigParser, os
config = ConfigParser.ConfigParser()
config.read(os.path.expanduser('~/.subversion/servers'))
@ -295,10 +295,10 @@ svn-enable-proxy ()
about 'Enables SVN proxy settings'
group 'proxy'
if $(command -v svn &> /dev/null) && $(command -v python &> /dev/null) ; then
if $(command -v svn &> /dev/null) && $(command -v python2 &> /dev/null) ; then
local my_http_proxy=${1:-$BASH_IT_HTTP_PROXY}
python - "$my_http_proxy" "$BASH_IT_NO_PROXY" <<END
python2 - "$my_http_proxy" "$BASH_IT_NO_PROXY" <<END
import ConfigParser, os, sys, urlparse
pieces = urlparse.urlparse(sys.argv[1])
host = pieces.hostname

View File

@ -1,9 +1,13 @@
# make sure virtualenvwrapper is enabled if available
cite about-plugin
about-plugin 'virtualenvwrapper helper functions'
about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions'
if _command_exists pyenv; then
pyenv virtualenvwrapper
else
[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh
fi
function mkvenv {

View File

@ -48,5 +48,8 @@ export SCM_CHECK=true
# after enabling or disabling aliases, plugins, and completions.
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1
# Uncomment this to make Bash-it create alias reload.
# export BASH_IT_RELOAD_LEGACY=1
# Load Bash It
source "$BASH_IT"/bash_it.sh

View File

@ -99,32 +99,32 @@ function __check_completion () {
@test "completion bash-it: show options" {
run __check_completion 'bash-it '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: bash-ti - show options" {
run __check_completion 'bash-ti '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: shit - show options" {
run __check_completion 'shit '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: bashit - show options" {
run __check_completion 'bashit '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: batshit - show options" {
run __check_completion 'batshit '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: bash_it - show options" {
run __check_completion 'bash_it '
assert_line -n 0 "disable enable help migrate search show update version"
assert_line -n 0 "disable enable help migrate reload search show update version"
}
@test "completion bash-it: show - show options" {

View File

@ -4,6 +4,7 @@ unset NGINX_PATH
unset IRC_CLIENT
unset TODO
unset SCM_CHECK
unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE
BASH_IT_TEST_DIR="${BATS_TMPDIR}/.bash_it"

View File

@ -7,6 +7,8 @@ CLOCK_THEME_PROMPT_SUFFIX=''
THEME_PROMPT_HOST='\H'
SCM=
SCM_CHECK=${SCM_CHECK:=true}
SCM_THEME_PROMPT_DIRTY=' ✗'
@ -42,6 +44,12 @@ SCM_GIT_STAGED_CHAR="S:"
SCM_GIT_STASH_CHAR_PREFIX="{"
SCM_GIT_STASH_CHAR_SUFFIX="}"
SCM_P4='p4'
SCM_P4_CHAR='⌛'
SCM_P4_CHANGES_CHAR='C:'
SCM_P4_DEFAULT_CHAR='D:'
SCM_P4_OPENED_CHAR='O:'
SCM_HG='hg'
SCM_HG_CHAR='☿'
@ -58,6 +66,8 @@ THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
USER_HOST_THEME_PROMPT_PREFIX=''
USER_HOST_THEME_PROMPT_SUFFIX=''
VIRTUAL_ENV=
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
@ -69,11 +79,12 @@ RBFU_THEME_PROMPT_SUFFIX='|'
function scm {
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE
elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT
elif [[ -f .git/HEAD ]] && which git &> /dev/null; then SCM=$SCM_GIT
elif which git &> /dev/null && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT
elif [[ -d .hg ]]; then SCM=$SCM_HG
elif which p4 &> /dev/null && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then SCM=$SCM_P4
elif [[ -d .hg ]] && which hg &> /dev/null; then SCM=$SCM_HG
elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG
elif [[ -d .svn ]]; then SCM=$SCM_SVN
elif [[ -d .svn ]] && which svn &> /dev/null; then SCM=$SCM_SVN
else SCM=$SCM_NONE
fi
}
@ -81,6 +92,7 @@ function scm {
function scm_prompt_char {
if [[ -z $SCM ]]; then scm; fi
if [[ $SCM == $SCM_GIT ]]; then SCM_CHAR=$SCM_GIT_CHAR
elif [[ $SCM == $SCM_P4 ]]; then SCM_CHAR=$SCM_P4_CHAR
elif [[ $SCM == $SCM_HG ]]; then SCM_CHAR=$SCM_HG_CHAR
elif [[ $SCM == $SCM_SVN ]]; then SCM_CHAR=$SCM_SVN_CHAR
else SCM_CHAR=$SCM_NONE_CHAR
@ -93,6 +105,7 @@ function scm_prompt_vars {
SCM_DIRTY=0
SCM_STATE=''
[[ $SCM == $SCM_GIT ]] && git_prompt_vars && return
[[ $SCM == $SCM_P4 ]] && p4_prompt_vars && return
[[ $SCM == $SCM_HG ]] && hg_prompt_vars && return
[[ $SCM == $SCM_SVN ]] && svn_prompt_vars && return
}
@ -125,6 +138,7 @@ function scm_prompt_info_common {
fi
# TODO: consider adding minimal status information for hg and svn
[[ ${SCM} == ${SCM_P4} ]] && p4_prompt_info && return
[[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return
[[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return
}
@ -193,6 +207,26 @@ function git_prompt_vars {
SCM_CHANGE=$(_git-short-sha 2>/dev/null || echo "")
}
function p4_prompt_vars {
IFS=$'\t' read -r \
opened_count non_default_changes default_count \
add_file_count edit_file_count delete_file_count \
<<< "$(_p4-opened-counts)"
if [[ "${opened_count}" -gt 0 ]]; then
SCM_DIRTY=1
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
[[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR}${opened_count}"
[[ "${non_default_changes}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_CHANGES_CHAR}${non_default_changes}"
[[ "${default_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_DEFAULT_CHAR}${default_count}"
else
SCM_DIRTY=0
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
fi
SCM_PREFIX=${P4_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
SCM_SUFFIX=${P4_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
}
function svn_prompt_vars {
if [[ -n $(svn status 2> /dev/null) ]]; then
SCM_DIRTY=1
@ -313,7 +347,7 @@ function condaenv_prompt {
}
function py_interp_prompt {
py_version=$(python --version 2>&1 | awk '{print "py-"$2;}') || return
py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return
echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}"
}
@ -359,10 +393,16 @@ function user_host_prompt {
# backwards-compatibility
function git_prompt_info {
_git-hide-status && return
git_prompt_vars
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
}
function p4_prompt_info() {
p4_prompt_vars
echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE}${SCM_STATE}${SCM_SUFFIX}"
}
function svn_prompt_info {
svn_prompt_vars
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
function prompt_command() {
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ${normal}";
}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}

View File

@ -0,0 +1,22 @@
# Single line PS1 theme w/realtime history among windows
Minimal theme overrides from bash_it base theming
## `user@host:path[virt-env][scm] $`
Breakdown of the segments:
- **user@host:path** - *convienient for LAN based `ssh` and `scp` tasks*
- [**virtualenv**] - *only appears when activated*
- [**scm**] - *only appears when activated*
- **marker** - *$ or # depending on current user*
### Examples
```bash
user@example.lan:~ $ cd /tmp/foo/bar/baz
user@example.lan:/tmp/foo/bar/baz $ cd $HOME/workspace
user@example.lan:~/workspace $ cd sampleRepo/
user@example.lan:~/workspace/sampleRepo [± |master ↑1 ↓3 {1} S:2 ?:1 ✗|] $
```

View File

@ -0,0 +1,38 @@
SCM_THEME_PROMPT_PREFIX=${SCM_THEME_PROMPT_SUFFIX}
SCM_THEME_PROMPT_DIRTY="${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN="${bold_green}${normal}"
SCM_GIT_CHAR="${green}±${normal}"
scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
return
else
echo " [$(scm_char)$(scm_prompt_info)]"
fi
}
mark_prompt() {
echo "${green}\$${normal}"
}
user_host_path_prompt() {
ps_user="${green}\u${normal}";
ps_host="${blue}\H${normal}";
ps_path="${yellow}\w${normal}";
echo "$ps_user@$ps_host:$ps_path"
}
prompt() {
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
}
share_history() {
history -a
history -c
history -r
}
safe_append_prompt_command share_history
safe_append_prompt_command prompt

View File

@ -100,8 +100,7 @@ prompt() {
if [ $(uname) = "Linux" ];
then
PS1="${TITLEBAR}
${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}
$(safe_battery_charge)${RESTORE_CURSOR}\
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" ${green}| "
SCM_THEME_PROMPT_SUFFIX="${green} |"
SCM_NONE_CHAR='◐ '
SCM_GIT_SHOW_MINIMAL_INFO=true
GIT_THEME_PROMPT_DIRTY=" ${red}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX=" ${green}|"
GIT_THEME_PROMPT_SUFFIX="${green}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX=" d|"
BOLD="\[\e[1m\]"
function prompt_command() {
PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} "
}
safe_append_prompt_command prompt_command

View File

@ -71,7 +71,8 @@ function _git-hide-status {
}
function _git-status {
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno'
local git_status_flags=
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno'
git status --porcelain ${git_status_flags} 2> /dev/null
}
@ -102,7 +103,8 @@ function _git-status-counts {
function _git-remote-info {
[[ "$(_git-upstream)" == "" ]] && return
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true
local same_branch_name=
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "$(_git-num-remotes)" -ge 2 ]]) ||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
if [[ "${same_branch_name}" != "true" ]]; then

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
function set_prompt_symbol () {
if test $1 -eq 0 ; then
PROMPT_SYMBOL=">_"
else
PROMPT_SYMBOL="${orange}>_${normal}"
fi
}
function prompt_command() {
set_prompt_symbol $?
if test -z "$VIRTUAL_ENV" ; then
PYTHON_VIRTUALENV=""
else
PYTHON_VIRTUALENV="${bold_yellow}[`basename \"$VIRTUAL_ENV\"`]"
fi
PS1="${bold_orange}${PYTHON_VIRTUALENV}${reset_color}${bold_green}[\w]${bold_blue}\[$(scm_prompt_info)\]${normal} \n${PROMPT_SYMBOL} "
}
# scm themeing
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX="["
SCM_THEME_PROMPT_SUFFIX="]"
safe_append_prompt_command prompt_command

View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
function _p4-opened {
timeout 2.0s p4 opened -s 2> /dev/null
}
function _p4-opened-counts {
# Return the following counts seperated by tabs:
# - count of opened files
# - count of pending changesets (other than defaults)
# - count of files in the default changeset
# - count of opened files in add mode
# - count of opened files in edit mode
# - count of opened files in delete mode
_p4-opened | awk '
BEGIN {
opened=0;
type_array["edit"]=0;
type_array["add"]=0;
type_array["delete"]=0;
change_array["change"]=0;
}
{
# p4 opened prints one file per line, and all lines begin with "//"
# Here is an examples:
#
# $ p4 opened
# //depot/some/file.py#4 - edit change 716431 (text)
# //depot/another/file.py - edit default change (text)
# //now/add/a/newfile.sh - add change 435645 (text+k)
#
#
if ($1 ~ /^\/\//) {
opened += 1
change_array[$5] += 1
type_array[$3] += 1
}
}
END {
default_changes=change_array["change"];
non_default_changes=length(change_array) - 1;
print opened "\t" non_default_changes "\t" default_changes "\t" type_array["add"] "\t" type_array["edit"] "\t" type_array["delete"]
}
'
}

View File

@ -46,14 +46,19 @@ The time/date is printed by the `date` command, so refer to its man page to chan
The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* ruby
* scm
* user_info
* `battery` - Battery information (you'll need to enable the `battery` plugin)
* `clock` - Current time in `HH:MM:SS` format
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
* `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim
* `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported)
* `ruby` - Current ruby version if using `rvm`
* `scm` - Version control information, `git`
* `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in.
Two variables can be defined to set the order of the prompt segments:

View File

@ -46,11 +46,13 @@ function __powerline_prompt_command {
## right prompt ##
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
LEFT_PROMPT+="${move_cursor_rightmost}"
# LEFT_PROMPT+="${move_cursor_rightmost}"
for segment in $POWERLINE_RIGHT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_right_segment "${info}"
done
RIGHT_PAD=$(printf "%.s " $(seq 1 $RIGHT_PROMPT_LENGTH))
LEFT_PROMPT+="${RIGHT_PAD}${move_cursor_rightmost}"
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D"
fi

View File

@ -51,6 +51,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
HOST_THEME_PROMPT_COLOR=0
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"}
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}

View File

@ -42,16 +42,21 @@ The time/date is printed by the `date` command, so refer to its man page to chan
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* ruby
* scm
* user_info
* `battery` - Battery information (you'll need to enable the `battery` plugin)
* `clock` - Current time in `HH:MM:SS` format
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
* `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim
* `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported)
* `ruby` - Current ruby version if using `rvm`
* `scm` - Version control information, `git`
* `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in.
A variables can be defined to set the order of the prompt segments:
A variable can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"

View File

@ -4,7 +4,7 @@ function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char=""
local separator_char="${POWERLINE_LEFT_SEPARATOR}"
local separator=""
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then

View File

@ -1,9 +1,10 @@
#!/usr/bin/env bash
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
. "$BASH_IT/themes/powerline-naked/powerline-naked.base.bash"
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=240
@ -47,6 +48,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
HOST_THEME_PROMPT_COLOR=254
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
safe_append_prompt_command __powerline_prompt_command

View File

@ -40,16 +40,21 @@ The time/date is printed by the `date` command, so refer to its man page to chan
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* ruby
* scm
* user_info
* `battery` - Battery information (you'll need to enable the `battery` plugin)
* `clock` - Current time in `HH:MM:SS` format
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
* `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim
* `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported)
* `ruby` - Current ruby version if using `rvm`
* `scm` - Version control information, `git`
* `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in.
A variables can be defined to set the order of the prompt segments:
A variable can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"

View File

@ -25,7 +25,7 @@ RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:=" "}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "}
CWD_THEME_PROMPT_COLOR=240
@ -43,6 +43,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
HOST_THEME_PROMPT_COLOR=0
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
safe_append_prompt_command __powerline_prompt_command

View File

@ -44,16 +44,21 @@ The time/date is printed by the `date` command, so refer to its man page to chan
The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
* battery
* clock
* cwd
* in_vim
* python_venv
* ruby
* scm
* user_info
* `battery` - Battery information (you'll need to enable the `battery` plugin)
* `clock` - Current time in `HH:MM:SS` format
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
* `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim
* `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported)
* `ruby` - Current ruby version if using `rvm`
* `scm` - Version control information, `git`
* `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in.
A variables can be defined to set the order of the prompt segments:
A variable can be defined to set the order of the prompt segments:
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"

View File

@ -84,6 +84,8 @@ function __powerline_scm_prompt {
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}"
fi

View File

@ -46,6 +46,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
HOST_THEME_PROMPT_COLOR=0
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"}
safe_append_prompt_command __powerline_prompt_command

View File

@ -0,0 +1,185 @@
#!/usr/bin/env bash
# Power-Turk theme for bash-it
# Author (C) 2015 Ahmed Seref Guneysu
THEME_PROMPT_SEPARATOR=""
SHELL_SSH_CHAR=" "
SHELL_THEME_PROMPT_COLOR=2
SHELL_SSH_THEME_PROMPT_COLOR=208
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=" " # " "
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_COLOR=16
SCM_THEME_PROMPT_CLEAN_COLOR=231
SCM_THEME_PROMPT_DIRTY_COLOR=196
SCM_THEME_PROMPT_STAGED_COLOR=220
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52
_collapsed_wd() {
# echo -e "\u2771\u276d\u276f"
echo $(pwd | perl -pe "
BEGIN {
binmode STDIN, ':encoding(UTF-8)';
binmode STDOUT, ':encoding(UTF-8)';
}; s|^$HOME|<HOME>|g; s|/([^/])[^/]*(?=/)|/\$1|g") | \
sed -re "s/\//  /g"
}
_swd(){
# Adapted from http://stackoverflow.com/a/2951707/1766716
begin="" # The unshortened beginning of the path.
shortbegin="" # The shortened beginning of the path.
current="" # The section of the path we're currently working on.
end="${2:-$(pwd)}/" # The unmodified rest of the path.
if [[ "$end" =~ "$HOME" ]]; then
INHOME=1
end="${end#$HOME}" #strip /home/username from start of string
begin="$HOME" #start expansion from the right spot
else
INHOME=0
fi
end="${end#/}" # Strip the first /
shortenedpath="$end" # The whole path, to check the length.
maxlength="${1:-0}"
shopt -q nullglob && NGV="-s" || NGV="-u" # Store the value for later.
shopt -s nullglob # Without this, anything that doesn't exist in the filesystem turns into */*/*/...
while [[ "$end" ]] && (( ${#shortenedpath} > maxlength ))
do
current="${end%%/*}" # everything before the first /
end="${end#*/}" # everything after the first /
shortcur="$current"
shortcurstar="$current" # No star if we don't shorten it.
for ((i=${#current}-2; i>=0; i--)); do
subcurrent="${current:0:i}"
matching=("$begin/$subcurrent"*) # Array of all files that start with $subcurrent.
(( ${#matching[*]} != 1 )) && break # Stop shortening if more than one file matches.
shortcur="$subcurrent"
shortcurstar="$subcurrent*"
done
#advance
begin="$begin/$current"
shortbegin="$shortbegin/$shortcurstar"
shortenedpath="$shortbegin/$end"
done
shortenedpath="${shortenedpath%/}" # strip trailing /
shortenedpath="${shortenedpath#/}" # strip leading /
# Replaces slashes with  except first occurence.
if [ $INHOME -eq 1 ]; then
echo "~/$shortenedpath" | sed "s/\///2g" # make sure it starts with ~/
else
echo "/$shortenedpath" | sed "s/\///2g" # Make sure it starts with /
fi
shopt "$NGV" nullglob # Reset nullglob in case this is being used as a function.
}
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
function powerline_shell_prompt {
if [[ -n "${SSH_CLIENT}" ]]; then
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR}
else
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) ${normal}"
LAST_THEME_COLOR=${SHELL_THEME_PROMPT_COLOR}
fi
}
function powerline_virtualenv_prompt {
local environ=""
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
environ="conda: $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
environ=$(basename "$VIRTUAL_ENV")
fi
if [[ -n "$environ" ]]; then
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}"
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
else
VIRTUALENV_PROMPT=""
fi
}
function powerline_scm_prompt {
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
else
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}"
LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR}
else
SCM_PROMPT=""
fi
}
function powerline_cwd_prompt {
CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}$(set_rgb_color 0 ${CWD_THEME_PROMPT_COLOR}) $(_swd)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR}
}
function powerline_last_status_prompt {
if [[ "$1" -eq 0 ]]; then
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
else
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
fi
}
function powerline_prompt_command() {
local LAST_STATUS="$?"
powerline_shell_prompt
powerline_virtualenv_prompt
powerline_scm_prompt
powerline_cwd_prompt
powerline_last_status_prompt LAST_STATUS
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
}
PROMPT_COMMAND=powerline_prompt_command

View File

@ -57,7 +57,12 @@ chroot(){
# show virtualenvwrapper
my_ve(){
if [ -n "$VIRTUAL_ENV" ]
if [ -n "$CONDA_DEFAULT_ENV" ]
then
my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}";
echo "($my_ps_ve)";
elif [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${bold_purple}$ve${normal}";
echo "($my_ps_ve)";

View File

@ -16,7 +16,7 @@ esac
BACKUP_FILE=$CONFIG_FILE.bak
if [ ! -e "$HOME/$BACKUP_FILE" ]; then
echo -e "\033[0;33mBackup file "$HOME/$BACKUP_FILE" not found.\033[0m" >&2
echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2
test -w "$HOME/$CONFIG_FILE" &&
mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" &&