Merge pull request #1 from Bash-it/master

Sync with original bash-it repo
pull/1285/head
con-f-use 2018-12-10 12:38:48 +01:00 committed by GitHub
commit 247b00fc36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 733 additions and 179 deletions

View File

@ -19,9 +19,13 @@ Most of this is common sense, but please try to stick to the conventions listed
Create a _Pull Request_ from your feature branch against Bash-it's _master_ branch.
* Limit each Pull Request to one feature.
Don't bundle multiple features/changes (e.g. a new _Theme_ and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix.
* For complex changes, try to _squash_ your changes into a single commit.
Don't create a PR consisting of 20 commits that show your work in progress.
Before you create the PR, _squash_ your changes into a single commit.
* For complex changes, try to _squash_ your changes into a single commit before
pushing code. Once you've pushed your code and opened a PR, please refrain
from force-pushing changes to the PR branch remember, Bash-it is a
distributed project and your branch may be in use already.
* When in doubt, open a PR with too many commits. Bash-it is a learning project
for everyone involved. Showing your work provides a great history for folks
to learn what works and what didn't.
## Code Style

View File

@ -59,10 +59,10 @@ When you run without the `--no-modify-config` switch, the Bash-it installer auto
Use the `--no-modify-config` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it.
**NOTE**: Keep in mind how Bash load its configuration files,
`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or
`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or
[iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators),
to ensure that Bash-it is loaded correctly.
A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios.
A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios.
To achieve this, you can add this snippet in your `.bash_profile`:
```
@ -76,8 +76,8 @@ Refer to the official [Bash documentation](https://www.gnu.org/software/bash/man
### Install using Docker
You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container.
(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)).
You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container.
(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)).
`docker pull ellerbrock/bash-it`
@ -140,7 +140,7 @@ Currently enabled modules will be shown in green.
### Searching with Negations
You can prefix a search term with a "-" to exclude it from the results.
You can prefix a search term with a "-" to exclude it from the results.
In the above example, if we wanted to hide `chruby` and `chruby-auto`,
we could change the command as follows:
@ -189,6 +189,7 @@ There are over 50+ Bash-it themes to pick from in `$BASH_IT/themes`.
The default theme is `bobby`.
Set `BASH_IT_THEME` to the theme name you want, or if you've developed your own custom theme outside of `$BASH_IT/themes`,
point the `BASH_IT_THEME` variable directly to the theme file.
To disable theming completely, leave the variable empty.
Examples:
@ -198,6 +199,9 @@ export BASH_IT_THEME="powerline-multiline"
# Use a theme outside of the Bash-it folder
export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash"
# Disable theming
export BASH_IT_THEME=""
```
You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`.
@ -294,8 +298,8 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**:
### Untracked files
By default, the `git status` command shows information about *untracked* files.
This behavior can be controlled through command-line flags or git configuration files.
By default, the `git status` command shows information about *untracked* files.
This behavior can be controlled through command-line flags or git configuration files.
For big repositories, ignoring *untracked* files can make git faster.
Bash-it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files.
You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`:
@ -312,6 +316,19 @@ Also, with this flag to false, Bash-it will not show the repository as dirty whe
**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always.
### Stash item count
When `SCM_GIT_SHOW_DETAILS` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items.
This feature is controlled through the flag `SCM_GIT_SHOW_STASH_INFO` as follows:
Set `SCM_GIT_SHOW_STASH_INFO` to 'true' (the default value) to **show** the count of stashed items:
* `export SCM_GIT_SHOW_STASH_INFO=true`
Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it:
* `export SCM_GIT_SHOW_STASH_INFO=false`
### Git user
In some environments, it is useful to know the value of the current git user, which is used to mark all new commits.
@ -333,7 +350,7 @@ You can control the prefix and the suffix of this component using the two variab
And
* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '`
* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '`
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_CURRENT_USER` is ignored.

View File

@ -0,0 +1,8 @@
cite 'about-alias'
about-alias 'puppet bolt aliases'
# Aliases
alias bolt='bolt command run --tty --no-host-key-check'
alias boltas='bolt -p -u'
alias sudobolt='bolt --run-as root --sudo-password'
alias sudoboltas='sudobolt -p -u'

View File

@ -0,0 +1,39 @@
cite 'about-alias'
about-alias 'common composer abbreviations'
# Aliases
alias coab='composer about'
alias coar='composer archive'
alias cob='composer browser'
alias cocpr='composer check-platform-reqs'
alias cocc='composer clear-cache'
alias cocfg='composer config'
alias cocp='composer create-project'
alias codp='composer depends'
alias codiag='composer diagnose'
alias codmp='composer dump-autoload'
alias coex='composer exec'
alias coglob='composer global'
alias coh='composer help'
alias cohome='composer home'
alias coi='composer install'
alias coinf='composer info'
alias coini='composer init'
alias coli='composer license'
alias colis='composer list'
alias coout='composer outdated'
alias cop='composer prohibits'
alias corem='composer remove'
alias coreq='composer require'
alias coreqd='composer require --dev'
alias cors='composer run-script'
alias cos='composer search'
alias cosu='composer self-update'
alias coshow='composer show'
alias costat='composer status'
alias cosugg='composer suggest'
alias coup='composer update'
alias coupg='composer upgrade'
alias coval='composer validate'
alias cowhy='composer why'
alias cowhyn='composer why-not'

View File

@ -4,3 +4,4 @@ about-alias 'docker-compose abbreviations'
alias dco="docker-compose"
alias dcofresh="docker-compose-fresh"
alias dcol="docker-compose logs -f --tail 100"
alias dcou="docker-compose up"

View File

@ -1,6 +1,7 @@
cite 'about-alias'
about-alias 'docker abbreviations'
alias dk='docker'
alias dklc='docker ps -l' # List last Docker container
alias dklcid='docker ps -l -q' # List last Docker container ID
alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # Get IP of last Docker container
@ -25,3 +26,11 @@ alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if n
alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz
alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID
alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above)
alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host
alias dkri='docker run --rm -i '
alias dkrit='docker run --rm -it '
# Added more recent cleanup options from newer docker versions
alias dkip='docker image prune -a -f'
alias dkvp='docker volume prune -f'
alias dksp='docker system prune -a -f'

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

@ -3,7 +3,7 @@ about-alias 'phoenix abbreviations'
# Phoenix Commands
alias i='iex'
alias ips='iex -S mix phoenix.server'
alias ips='iex -S mix phx.server'
alias ism='iex -S mix'
alias m='mix'
alias mab='mix archive.build'
@ -32,14 +32,14 @@ alias mho='mix hex.outdated'
alias mlh='mix local.hex'
alias mn='mix new'
alias mns='mix new --sup'
alias mpgc='mix phoenix.gen.channel'
alias mpgh='mix phoenix.gen.html'
alias mpgj='mix phoenix.gen.json'
alias mpgm='mix phoenix.gen.model'
alias mpgs='mix phoenix.gen.secret'
alias mpn='mix phoenix.new'
alias mpr='mix phoenix.routes'
alias mps='mix phoenix.server'
alias mpgc='mix phx.gen.channel'
alias mpgh='mix phx.gen.html'
alias mpgj='mix phx.gen.json'
alias mpgm='mix phx.gen.model'
alias mpgs='mix phx.gen.secret'
alias mpn='mix phx.new'
alias mpr='mix phx.routes'
alias mps='mix phx.server'
alias mr='mix run'
alias mrnh='mix run --no-halt'
alias mrl='mix release'

View File

@ -0,0 +1,10 @@
cite 'about-alias'
about-alias 'puppet aliases'
# Aliases
alias pupval="puppet parser validate *.pp"
alias puplint="puppet-lint *.pp"
alias pupagt="puppet agent -t"
alias pupagtd="puppet agent -t --debug"
alias pupapp="puppet apply"

View File

@ -29,36 +29,42 @@ cite _about _param _example _group _author _version
# libraries, but skip appearance (themes) for now
LIB="${BASH_IT}/lib/*.bash"
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
for config_file in $LIB
for _bash_it_config_file in $LIB
do
if [ "$config_file" != "$APPEARANCE_LIB" ]; then
if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then
# shellcheck disable=SC1090
source "$config_file"
source "$_bash_it_config_file"
fi
done
# Load the global "enabled" directory
_load_global_bash_it_files
# "family" param is empty so that files get sources in glob order
# shellcheck source=./scripts/reloader.bash
source "${BASH_IT}/scripts/reloader.bash"
# Load enabled aliases, completion, plugins
for file_type in "aliases" "plugins" "completion"
do
_load_bash_it_files $file_type
# shellcheck source=./scripts/reloader.bash
source "${BASH_IT}/scripts/reloader.bash" "skip" "$file_type"
done
# Load colors and helpers first so they can be used in base theme
# shellcheck source=./themes/colors.theme.bash
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"
# Load theme, if a theme was set
if [[ ! -z "${BASH_IT_THEME}" ]]; then
# Load colors and helpers first so they can be used in base theme
# shellcheck source=./themes/colors.theme.bash
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"
# appearance (themes) now, after all dependencies
# shellcheck source=./lib/appearance.bash
source "$APPEARANCE_LIB"
fi
# Load custom aliases, completion, plugins
for file_type in "aliases" "completion" "plugins"
@ -72,15 +78,15 @@ done
# Custom
CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash"
for config_file in $CUSTOM
for _bash_it_config_file in $CUSTOM
do
if [ -e "${config_file}" ]; then
if [ -e "${_bash_it_config_file}" ]; then
# shellcheck disable=SC1090
source "$config_file"
source "$_bash_it_config_file"
fi
done
unset config_file
unset _bash_it_config_file
if [[ $PROMPT ]]; then
export PS1="\[""$PROMPT""\]"
fi

View File

@ -21,6 +21,9 @@ __bundle() {
if [[ -z $bundle_command ]]; then
options="$options --version --help"
fi
elif [[ $bundle_command = "exec" ]]; then
_bundle_exec_completions
return
else
if [[ -z $bundle_command || $bundle_command = help ]]; then
options="help install update package exec config check list show
@ -53,3 +56,10 @@ __bundle_get_command() {
complete -F __bundle -o bashdefault -o default bundle
# vim: ai ft=sh sw=4 sts=2 et
_bundle_exec_completions()
{
if [[ $COMP_CWORD = 2 ]]; then
COMPREPLY=($(compgen -c -- "$2"))
fi
}

View File

@ -0,0 +1,11 @@
if which crystal >/dev/null 2>&1; then
if which brew >/dev/null 2>&1; then
BREW_PREFIX=$(brew --prefix)
if [ -f "$BREW_PREFIX"/etc/bash_completion.d/crystal ]; then
. "$BREW_PREFIX"/etc/bash_completion.d/crystal
fi
fi
fi

View File

@ -0,0 +1,207 @@
#!/usr/bin/env bash
##############
### CONFIG ###
##############
### feel free to change those constants
# the dir where to store the cache (must be writable and readable by the current user)
# must be an absolute path
_KNIFE_AUTOCOMPLETE_CACHE_DIR="$HOME/.knife_autocomplete_cache"
# the maximum # of _seconds_ after which a cache will be considered stale
# (a cache is refreshed whenever it is used! this is only for caches that might not have been used for a long time)
# WARNING: keep that value > 100
_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE=86400
###############################################
### END OF CONFIG - DON'T CHANGE CODE BELOW ###
###############################################
### init
_KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp"
# make sure the cache dir exists
mkdir -p $_KAC_CACHE_TMP_DIR
##############################
### Cache helper functions ###
##############################
# GNU or BSD stat?
stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_STAT_COMMAND="stat -f %m"
# returns 0 iff the file whose path is given as 1st argument
# exists and has last been modified in the last $2 seconds
# returns 1 otherwise
_KAC_is_file_newer_than()
{
[ -f "$1" ] || return 1
[ $(( $(date +%s) - $($_KAC_STAT_COMMAND "$1") )) -gt $2 ] && return 1 || return 0
}
# helper function for _KAC_get_and_regen_cache, see doc below
_KAC_regen_cache()
{
local CACHE_NAME=$1
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
shift 1
"$@" > $TMP_FILE 2> /dev/null
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
[[ $? != 0 ]] && [[ $(cat $TMP_FILE | wc -l) == 0 ]] && rm -f $TMP_FILE && touch $CACHE_PATH && return 1 \
|| mv -f $TMP_FILE $CACHE_PATH
}
# cached files can't have spaces in their names
_KAC_get_cache_name_from_command()
{
echo "$@" | sed 's/ /_SPACE_/g'
}
# the reverse operation from the function above
_KAC_get_command_from_cache_name()
{
echo "$@" | sed 's/_SPACE_/ /g'
}
# given a command as argument, it fetches the cache for that command if it can find it
# otherwise it waits for the cache to be generated
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
_KAC_get_and_regen_cache()
{
# the cache name can't have space in it
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $@"
_KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
# no need to wait for the regen if the file already exists
[ -f $_KAC_CACHE_PATH ] && ($REGEN_CMD &) || $REGEN_CMD
}
# performs two things: first, deletes all obsolete temp files
# then refreshes stale caches that haven't been called in a long time
_KAC_clean_cache()
{
local FILE CMD
# delete all obsolete temp files, could be lingering there for any kind of crash in the caching process
for FILE in $(ls $_KAC_CACHE_TMP_DIR)
do
_KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE || rm -f $FILE
done
# refresh really stale caches
for FILE in $(find $_KNIFE_AUTOCOMPLETE_CACHE_DIR -maxdepth 1 -type f -not -name '.*')
do
_KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE && continue
# first let's get the original command
CMD=$(_KAC_get_command_from_cache_name $(basename "$FILE"))
# then regen the cache
_KAC_get_and_regen_cache "$CMD" > /dev/null
done
}
# perform a cache cleaning when loading this file
_KAC_clean_cache
#####################################
### End of cache helper functions ###
#####################################
# returns all the possible knife sub-commands
_KAC_knife_commands()
{
knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
}
# rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND
# additionnally, returns 1 iff the current base command is not complete, 0 otherwise
# also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete
_KAC_get_current_base_command()
{
local PREVIOUS="knife"
local I=1
local CURRENT
while [ $I -le $COMP_CWORD ]
do
# command words are all lower-case
echo ${COMP_WORDS[$I]} | grep -E "^[a-z]+$" > /dev/null || break
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
cat $_KAC_CACHE_PATH | grep -E "^$CURRENT" > /dev/null || break
PREVIOUS=$CURRENT
I=$(( $I + 1))
done
_KAC_CURRENT_COMMAND=$PREVIOUS
[ $I -le $COMP_CWORD ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
}
# searches the position of the currently completed argument in the current base command
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
# assumes the current base command is complete
_KAC_get_current_arg_position()
{
local CURRENT_ARG_POS=$(( $_KAC_CURRENT_COMMAND_NB_WORDS + 1 ))
local COMPLETE_COMMAND=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND")
local CURRENT_ARG
while [ $CURRENT_ARG_POS -le $COMP_CWORD ]
do
CURRENT_ARG=$(echo $COMPLETE_COMMAND | cut -d ' ' -f $CURRENT_ARG_POS)
# we break if the current arg is a "plural" arg
echo $CURRENT_ARG | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break
CURRENT_ARG_POS=$(( $CURRENT_ARG_POS + 1 ))
done
echo $CURRENT_ARG_POS
}
# the actual auto-complete function
_knife()
{
_KAC_get_and_regen_cache _KAC_knife_commands
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
COMREPLY=()
# get correct command & arg pos
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$(( $COMP_CWORD + 1 ))
RAW_LIST=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND" | cut -d ' ' -f $ARG_POSITION | uniq)
# we need to process that raw list a bit, most notably for placeholders
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
# as opposed to a generic approach by trying to find a 'list' knife command corresponding to the
# current base command - that might limit my script in some situation, but that way I'm sure it caches only
# not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin)
LIST=""
for ITEM in $RAW_LIST
do
# always relevant if only lower-case chars : continuation of the base command
echo $ITEM | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue
case $ITEM in
*COOKBOOK*)
# special case for cookbooks : from site or local
[[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list"
_KAC_get_and_regen_cache $REGEN_CMD
LIST="$LIST $(cat $_KAC_CACHE_PATH | cut -d ' ' -f 1)"
continue
;;
*ITEM*)
# data bag item : another special case
local DATA_BAG_NAME=${COMP_WORDS[$(( COMP_CWORD-1 ))]}
REGEN_CMD="knife data bag show $DATA_BAG_NAME"
;;
*INDEX*)
# see doc @ http://docs.opscode.com/knife_search.html
LIST="$LIST client environment node role"
REGEN_CMD="knife data bag list"
;;
*BAG*) REGEN_CMD="knife data bag list";;
*CLIENT*) REGEN_CMD="knife client list";;
*NODE*) REGEN_CMD="knife node list";;
*ENVIRONMENT*) REGEN_CMD="knife environment list";;
*ROLE*) REGEN_CMD="knife role list";;
*USER*) REGEN_CMD="knife user list";;
# not a generic argument we support...
*) continue;;
esac
_KAC_get_and_regen_cache $REGEN_CMD
LIST="$LIST $(cat $_KAC_CACHE_PATH)"
done
COMPREPLY=( $(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
}
#complete -f -F _knife knife
complete -F _knife knife

View File

@ -0,0 +1,19 @@
#!/bin/bash
# Lerna autocompletion.
function _lerna_completions() {
local cur compls
# The currently-being-completed word.
cur="${COMP_WORDS[COMP_CWORD]}"
# Options
compls="add bootstrap changed clean create diff exec \
import init link list publish run version \
--loglevel --concurrency --reject-cycles \
--progress --sort --no-sort --help \
--version"
# Tell complete what stuff to show.
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
}
complete -o default -F _lerna_completions lerna

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

@ -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

@ -13,7 +13,7 @@ _sshcomplete() {
# parse all defined hosts from .ssh/config and files included there
for fl in "$HOME/.ssh/config" \
$(grep -P "^\s*Include" "$HOME/.ssh/config" |
$(grep "^\s*Include" "$HOME/.ssh/config" |
awk '{for (i=2; i<=NF; i++) print $i}' |
sed "s|^~/|$HOME/|")
do

View File

@ -20,8 +20,8 @@ if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then
. "$BREW_PREFIX"/etc/bash_completion
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
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
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

@ -14,54 +14,26 @@ function _command_exists ()
type "$1" &> /dev/null ;
}
# Helper function loading various enable-able files
function _load_bash_it_files() {
subdirectory="$1"
if [ -d "${BASH_IT}/${subdirectory}/enabled" ]
then
FILES="${BASH_IT}/${subdirectory}/enabled/*.bash"
for config_file in $FILES
do
if [ -e "${config_file}" ]; then
source $config_file
fi
done
fi
function _make_reload_alias() {
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
}
function _load_global_bash_it_files() {
# In the new structure
if [ -d "${BASH_IT}/enabled" ]
then
FILES="${BASH_IT}/enabled/*.bash"
for config_file in $FILES
do
if [ -e "${config_file}" ]; then
source $config_file
fi
done
fi
}
# Alias for reloading aliases
# shellcheck disable=SC2139
alias reload_aliases="$(_make_reload_alias alias aliases)"
# Function for reloading aliases
function reload_aliases() {
_load_bash_it_files "aliases"
}
# Alias for reloading auto-completion
# shellcheck disable=SC2139
alias reload_completion="$(_make_reload_alias completion completion)"
# Function for reloading auto-completion
function reload_completion() {
_load_bash_it_files "completion"
}
# Function for reloading plugins
function reload_plugins() {
_load_bash_it_files "plugins"
}
# Alias for reloading plugins
# shellcheck disable=SC2139
alias reload_plugins="$(_make_reload_alias plugin plugins)"
bash-it ()
{
about 'Bash-it help and maintenance'
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] '
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'
@ -79,28 +51,28 @@ bash-it ()
shift
typeset func
case $verb in
show)
func=_bash-it-$component;;
enable)
func=_enable-$component;;
disable)
func=_disable-$component;;
help)
func=_help-$component;;
search)
_bash-it-search $component "$@"
return;;
update)
func=_bash-it_update;;
migrate)
func=_bash-it-migrate;;
version)
func=_bash-it-version;;
reload)
func=_bash-it-reload;;
*)
reference bash-it
return;;
show)
func=_bash-it-$component;;
enable)
func=_enable-$component;;
disable)
func=_disable-$component;;
help)
func=_help-$component;;
search)
_bash-it-search $component "$@"
return;;
update)
func=_bash-it_update;;
migrate)
func=_bash-it-migrate;;
version)
func=_bash-it-version;;
reload)
func=_bash-it-reload;;
*)
reference bash-it
return;;
esac
# pluralize component if necessary
@ -167,6 +139,8 @@ _bash-it_update() {
_about 'updates Bash-it'
_group 'lib'
local old_pwd="${PWD}"
cd "${BASH_IT}" || return
if [ -z $BASH_IT_REMOTE ]; then
@ -179,22 +153,44 @@ _bash-it_update() {
status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)"
if [[ -n "${status}" ]]; then
git pull --rebase &> /dev/null
if [[ $? -eq 0 ]]; then
echo "Bash-it successfully updated."
echo ""
echo "Migrating your installation to the latest version now..."
_bash-it-migrate
echo ""
echo "All done, enjoy!"
reload
else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi
for i in $(git rev-list --merges --first-parent master..${BASH_IT_REMOTE}); do
num_of_lines=$(git log -1 --format=%B $i | awk 'NF' | wc -l)
if [ $num_of_lines -eq 1 ]; then
description="%s"
else
description="%b"
fi
git log --format="%h: $description (%an)" -1 $i
done
echo ""
read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP
case $RESP in
[yY]|"")
git pull --rebase &> /dev/null
if [[ $? -eq 0 ]]; then
echo "Bash-it successfully updated."
echo ""
echo "Migrating your installation to the latest version now..."
_bash-it-migrate
echo ""
echo "All done, enjoy!"
bash-it reload
else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi
;;
[nN])
echo "Not upgrading…"
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
else
echo "Bash-it is up to date, nothing to do!"
fi
cd - &> /dev/null || return
cd "${old_pwd}" &> /dev/null || return
}
_bash-it-migrate() {
@ -270,7 +266,7 @@ _bash-it-reload() {
source ~/.bashrc
;;
esac
cd - &> /dev/null || return
}

View File

@ -1,11 +1,14 @@
cite about-plugin
about-plugin 'AWS helper functions'
AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}"
function awskeys {
about 'helper function for AWS credentials file'
group 'aws'
if [[ ! -f ~/.aws/credentials ]]; then
if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]; then
echo "AWS credentials file not found"
return 1
fi
@ -35,14 +38,14 @@ function __awskeys_help {
}
function __awskeys_get {
local ln=$(grep -n "\[ *$1 *\]" ~/.aws/credentials | cut -d ":" -f 1)
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
if [[ -n "${ln}" ]]; then
tail -n +${ln} ~/.aws/credentials | egrep -m 2 "aws_access_key_id|aws_secret_access_key"
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token"
fi
}
function __awskeys_list {
local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials; grep "\[profile" ~/.aws/config | sed "s|\[profile |\[|g") | sort | uniq)"
local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)"
if [[ -n $"{credentials_list}" ]]; then
echo -e "Available credentials profiles:\n"
for profile in ${credentials_list}; do
@ -72,14 +75,14 @@ function __awskeys_export {
export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}"
done
fi
export AWS_DEFAULT_PROFILE="$1"
export AWS_PROFILE="$1"
else
echo "Profile $1 not found in credentials file"
fi
}
function __awskeys_unset {
unset AWS_DEFAULT_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
}
function __awskeys_comp {

View File

@ -4,7 +4,15 @@
cite about-plugin
about-plugin 'load fzf, if you are using it'
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
if [ -f ~/.fzf.bash ]; then
source ~/.fzf.bash
elif [ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ]; then
source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
fi
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"

24
plugins/available/go.plugin.bash 100644 → 100755
View File

@ -5,7 +5,25 @@ about-plugin 'go environment variables & path configuration'
[ ! command -v go &>/dev/null ] && return
export GOROOT=${GOROOT:-$(go env | grep GOROOT | cut -d'"' -f2)}
function _split_path_reverse() {
local a=( ${@//:/ } )
local i=${#a[@]}
local r=
while [ $i -gt 0 ] ; do
i=$(( i - 1 ))
if [ $(( i + 1 )) -eq ${#a[@]} ] ; then
r="${a[i]}"
else
r="${r} ${a[i]}"
fi
done
echo "$r"
}
export GOROOT=${GOROOT:-$(go env GOROOT)}
pathmunge "${GOROOT}/bin"
export GOPATH=${GOPATH:-"$HOME/go"}
pathmunge "${GOPATH}/bin"
export GOPATH=${GOPATH:-$(go env GOPATH)}
for p in $( _split_path_reverse ${GOPATH} ) ; do
pathmunge "${p}/bin"
done

View File

@ -4,6 +4,4 @@ about-plugin 'load jenv, if you are using it'
export JENV_ROOT="$HOME/.jenv"
pathmunge "$JENV_ROOT/bin"
if which jenv > /dev/null; then eval "$(jenv init -)"; fi
[[ -e $JENV_ROOT/completions/jenv.bash ]] && source $JENV_ROOT/completions/jenv.bash
if which jenv > /dev/null; then eval "$(jenv init - bash)"; fi

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

@ -4,7 +4,4 @@ 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
[[ `which nodenv` ]] && eval "$(nodenv init - 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

View File

@ -4,18 +4,15 @@ cite about-plugin
about-plugin 'plenv plugin for Perl'
if [[ -e "${HOME}/.plenv/bin" ]] ; then
# load plenv bin dir into path if it exists
pathmunge "${HOME}/.plenv/bin"
fi
if [[ `which plenv` ]] ; then
# init plenv
eval "$(plenv init -)"
# Load the auto-completion script if it exists.
[[ -e "${HOME}/.plenv/completions/plenv.bash" ]] && source "${HOME}/.plenv/completions/plenv.bash"
eval "$(plenv init - bash)"
fi

View File

@ -20,23 +20,23 @@ done
function postgres_start {
about 'Starts PostgresSQL server'
about 'Starts PostgreSQL server'
group 'postgres'
echo 'Starting PostgresSQL Server....';
echo 'Starting Postgres....';
$POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile start
}
function postgres_stop {
about 'Steps PostgresSQL server'
about 'Stops PostgreSQL server'
group 'postgres'
echo 'Stopping PostgresSQL Server....';
echo 'Stopping Postgres....';
$POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile stop -s -m fast
}
function postgres_status {
about 'Returns status of PostgresSQL server'
about 'Returns status of PostgreSQL server'
group 'postgres'
# $POSTGRES_BIN/pg_ctl -D $PGDATA status
@ -55,7 +55,7 @@ function is_postgres_running {
function postgres_restart {
about 'Restarts status of PostgresSQL server'
about 'Restarts status of PostgreSQL server'
group 'postgres'
echo 'Restarting Postgres....';

View File

@ -4,12 +4,9 @@ about-plugin 'load pyenv, if you are using it'
export PYENV_ROOT="$HOME/.pyenv"
pathmunge "$PYENV_ROOT/bin"
[[ `which pyenv` ]] && eval "$(pyenv init -)"
[[ `which pyenv` ]] && eval "$(pyenv init - bash)"
#Load pyenv virtualenv if the virtualenv plugin is installed.
if pyenv virtualenv-init - &> /dev/null; then
eval "$(pyenv virtualenv-init -)"
eval "$(pyenv virtualenv-init - bash)"
fi
# Load the auto-completion script if pyenv was loaded.
[[ -e $PYENV_ROOT/completions/pyenv.bash ]] && source $PYENV_ROOT/completions/pyenv.bash

View File

@ -1,9 +1,7 @@
# Load rbebv, if you are using it
cite about-plugin
about-plugin 'load rbenv, if you are using it'
pathmunge "$HOME"/.rbenv/bin
[ -x `which rbenv` ] && eval "$(rbenv init -)"
export RBENV_ROOT="$HOME/.rbenv"
pathmunge "$RBENV_ROOT/bin"
[ -d "$HOME"/.rbenv/plugins/ruby-build ] && pathmunge "$HOME"/.rbenv/plugins/ruby-build/bin
[[ `which rbenv` ]] && eval "$(rbenv init - bash)"

View File

@ -0,0 +1,36 @@
#!/bin/bash
pushd "${BASH_IT}" >/dev/null || exit 1
# TODO: Add debugging output
if [ "$1" != "skip" ] && [ -d "./enabled" ]; then
_bash_it_config_type=""
if [[ "${1}" =~ ^(alias|completion|plugin)$ ]]; then
_bash_it_config_type=$1
fi
for _bash_it_config_file in $(sort <(compgen -G "./enabled/*${_bash_it_config_type}.bash")); do
if [ -e "${_bash_it_config_file}" ]; then
# shellcheck source=/dev/null
source $_bash_it_config_file
else
echo "Unable to read ${_bash_it_config_file}" > /dev/stderr
fi
done
fi
if [ ! -z "${2}" ] && [[ "${2}" =~ ^(aliases|completion|plugins)$ ]] && [ -d "${2}/enabled" ]; then
# TODO: We should warn users they're using legacy enabling
for _bash_it_config_file in $(sort <(compgen -G "./${2}/enabled/*.bash")); do
if [ -e "$_bash_it_config_file" ]; then
# shellcheck source=/dev/null
source "$_bash_it_config_file"
else
echo "Unable to locate ${_bash_it_config_file}" > /dev/stderr
fi
done
fi
unset _bash_it_config_file
unset _bash_it_config_type
popd >/dev/null || exit 1

View File

@ -3,7 +3,8 @@
# Path to the bash it configuration
export BASH_IT="{{BASH_IT}}"
# Lock and Load a custom theme file
# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location /.bash_it/themes/
export BASH_IT_THEME='bobby'

View File

@ -0,0 +1,44 @@
#!/usr/bin/env bats
#load ../test_helper
load ../../lib/helpers
load ../../lib/composure
load ../../plugins/available/go.plugin
@test 'plugins go: reverse path: single entry' {
run _split_path_reverse '/foo'
echo "output = ${output}"
[ "$output" = "/foo" ]
}
@test 'plugins go: reverse path: single entry, colon empty' {
run _split_path_reverse '/foo:'
echo "output = ${output}"
[ "$output" = "/foo" ]
}
@test 'plugins go: reverse path: single entry, colon whitespace' {
run _split_path_reverse '/foo: '
echo "output = ${output}"
[ "$output" = "/foo" ]
}
@test 'plugins go: reverse path: multiple entries' {
run _split_path_reverse '/foo:/bar'
echo "output = ${output}"
[ "$output" = "/bar /foo" ]
}
@test 'plugins go: single entry in GOPATH' {
export GOPATH="/foo"
load ../../plugins/available/go.plugin
echo "$(echo $PATH | cut -d':' -f1,2)"
[ "$(echo $PATH | cut -d':' -f1)" = "/foo/bin" ]
}
@test 'plugins go: multiple entries in GOPATH' {
export GOPATH="/foo:/bar"
load ../../plugins/available/go.plugin
echo "$(echo $PATH | cut -d':' -f1,2)"
[ "$(echo $PATH | cut -d':' -f1,2)" = "/foo/bin:/bar/bin" ]
}

View File

@ -32,6 +32,7 @@ SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto}
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false}
SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false}
SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true}
SCM_GIT='git'
SCM_GIT_CHAR='±'
@ -138,9 +139,9 @@ 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
{ [[ ${SCM} == ${SCM_P4} ]] && p4_prompt_info && return; } || true
{ [[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return; } || true
{ [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true
}
function git_prompt_minimal_info {
@ -181,9 +182,11 @@ function git_prompt_vars {
[[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}"
[[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}"
local stash_count
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
local stash_count
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
fi
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
if ! _git-hide-status; then
@ -333,6 +336,10 @@ function ruby_version_prompt {
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
}
function k8s_context_prompt {
echo -e "$(kubectl config current-context)"
}
function virtualenv_prompt {
if [[ -n "$VIRTUAL_ENV" ]]; then
virtualenv=`basename "$VIRTUAL_ENV"`

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}\
@ -113,7 +112,7 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
else
PS1="${TITLEBAR}
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\

View File

@ -17,7 +17,7 @@ RVM_THEME_PROMPT_SUFFIX=" d|"
BOLD="\[\e[1m\]"
function prompt_command() {
PS1="\n${bold_cyan}$(scm_prompt_char_info) ${bold_cyan}\w :${reset_color}${normal}${BOLD} "
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

@ -72,7 +72,7 @@ function _git-hide-status {
function _git-status {
local git_status_flags=
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno'
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' || true
git status --porcelain ${git_status_flags} 2> /dev/null
}
@ -101,8 +101,9 @@ function _git-status-counts {
}
function _git-remote-info {
[[ "$(_git-upstream)" == "" ]] && return
[[ "$(_git-upstream)" == "" ]] && return || true
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true || 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 ]]) ||

View File

@ -46,6 +46,7 @@ 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:
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
* `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`)

View File

@ -20,6 +20,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
@ -35,6 +36,9 @@ RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=aws }"
AWS_PROFILE_PROMPT_COLOR=208
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=196

View File

@ -14,6 +14,7 @@ A colorful theme, where shows a lot information about your shell session.
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Kubernetes environment
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (rvm and rbenv are supported) in use
* Last command exit code (only shown when the exit code is greater than 0)
@ -42,16 +43,18 @@ 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:
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
* `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
* `k8s_context` - Show current kubernetes context
* `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`
* `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.

View File

@ -16,6 +16,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_COLOR=238
@ -32,6 +33,12 @@ RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=aws }"
AWS_PROFILE_PROMPT_COLOR=208
CWD_THEME_PROMPT_COLOR=254
LAST_STATUS_THEME_PROMPT_COLOR=124

View File

@ -12,6 +12,7 @@ A colorful theme, where shows a lot information about your shell session.
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Kubernetes environment
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (rvm and rbenv are supported) in use
* Last command exit code (only shown when the exit code is greater than 0)
@ -40,16 +41,18 @@ 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:
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
* `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
* `k8s_context` - Show current kubernetes context
* `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`
* `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.

View File

@ -12,6 +12,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
@ -27,6 +28,12 @@ RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=aws }"
AWS_PROFILE_PROMPT_COLOR=208
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52

View File

@ -16,6 +16,7 @@ A colorful theme, where shows a lot information about your shell session.
* An indicator when the current shell is inside the Vim editor
* Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin))
* SCM Repository status (e.g. Git, SVN)
* The current Kubernetes environment
* The current Python environment (Virtualenv, venv, and Conda are supported) in use
* The current Ruby environment (rvm and rbenv are supported) in use
* Last command exit code (only shown when the exit code is greater than 0)
@ -44,16 +45,18 @@ 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:
* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable
* `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
* `k8s_context` - Show current kubernetes context
* `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`
* `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.

View File

@ -52,6 +52,16 @@ function __powerline_ruby_prompt {
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
}
function __powerline_k8s_context_prompt {
local kubernetes_context=""
if _command_exists kubectl; then
kubernetes_context="$(k8s_context_prompt)"
fi
[[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}"
}
function __powerline_python_venv_prompt {
set +u
local python_venv=""
@ -86,6 +96,8 @@ function __powerline_scm_prompt {
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}"
fi
@ -134,6 +146,12 @@ function __powerline_in_vim_prompt {
fi
}
function __powerline_aws_profile_prompt {
if [[ -n "${AWS_PROFILE}" ]]; then
echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}"
fi
}
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )

View File

@ -15,6 +15,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=25
@ -30,6 +31,12 @@ RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26
AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=aws }"
AWS_PROFILE_PROMPT_COLOR=208
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52

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)";