commit
c8ea31d1aa
|
|
@ -0,0 +1,2 @@
|
|||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
46
README.md
46
README.md
|
|
@ -36,6 +36,17 @@ fi
|
|||
|
||||
Refer to the official [Bash documention](https://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files) to get more info.
|
||||
|
||||
|
||||
## Install using Docker
|
||||
|
||||
You can try Bash-it in an isolated enviroment 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`
|
||||
|
||||
Have a look at our [bash-it-docker respository](https://github.com/Bash-it/bash-it-docker) for further information.
|
||||
|
||||
|
||||
## Update
|
||||
|
||||
To update Bash-it, simply run:
|
||||
|
|
@ -129,17 +140,28 @@ For custom scripts, and aliases, just create the following files (they'll be ign
|
|||
|
||||
Anything in the custom directory will be ignored, with the exception of `custom/example.bash`.
|
||||
|
||||
Alternately, if you would like to keep your custom scripts under version control, you can set BASH_IT_CUSTOM in your `~/.bashrc` to another location outside of the `~/.bash_it` folder.
|
||||
Alternately, if you would like to keep your custom scripts under version control, you can set `BASH_IT_CUSTOM` in your `~/.bashrc` to another location outside of the `~/.bash_it` folder.
|
||||
|
||||
## Themes
|
||||
|
||||
There are a few Bash-it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request.
|
||||
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.
|
||||
|
||||
You can see the theme screenshots [here](https://github.com/Bash-it/bash-it/wiki/Themes).
|
||||
Examples:
|
||||
|
||||
Alternatively, you can preview the themes in your own shell using `BASH_PREVIEW=true reload`.
|
||||
```bash
|
||||
# Use the "powerline-multiline" theme
|
||||
export BASH_IT_THEME="powerline-multiline"
|
||||
|
||||
**NOTE**: Bash-it and some themes use UTF-8 characters, so to avoid extrange behaviors in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if isn't American English.
|
||||
# Use a theme outside of the Bash-it folder
|
||||
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`.
|
||||
|
||||
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).
|
||||
|
||||
**NOTE**: Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to `LC_ALL=en_US.UTF-8` or the equivalent to your language if isn't American English.
|
||||
|
||||
## Uninstalling
|
||||
|
||||
|
|
@ -200,6 +222,8 @@ Set `SCM_GIT_SHOW_DETAILS` to 'false' to **don't show** it:
|
|||
|
||||
* `export SCM_GIT_SHOW_DETAILS=false`
|
||||
|
||||
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_DETAILS` is ignored.
|
||||
|
||||
#### Remotes and remote branches
|
||||
|
||||
In some git workflows you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch.
|
||||
|
|
@ -218,6 +242,8 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**:
|
|||
|
||||
* `export SCM_GIT_SHOW_REMOTE_INFO=false`
|
||||
|
||||
**NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_REMOTE_INFO` is ignored.
|
||||
|
||||
#### Untracked files
|
||||
|
||||
By default, `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, can be useful to instruct Bash-it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`:
|
||||
|
|
@ -250,6 +276,16 @@ And
|
|||
|
||||
* `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.
|
||||
|
||||
#### Git show minimal status info
|
||||
|
||||
To speed up the prompt while still getting minimal git status information displayed such as the value of HEAD and whether there are any dirty objects, you can set:
|
||||
|
||||
```
|
||||
export SCM_GIT_SHOW_MINIMAL_INFO=true
|
||||
```
|
||||
|
||||
#### Ignore repo status
|
||||
|
||||
When working in repos with a large code base Bash-it can slow down your prompt when checking the repo status, to avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ alias dki='docker images' # List Docker images
|
|||
alias dkrmac='docker rm $(docker ps -a -q)' # Delete all Docker containers
|
||||
alias dkrmlc='docker-remove-most-recent-container' # Delete most recent (i.e., last) Docker container
|
||||
alias dkrmui='docker images -q -f dangling=true |xargs -r docker rmi' # Delete all untagged Docker images
|
||||
alias dkrmall='docker-remove-stale-assets' # Delete all untagged images and exited containers
|
||||
alias dkrmli='docker-remove-most-recent-image' # Delete most recent (i.e., last) Docker image
|
||||
alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if no IDs are passed as arguments
|
||||
alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
cite about-alias
|
||||
about-alias 'general aliases'
|
||||
|
||||
if ls --color -d . &> /dev/null
|
||||
then
|
||||
alias ls="ls --color=auto"
|
||||
elif ls -G -d . &> /dev/null
|
||||
then
|
||||
alias ls='ls -G' # Compact view, show colors
|
||||
fi
|
||||
|
||||
# List directory contents
|
||||
alias sl=ls
|
||||
alias ls='ls -G' # Compact view, show colors
|
||||
alias la='ls -AF' # Compact view, show hidden
|
||||
alias ll='ls -al'
|
||||
alias l='ls -a'
|
||||
|
|
@ -11,10 +18,15 @@ alias l1='ls -1'
|
|||
|
||||
alias _="sudo"
|
||||
|
||||
if [ $(uname) = "Linux" ]
|
||||
# colored grep
|
||||
# Need to check an existing file for a pattern that will be found to ensure
|
||||
# that the check works when on an OS that supports the color option
|
||||
if grep --color=auto "a" $BASH_IT/*.md &> /dev/null
|
||||
then
|
||||
alias ls="ls --color=auto"
|
||||
alias grep='grep --color=auto'
|
||||
export GREP_COLOR='1;33'
|
||||
fi
|
||||
|
||||
which gshuf &> /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
|
|
@ -59,6 +71,13 @@ fi
|
|||
alias md='mkdir -p'
|
||||
alias rd='rmdir'
|
||||
|
||||
# Common misspellings of bash-it
|
||||
alias shit='bash-it'
|
||||
alias batshit='bash-it'
|
||||
alias bashit='bash-it'
|
||||
alias bash_it='bash-it'
|
||||
alias bash_ti='bash-it'
|
||||
|
||||
# Display whatever file is regular file or folder
|
||||
catt() {
|
||||
for i in "$@"; do
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ about-alias 'common git abbreviations'
|
|||
# Aliases
|
||||
alias gcl='git clone'
|
||||
alias ga='git add'
|
||||
alias grm='git rm'
|
||||
alias gap='git add -p'
|
||||
alias gall='git add -A'
|
||||
alias gf='git fetch --all --prune'
|
||||
|
|
@ -32,6 +33,7 @@ alias gpom='git push origin master'
|
|||
alias gr='git remote'
|
||||
alias grv='git remote -v'
|
||||
alias gra='git remote add'
|
||||
alias gd='git diff'
|
||||
alias gdv='git diff -w "$@" | vim -R -'
|
||||
alias gc='git commit -v'
|
||||
alias gca='git commit -v -a'
|
||||
|
|
@ -40,6 +42,7 @@ alias gci='git commit --interactive'
|
|||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
alias gbt='git branch --track'
|
||||
alias gmv='git branch -m'
|
||||
alias gcount='git shortlog -sn'
|
||||
alias gcp='git cherry-pick'
|
||||
alias gco='git checkout'
|
||||
|
|
@ -65,6 +68,10 @@ alias gnew="git log HEAD@{1}..HEAD@{0}"
|
|||
# Add uncommitted and unstaged changes to the last commit
|
||||
alias gcaa="git commit -a --amend -C HEAD"
|
||||
alias ggui="git gui"
|
||||
alias gcam="git commit -am"
|
||||
alias gcsam="git commit -S -am"
|
||||
alias gstd="git stash drop"
|
||||
alias gstl="git stash list"
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
|
|
@ -74,19 +81,3 @@ case $OSTYPE in
|
|||
alias gtls='git tag -l | sort -V'
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$EDITOR" ]; then
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
alias gd='git diff | vim -R -'
|
||||
;;
|
||||
darwin*)
|
||||
alias gd='git diff | mate'
|
||||
;;
|
||||
*)
|
||||
alias gd='git diff'
|
||||
;;
|
||||
esac
|
||||
else
|
||||
alias gd="git diff | $EDITOR"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
cite 'about-alias'
|
||||
about-alias 'homebrew-cask abbreviations'
|
||||
|
||||
alias bcup='brew cask update'
|
||||
alias bcin='brew cask install'
|
||||
alias bcrm='brew cask uninstall'
|
||||
alias bczp='brew cask zap'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ alias nits='npm install-test --save'
|
|||
alias nitd='npm install-test --save-dev'
|
||||
alias nu='npm uninstall'
|
||||
alias nus='npm uninstall --save'
|
||||
alias nud='npm uninstall --save-dev'
|
||||
alias nusd='npm uninstall --save-dev'
|
||||
alias np='npm publish'
|
||||
alias nup='npm unpublish'
|
||||
alias nlk='npm link'
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ alias textedit='open -a TextEdit'
|
|||
alias hex='open -a "Hex Fiend"'
|
||||
alias skype='open -a Skype'
|
||||
alias mou='open -a Mou'
|
||||
alias subl='open -a Sublime\ Text --args'
|
||||
alias subl='open -a Sublime\ Text'
|
||||
|
||||
if [ -s /usr/bin/firefox ] ; then
|
||||
unalias firefox
|
||||
|
|
|
|||
|
|
@ -110,4 +110,10 @@ _bash-it-comp()
|
|||
return 0
|
||||
}
|
||||
|
||||
# Activate completion for bash-it and its common misspellings
|
||||
complete -F _bash-it-comp bash-it
|
||||
complete -F _bash-it-comp bash-ti
|
||||
complete -F _bash-it-comp shit
|
||||
complete -F _bash-it-comp bashit
|
||||
complete -F _bash-it-comp batshit
|
||||
complete -F _bash-it-comp bash_it
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_composer()
|
||||
{
|
||||
local cur script coms opts com
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur words
|
||||
|
||||
# for an alias, get the real script behind it
|
||||
if [[ $(type -t ${words[0]}) == "alias" ]]; then
|
||||
script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
|
||||
else
|
||||
script=${words[0]}
|
||||
fi
|
||||
|
||||
# lookup for command
|
||||
for word in ${words[@]:1}; do
|
||||
if [[ $word != -* ]]; then
|
||||
com=$word
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# completing for an option
|
||||
if [[ ${cur} == --* ]] ; then
|
||||
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
|
||||
|
||||
case "$com" in
|
||||
about)
|
||||
opts="${opts} "
|
||||
;;
|
||||
archive)
|
||||
opts="${opts} --format --dir --file"
|
||||
;;
|
||||
browse)
|
||||
opts="${opts} --homepage --show"
|
||||
;;
|
||||
clear-cache)
|
||||
opts="${opts} "
|
||||
;;
|
||||
config)
|
||||
opts="${opts} --global --editor --auth --unset --list --file --absolute"
|
||||
;;
|
||||
create-project)
|
||||
opts="${opts} --stability --prefer-source --prefer-dist --repository --repository-url --dev --no-dev --no-custom-installers --no-scripts --no-progress --no-secure-http --keep-vcs --no-install --ignore-platform-reqs"
|
||||
;;
|
||||
depends)
|
||||
opts="${opts} --recursive --tree"
|
||||
;;
|
||||
diagnose)
|
||||
opts="${opts} "
|
||||
;;
|
||||
dump-autoload)
|
||||
opts="${opts} --no-scripts --optimize --classmap-authoritative --apcu --no-dev"
|
||||
;;
|
||||
exec)
|
||||
opts="${opts} --list"
|
||||
;;
|
||||
global)
|
||||
opts="${opts} "
|
||||
;;
|
||||
help)
|
||||
opts="${opts} --xml --format --raw"
|
||||
;;
|
||||
init)
|
||||
opts="${opts} --name --description --author --type --homepage --require --require-dev --stability --license --repository"
|
||||
;;
|
||||
install)
|
||||
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs"
|
||||
;;
|
||||
licenses)
|
||||
opts="${opts} --format --no-dev"
|
||||
;;
|
||||
list)
|
||||
opts="${opts} --xml --raw --format"
|
||||
;;
|
||||
outdated)
|
||||
opts="${opts} --outdated --all --direct --strict"
|
||||
;;
|
||||
prohibits)
|
||||
opts="${opts} --recursive --tree"
|
||||
;;
|
||||
remove)
|
||||
opts="${opts} --dev --no-progress --no-update --no-scripts --update-no-dev --update-with-dependencies --no-update-with-dependencies --ignore-platform-reqs --optimize-autoloader --classmap-authoritative --apcu-autoloader"
|
||||
;;
|
||||
require)
|
||||
opts="${opts} --dev --prefer-source --prefer-dist --no-progress --no-suggest --no-update --no-scripts --update-no-dev --update-with-dependencies --ignore-platform-reqs --prefer-stable --prefer-lowest --sort-packages --optimize-autoloader --classmap-authoritative --apcu-autoloader"
|
||||
;;
|
||||
run-script)
|
||||
opts="${opts} --timeout --dev --no-dev --list"
|
||||
;;
|
||||
search)
|
||||
opts="${opts} --only-name --type"
|
||||
;;
|
||||
self-update)
|
||||
opts="${opts} --rollback --clean-backups --no-progress --update-keys --stable --preview --snapshot"
|
||||
;;
|
||||
show)
|
||||
opts="${opts} --all --installed --platform --available --self --name-only --path --tree --latest --outdated --minor-only --direct --strict"
|
||||
;;
|
||||
status)
|
||||
opts="${opts} "
|
||||
;;
|
||||
suggests)
|
||||
opts="${opts} --by-package --by-suggestion --no-dev"
|
||||
;;
|
||||
update)
|
||||
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --lock --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --with-dependencies --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs --prefer-stable --prefer-lowest --interactive --root-reqs"
|
||||
;;
|
||||
validate)
|
||||
opts="${opts} --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
__ltrim_colon_completions "$cur"
|
||||
|
||||
return 0;
|
||||
fi
|
||||
|
||||
# completing for a command
|
||||
if [[ $cur == $com ]]; then
|
||||
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
|
||||
|
||||
COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
|
||||
__ltrim_colon_completions "$cur"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F _composer composer
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Add completion for Makefile
|
||||
# see http://stackoverflow.com/a/38415982/1472048
|
||||
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
# pip bash completion start
|
||||
_pip_completion()
|
||||
{
|
||||
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
|
||||
COMP_CWORD=$COMP_CWORD \
|
||||
PIP_AUTO_COMPLETE=1 $1 ) )
|
||||
}
|
||||
complete -o default -F _pip_completion pip3
|
||||
# pip bash completion end
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Bash completion support for RVM.
|
||||
# Source: https://rvm.io/workflow/completion
|
||||
|
||||
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
|
||||
|
|
@ -1,34 +1,49 @@
|
|||
# Credit https://github.com/iljaweis/vault-bash-completion/
|
||||
# ---------------------------------------------------------------------------
|
||||
# vault-bash-completion
|
||||
#
|
||||
# This adds bash completions for [HashiCorp Vault](https://www.vaultproject.io/)
|
||||
#
|
||||
# see https://github.com/iljaweis/vault-bash-completion
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
function _vault_mounts() {
|
||||
(
|
||||
set -euo pipefail
|
||||
if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then
|
||||
echo "secret"
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
function _vault() {
|
||||
local VAULT_COMMANDS=$(vault 2>&1 | egrep '^ +' | awk '{print $1}')
|
||||
|
||||
local VAULT_COMMANDS='delete path-help read renew revoke server status write audit-disable audit-enable audit-list auth auth-disable auth-enable capabilities generate-root init key-status list mount mount-tune mounts policies policy-delete policy-write rekey remount rotate seal ssh step-down token-create token-lookup token-renew token-revoke unmount unseal version'
|
||||
local cur
|
||||
local prev
|
||||
|
||||
# get root paths
|
||||
vault mounts >/dev/null 2>&1
|
||||
if [ $? != 0 ]; then
|
||||
# we do not have access to list mounts
|
||||
local VAULT_ROOTPATH="secret"
|
||||
else
|
||||
local VAULT_ROOTPATH=$(vault mounts | tail -n +2 | awk '{print $1}' | paste -s -d ' ' -)
|
||||
if [ $COMP_CWORD -gt 0 ]; then
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
fi
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
local line=${COMP_LINE}
|
||||
|
||||
if [ "$(echo $line | wc -w)" -le 2 ]; then
|
||||
if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then
|
||||
local policies=$(vault policies 2> /dev/null)
|
||||
COMPREPLY=($(compgen -W "$policies" -- $cur))
|
||||
elif [ "$(echo $line | wc -w)" -le 2 ]; then
|
||||
if [[ "$line" =~ ^vault\ (read|write|delete|list)\ $ ]]; then
|
||||
COMPREPLY=($(compgen -W "$VAULT_ROOTPATH" -- ''))
|
||||
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- ''))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$VAULT_COMMANDS" -- $cur))
|
||||
fi
|
||||
elif [[ "$line" =~ ^vault\ (read|write|delete|list)\ (.*)$ ]]; then
|
||||
path=${BASH_REMATCH[2]}
|
||||
if [[ "$path" =~ ^([^ ]+)/([^ /]*)$ ]]; then
|
||||
list=$(vault list ${BASH_REMATCH[1]} | tail -n +2)
|
||||
list=$(vault list -format=yaml ${BASH_REMATCH[1]} 2> /dev/null | awk '{ print $2 }')
|
||||
COMPREPLY=($(compgen -W "$list" -P "${BASH_REMATCH[1]}/" -- ${BASH_REMATCH[2]}))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$VAULT_ROOTPATH" -- $path))
|
||||
COMPREPLY=($(compgen -W "$(_vault_mounts)" -- $path))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# colored grep
|
||||
alias grep='grep --color=auto'
|
||||
export GREP_COLOR='1;33'
|
||||
|
||||
# colored ls
|
||||
export LSCOLORS='Gxfxcxdxdxegedabagacad'
|
||||
|
||||
|
|
@ -13,7 +9,9 @@ fi
|
|||
|
||||
# Load the theme
|
||||
if [[ $BASH_IT_THEME ]]; then
|
||||
if [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
|
||||
if [[ -f $BASH_IT_THEME ]]; then
|
||||
source $BASH_IT_THEME
|
||||
elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
|
||||
source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
|
||||
else
|
||||
source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ _bash-it-search-component() {
|
|||
fi
|
||||
done
|
||||
|
||||
local _grep=$(which egrep || which grep)
|
||||
local _grep=$((which --skip-alias grep 2> /dev/null || which grep) | tail -n 1)
|
||||
|
||||
declare -a terms=($@) # passed on the command line
|
||||
declare -a matches=() # results that we found
|
||||
|
|
@ -98,7 +98,7 @@ _bash-it-search-component() {
|
|||
[[ "${term:0:1}" == "-" ]] && negative_terms=(${negative_terms[@]} ${term:1}) && continue
|
||||
|
||||
# print asterisk next to each result that is already enabled by the user
|
||||
local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | egrep '\[( |x)\]' | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' ))
|
||||
local term_match=($(echo "${help}"| ${_grep} -i -- ${term} | ${_grep} -E '\[( |x)\]' | cut -b -30 | sed 's/ *\[ \]//g;s/ *\[x\]/*/g;' ))
|
||||
[[ "${#term_match[@]}" -gt 0 ]] && {
|
||||
matches=(${matches[@]} ${term_match[@]}) # append to the list of results
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,20 @@ about-plugin 'Helpers to more easily work with Docker'
|
|||
function docker-remove-most-recent-container() {
|
||||
about 'attempt to remove the most recent container from docker ps -a'
|
||||
group 'docker'
|
||||
docker ps -a | head -2 | tail -1 | awk '{print $NF}' | xargs docker rm
|
||||
docker ps -ql | xargs docker rm
|
||||
}
|
||||
|
||||
function docker-remove-most-recent-image() {
|
||||
about 'attempt to remove the most recent image from docker images'
|
||||
group 'docker'
|
||||
docker images | head -2 | tail -1 | awk '{print $3}' | xargs docker rmi
|
||||
docker images -q | head -1 | xargs docker rmi
|
||||
}
|
||||
|
||||
function docker-remove-stale-assets() {
|
||||
about 'attempt to remove exited containers and dangling images'
|
||||
group 'docker'
|
||||
docker ps --filter status=exited -q | xargs docker rm --volumes
|
||||
docker images --filter dangling=true -q | xargs docker rmi
|
||||
}
|
||||
|
||||
function docker-enter() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
cite about-plugin
|
||||
about-plugin 'Enable emacs editing mode'
|
||||
|
||||
set -o emacs
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
cite about-plugin
|
||||
about-plugin 'Enable vi editing mode'
|
||||
|
||||
set -o vi
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
cite about-plugin
|
||||
about-plugin 'Add a gw command to use gradle wrapper if present, else use system gradle'
|
||||
|
||||
function gw() {
|
||||
local file="gradlew"
|
||||
local curr_path="${PWD}"
|
||||
local result="gradle"
|
||||
|
||||
# Search recursively upwards for file.
|
||||
until [[ "${curr_path}" == "/" ]]; do
|
||||
if [[ -e "${curr_path}/${file}" ]]; then
|
||||
result="${curr_path}/${file}"
|
||||
break
|
||||
else
|
||||
curr_path=$(dirname "${curr_path}")
|
||||
fi
|
||||
done
|
||||
|
||||
# Call gradle
|
||||
"${result}" $*
|
||||
}
|
||||
|
||||
|
|
@ -29,13 +29,14 @@ _replace_by_history() {
|
|||
if command -v percol>/dev/null; then
|
||||
local current_version=${BASH_VERSION%%[^0-9]*}
|
||||
if [ $current_version -lt 4 ]; then
|
||||
echo "Warning:You have to upgrade bash to bash 4.x to use percol plugin."
|
||||
echo -e "\033[91mWarning: You have to upgrade Bash to Bash v4.x to use the 'percol' plugin.\033[m"
|
||||
echo -e "\033[91m Your current Bash version is $BASH_VERSION.\033[m"
|
||||
else
|
||||
bind -x '"\C-r": _replace_by_history'
|
||||
|
||||
# bind zz to percol if fasd enable
|
||||
if command -v fasd>/dev/null; then
|
||||
zz(){
|
||||
function zz() {
|
||||
local l=$(fasd -d | awk '{print $2}' | percol)
|
||||
cd $l
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function pyedit() {
|
|||
example '$ pyedit requests'
|
||||
group 'python'
|
||||
|
||||
xpyc=`python -c "import sys; stdout = sys.stdout; sys.stdout = sys.stderr; import $1; stdout.write($1.__file__)"`
|
||||
xpyc=`python -c "import os, sys; f = open(os.devnull, 'w'); sys.stderr = f; module = __import__('$1'); sys.stdout.write(module.__file__)"`
|
||||
|
||||
if [ "$xpyc" == "" ]; then
|
||||
echo "Python module $1 not found"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export TODO="t"
|
|||
export SCM_CHECK=true
|
||||
|
||||
# Set Xterm/screen/Tmux title with only a short hostname.
|
||||
# Unomment this (or set SHORT_HOSTNAME to something else),
|
||||
# Uncomment this (or set SHORT_HOSTNAME to something else),
|
||||
# Will otherwise fall back on $HOSTNAME.
|
||||
#export SHORT_HOSTNAME=$(hostname -s)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
GIT_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
# Nicely formatted terminal prompt
|
||||
function prompt_command(){
|
||||
export PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
|
|
@ -20,6 +20,8 @@ SCM_THEME_BRANCH_TRACK_PREFIX=' → '
|
|||
SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ '
|
||||
SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '
|
||||
SCM_THEME_CURRENT_USER_SUFFIX=''
|
||||
SCM_THEME_CHAR_PREFIX=''
|
||||
SCM_THEME_CHAR_SUFFIX=''
|
||||
|
||||
THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true}
|
||||
|
||||
|
|
@ -27,6 +29,7 @@ SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true}
|
|||
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='git'
|
||||
SCM_GIT_CHAR='±'
|
||||
|
|
@ -91,11 +94,61 @@ function scm_prompt_vars {
|
|||
function scm_prompt_info {
|
||||
scm
|
||||
scm_prompt_char
|
||||
scm_prompt_info_common
|
||||
}
|
||||
|
||||
function scm_prompt_char_info {
|
||||
scm_prompt_char
|
||||
echo -ne "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
||||
scm_prompt_info_common
|
||||
}
|
||||
|
||||
function scm_prompt_info_common {
|
||||
SCM_DIRTY=0
|
||||
SCM_STATE=''
|
||||
[[ $SCM == $SCM_GIT ]] && git_prompt_info && return
|
||||
[[ $SCM == $SCM_HG ]] && hg_prompt_info && return
|
||||
[[ $SCM == $SCM_SVN ]] && svn_prompt_info && return
|
||||
|
||||
if [[ ${SCM} == ${SCM_GIT} ]]; then
|
||||
if [[ ${SCM_GIT_SHOW_MINIMAL_INFO} == true ]]; then
|
||||
# user requests minimal git status information
|
||||
git_prompt_minimal_info
|
||||
else
|
||||
# more detailed git status
|
||||
git_prompt_info
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
# TODO: consider adding minimal status information for hg and svn
|
||||
[[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return
|
||||
[[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return
|
||||
}
|
||||
|
||||
function git_prompt_minimal_info {
|
||||
local ref
|
||||
local status
|
||||
local git_status_flags=('--porcelain')
|
||||
SCM_STATE=${SCM_THEME_PROMPT_CLEAN}
|
||||
|
||||
if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then
|
||||
# Get the branch reference
|
||||
ref=$(command git symbolic-ref -q HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/}
|
||||
|
||||
# Get the status
|
||||
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no'
|
||||
status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1)
|
||||
|
||||
if [[ -n ${status} ]]; then
|
||||
SCM_DIRTY=1
|
||||
SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
|
||||
fi
|
||||
|
||||
# Output the git prompt
|
||||
SCM_PREFIX=${SCM_THEME_PROMPT_PREFIX}
|
||||
SCM_SUFFIX=${SCM_THEME_PROMPT_SUFFIX}
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_status_summary {
|
||||
|
|
@ -388,7 +441,7 @@ function hg_prompt_info() {
|
|||
|
||||
function scm_char {
|
||||
scm_prompt_char
|
||||
echo -e "$SCM_CHAR"
|
||||
echo -e "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
||||
}
|
||||
|
||||
function prompt_char {
|
||||
|
|
@ -423,11 +476,22 @@ function aws_profile {
|
|||
}
|
||||
|
||||
function safe_append_prompt_command {
|
||||
if [[ -n $1 ]] ; then
|
||||
case $PROMPT_COMMAND in
|
||||
*$1*) ;;
|
||||
"") PROMPT_COMMAND="$1";;
|
||||
*) PROMPT_COMMAND="$1;$PROMPT_COMMAND";;
|
||||
esac
|
||||
local prompt_re
|
||||
|
||||
# Set OS dependent exact match regular expression
|
||||
if [[ ${OSTYPE} == darwin* ]]; then
|
||||
# macOS
|
||||
prompt_re="[[:<:]]${1}[[:>:]]"
|
||||
else
|
||||
# Linux, FreeBSD, etc.
|
||||
prompt_re="\<${1}\>"
|
||||
fi
|
||||
|
||||
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then
|
||||
return
|
||||
elif [[ -z ${PROMPT_COMMAND} ]]; then
|
||||
PROMPT_COMMAND="${1}"
|
||||
else
|
||||
PROMPT_COMMAND="${1};${PROMPT_COMMAND}"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
SCM_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
|
|
@ -23,7 +23,7 @@ __bobby_clock() {
|
|||
|
||||
function prompt_command() {
|
||||
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
|
||||
PS1="\n$(battery_char) $(__bobby_clock)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
PS1="\n$(battery_char) $(__bobby_clock)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_prompt_char_info) ${green}→${reset_color} "
|
||||
}
|
||||
|
||||
THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# One line prompt showing the following configurable information
|
||||
# for git:
|
||||
# time (virtual_env) username@hostname pwd git_char|git_branch git_dirty_status|→
|
||||
#
|
||||
# The → arrow shows the exit status of the last command:
|
||||
# - bold green: 0 exit status
|
||||
# - bold red: non-zero exit status
|
||||
#
|
||||
# Example outside git repo:
|
||||
# 07:45:05 user@host ~ →
|
||||
#
|
||||
# Example inside clean git repo:
|
||||
# 07:45:05 user@host .bash_it ±|master|→
|
||||
#
|
||||
# Example inside dirty git repo:
|
||||
# 07:45:05 user@host .bash_it ±|master ✗|→
|
||||
#
|
||||
# Example with virtual environment:
|
||||
# 07:45:05 (venv) user@host ~ →
|
||||
#
|
||||
|
||||
SCM_NONE_CHAR=''
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_PREFIX="${green}|"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
SCM_GIT_SHOW_MINIMAL_INFO=true
|
||||
|
||||
CLOCK_THEME_PROMPT_PREFIX=''
|
||||
CLOCK_THEME_PROMPT_SUFFIX=' '
|
||||
THEME_SHOW_CLOCK=true
|
||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_blue"}
|
||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
|
||||
|
||||
VIRTUALENV_THEME_PROMPT_PREFIX='('
|
||||
VIRTUALENV_THEME_PROMPT_SUFFIX=') '
|
||||
|
||||
function prompt_command() {
|
||||
# This needs to be first to save last command return code
|
||||
local RC="$?"
|
||||
|
||||
hostname="${bold_black}\u@\h"
|
||||
virtualenv="${white}$(virtualenv_prompt)"
|
||||
|
||||
# Set return status color
|
||||
if [[ ${RC} == 0 ]]; then
|
||||
ret_status="${bold_green}"
|
||||
else
|
||||
ret_status="${bold_red}"
|
||||
fi
|
||||
|
||||
# Append new history lines to history file
|
||||
history -a
|
||||
|
||||
PS1="$(clock_prompt)${virtualenv}${hostname} ${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}"
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
|
|
@ -4,6 +4,8 @@ A colorful theme, where shows a lot information about your shell session.
|
|||
|
||||
**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator.
|
||||
|
||||
**NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where `sudo` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your `~/.bashrc` or `~/.bash_profile` to disable the Powerline theme's `sudo` check. This will apply to all `powerline*` themes.
|
||||
|
||||
## Provided Information
|
||||
|
||||
* Current path
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
# Define this here so it can be used by all of the Powerline themes
|
||||
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true}
|
||||
|
||||
function set_color {
|
||||
set +u
|
||||
if [[ "${1}" != "-" ]]; then
|
||||
fg="38;5;${1}"
|
||||
fi
|
||||
|
|
@ -10,11 +14,14 @@ function set_color {
|
|||
}
|
||||
|
||||
function __powerline_user_info_prompt {
|
||||
set +u
|
||||
local user_info=""
|
||||
local color=${USER_INFO_THEME_PROMPT_COLOR}
|
||||
|
||||
if sudo -n uptime 2>&1 | grep -q "load"; then
|
||||
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
|
||||
if [[ "${THEME_CHECK_SUDO}" = true ]]; then
|
||||
if sudo -n uptime 2>&1 | grep -q "load"; then
|
||||
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
|
||||
fi
|
||||
fi
|
||||
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
|
||||
"sudo")
|
||||
|
|
@ -46,6 +53,7 @@ function __powerline_ruby_prompt {
|
|||
}
|
||||
|
||||
function __powerline_python_venv_prompt {
|
||||
set +u
|
||||
local python_venv=""
|
||||
|
||||
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in New Issue