add bash-it
This commit is contained in:
21
dot_bash_it/LICENSE
Normal file
21
dot_bash_it/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 Bash-it
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
dot_bash_it/aliases/available/ag.aliases.bash
Normal file
12
dot_bash_it/aliases/available/ag.aliases.bash
Normal file
@@ -0,0 +1,12 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'the silver searcher (ag) aliases'
|
||||
|
||||
## Summary for args to less:
|
||||
# less(1)
|
||||
# -M (-M or --LONG-PROMPT) Prompt very verbosely
|
||||
# -I (-I or --IGNORE-CASE) Searches with '/' ignore case
|
||||
# -R (-R or --RAW-CONTROL-CHARS) For handling ANSI colors
|
||||
# -F (-F or --quit-if-one-screen) Auto exit if <1 screen
|
||||
# -X (-X or --no-init) Disable termcap init & deinit
|
||||
|
||||
alias ag='ag --smart-case --pager="less -MIRFX"'
|
||||
5
dot_bash_it/aliases/available/ansible.aliases.bash
Normal file
5
dot_bash_it/aliases/available/ansible.aliases.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'ansible abbreviations'
|
||||
|
||||
alias ans=ansible
|
||||
alias ap=ansible-playbook
|
||||
27
dot_bash_it/aliases/available/apt.aliases.bash
Normal file
27
dot_bash_it/aliases/available/apt.aliases.bash
Normal file
@@ -0,0 +1,27 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# -binaryanomaly
|
||||
|
||||
cite 'about-alias'
|
||||
about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.'
|
||||
|
||||
# set apt aliases
|
||||
function _set_pkg_aliases() {
|
||||
if _command_exists apt; then
|
||||
alias apts='apt-cache search'
|
||||
alias aptshow='apt-cache show'
|
||||
alias aptinst='sudo apt-get install -V'
|
||||
alias aptupd='sudo apt-get update'
|
||||
alias aptupg='sudo apt-get dist-upgrade -V && sudo apt-get autoremove'
|
||||
alias aptupgd='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo apt-get autoremove'
|
||||
alias aptrm='sudo apt-get remove'
|
||||
alias aptpurge='sudo apt-get remove --purge'
|
||||
|
||||
alias chkup='/usr/lib/update-notifier/apt-check -p --human-readable'
|
||||
alias chkboot='cat /var/run/reboot-required'
|
||||
|
||||
alias pkgfiles='dpkg --listfiles'
|
||||
fi
|
||||
}
|
||||
|
||||
_set_pkg_aliases
|
||||
7
dot_bash_it/aliases/available/atom.aliases.bash
Normal file
7
dot_bash_it/aliases/available/atom.aliases.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Atom.io editor abbreviations'
|
||||
|
||||
alias a='atom'
|
||||
alias ah='atom .'
|
||||
alias apmup='apm update --no-confirm'
|
||||
alias apmi='apm install'
|
||||
23
dot_bash_it/aliases/available/bash-it.aliases.bash
Normal file
23
dot_bash_it/aliases/available/bash-it.aliases.bash
Normal file
@@ -0,0 +1,23 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Aliases for the bash-it command (these aliases are automatically included with the "general" aliases)'
|
||||
|
||||
# Common misspellings of bash-it
|
||||
alias shit='bash-it'
|
||||
alias batshit='bash-it'
|
||||
alias bashit='bash-it'
|
||||
alias batbsh='bash-it'
|
||||
alias babsh='bash-it'
|
||||
alias bash_it='bash-it'
|
||||
alias bash_ti='bash-it'
|
||||
|
||||
# Additional bash-it aliases for help/show
|
||||
alias bshsa='bash-it show aliases'
|
||||
alias bshsc='bash-it show completions'
|
||||
alias bshsp='bash-it show plugins'
|
||||
alias bshha='bash-it help aliases'
|
||||
alias bshhc='bash-it help completions'
|
||||
alias bshhp='bash-it help plugins'
|
||||
alias bshsch="bash-it search"
|
||||
alias bshenp="bash-it enable plugin"
|
||||
alias bshena="bash-it enable alias"
|
||||
alias bshenc="bash-it enable completion"
|
||||
8
dot_bash_it/aliases/available/bolt.aliases.bash
Normal file
8
dot_bash_it/aliases/available/bolt.aliases.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
# shellcheck shell=bash
|
||||
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'
|
||||
9
dot_bash_it/aliases/available/bundler.aliases.bash
Normal file
9
dot_bash_it/aliases/available/bundler.aliases.bash
Normal file
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'ruby bundler'
|
||||
|
||||
# Bundler Commands
|
||||
alias be='bundle exec'
|
||||
alias bi='bundle install'
|
||||
alias bl='bundle list'
|
||||
alias bu='bundle update'
|
||||
alias bp='bundle package'
|
||||
16
dot_bash_it/aliases/available/clipboard.aliases.bash
Normal file
16
dot_bash_it/aliases/available/clipboard.aliases.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'xclip shortcuts'
|
||||
|
||||
alias pbcopy="xclip -selection clipboard"
|
||||
alias pbpaste="xclip -selection clipboard -o"
|
||||
|
||||
alias xcpy="xclip -selection clipboard"
|
||||
alias xpst="xclip -selection clipboard -o"
|
||||
# to use it just install xclip on your distribution and it would work like:
|
||||
# $ echo "hello" | xcpy
|
||||
# $ xpst
|
||||
# hello
|
||||
|
||||
# very useful for things like:
|
||||
# cat ~/.ssh/id_rsa.pub | xcpy
|
||||
# have fun!
|
||||
39
dot_bash_it/aliases/available/composer.aliases.bash
Normal file
39
dot_bash_it/aliases/available/composer.aliases.bash
Normal file
@@ -0,0 +1,39 @@
|
||||
# shellcheck shell=bash
|
||||
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'
|
||||
22
dot_bash_it/aliases/available/curl.aliases.bash
Normal file
22
dot_bash_it/aliases/available/curl.aliases.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Curl aliases for convenience.'
|
||||
|
||||
# set apt aliases
|
||||
function _set_pkg_aliases() {
|
||||
if _command_exists curl; then
|
||||
# follow redirects
|
||||
alias cl='curl -L'
|
||||
# follow redirects, download as original name
|
||||
alias clo='curl -L -O'
|
||||
# follow redirects, download as original name, continue
|
||||
alias cloc='curl -L -C - -O'
|
||||
# follow redirects, download as original name, continue, retry 5 times
|
||||
alias clocr='curl -L -C - -O --retry 5'
|
||||
# follow redirects, fetch banner
|
||||
alias clb='curl -L -I'
|
||||
# see only response headers from a get request
|
||||
alias clhead='curl -D - -so /dev/null'
|
||||
fi
|
||||
}
|
||||
|
||||
_set_pkg_aliases
|
||||
17
dot_bash_it/aliases/available/dnf.aliases.bash
Normal file
17
dot_bash_it/aliases/available/dnf.aliases.bash
Normal file
@@ -0,0 +1,17 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'dnf aliases for fedora 22+ distros'
|
||||
|
||||
alias dnfl="dnf list" # List packages
|
||||
alias dnfli="dnf list installed" # List installed packages
|
||||
alias dnfgl="dnf grouplist" # List package groups
|
||||
alias dnfmc="dnf makecache" # Generate metadata cache
|
||||
alias dnfp="dnf info" # Show package information
|
||||
alias dnfs="dnf search" # Search package
|
||||
|
||||
alias dnfu="sudo dnf upgrade" # Upgrade package
|
||||
alias dnfi="sudo dnf install" # Install package
|
||||
alias dnfri='sudo dnf reinstall' # Reinstall package
|
||||
alias dnfgi="sudo dnf groupinstall" # Install package group
|
||||
alias dnfr="sudo dnf remove" # Remove package
|
||||
alias dnfgr="sudo dnf groupremove" # Remove package group
|
||||
alias dnfc="sudo dnf clean all" # Clean cache
|
||||
10
dot_bash_it/aliases/available/docker-compose.aliases.bash
Normal file
10
dot_bash_it/aliases/available/docker-compose.aliases.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'docker-compose abbreviations'
|
||||
|
||||
alias dco="docker-compose"
|
||||
|
||||
# Defined in the `docker-compose` plugin, please check there for details.
|
||||
alias dcofresh="docker-compose-fresh"
|
||||
alias dcol="docker-compose logs -f --tail 100"
|
||||
alias dcou="docker-compose up"
|
||||
alias dcouns="dcou --no-start"
|
||||
43
dot_bash_it/aliases/available/docker.aliases.bash
Normal file
43
dot_bash_it/aliases/available/docker.aliases.bash
Normal file
@@ -0,0 +1,43 @@
|
||||
# shellcheck shell=bash
|
||||
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
|
||||
alias dkps='docker ps' # List running Docker containers
|
||||
alias dkpsa='docker ps -a' # List all Docker containers
|
||||
alias dki='docker images' # List Docker images
|
||||
alias dkrmac='docker rm $(docker ps -a -q)' # Delete all Docker containers
|
||||
|
||||
case $OSTYPE in
|
||||
darwin* | *bsd* | *BSD*)
|
||||
alias dkrmui='docker images -q -f dangling=true | xargs docker rmi' # Delete all untagged Docker images
|
||||
;;
|
||||
*)
|
||||
alias dkrmui='docker images -q -f dangling=true | xargs -r docker rmi' # Delete all untagged Docker images
|
||||
;;
|
||||
esac
|
||||
|
||||
if _bash-it-component-item-is-enabled plugin docker; then
|
||||
# Function aliases from docker plugin:
|
||||
alias dkrmlc='docker-remove-most-recent-container' # Delete most recent (i.e., last) Docker container
|
||||
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
|
||||
alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID
|
||||
fi
|
||||
alias dkelc='docker exec -it $(dklcid) bash --login' # Enter last container (works with Docker 1.3 and above)
|
||||
alias dkrmflast='docker rm -f $(dklcid)'
|
||||
alias dkbash='dkelc'
|
||||
alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host
|
||||
alias dkri='docker run --rm -i '
|
||||
alias dkric='docker run --rm -i -v $PWD:/cwd -w /cwd '
|
||||
alias dkrit='docker run --rm -it '
|
||||
alias dkritc='docker run --rm -it -v $PWD:/cwd -w /cwd '
|
||||
|
||||
# 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'
|
||||
16
dot_bash_it/aliases/available/emacs.aliases.bash
Normal file
16
dot_bash_it/aliases/available/emacs.aliases.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'emacs editor'
|
||||
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
alias em='emacs'
|
||||
alias en='emacs -nw'
|
||||
alias e='emacsclient -n'
|
||||
alias et='emacsclient -t'
|
||||
alias ed='emacs --daemon'
|
||||
alias E='SUDO_EDITOR=emacsclient sudo -e'
|
||||
;;
|
||||
darwin*)
|
||||
alias em='open -a emacs'
|
||||
;;
|
||||
esac
|
||||
10
dot_bash_it/aliases/available/fuck.aliases.bash
Normal file
10
dot_bash_it/aliases/available/fuck.aliases.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'fuck/please to retry last command with sudo'
|
||||
|
||||
# Play nicely with 'thefuck' plugin
|
||||
if ! _command_exists fuck; then
|
||||
alias fuck='sudo $(fc -ln -1)'
|
||||
fi
|
||||
alias please=fuck
|
||||
alias plz=please
|
||||
alias fucking=sudo
|
||||
96
dot_bash_it/aliases/available/general.aliases.bash
Normal file
96
dot_bash_it/aliases/available/general.aliases.bash
Normal file
@@ -0,0 +1,96 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'general aliases'
|
||||
|
||||
if command ls --color -d . &> /dev/null; then
|
||||
alias ls='ls --color=auto'
|
||||
# BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set.
|
||||
fi
|
||||
|
||||
# List directory contents
|
||||
alias sl=ls
|
||||
alias la='ls -AF' # Compact view, show hidden
|
||||
alias ll='ls -al'
|
||||
alias l='ls -a'
|
||||
alias l1='ls -1'
|
||||
alias lf='ls -F'
|
||||
|
||||
alias _='sudo'
|
||||
|
||||
# Shortcuts to edit startup files
|
||||
alias vbrc='${VISUAL:-vim} ~/.bashrc'
|
||||
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
|
||||
|
||||
# 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 command grep --color=auto "a" "${BASH_IT?}"/*.md &> /dev/null; then
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
if _command_exists gshuf; then
|
||||
alias shuf=gshuf
|
||||
fi
|
||||
|
||||
alias c='clear'
|
||||
alias cls='clear'
|
||||
|
||||
alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
|
||||
alias pager='${PAGER:=less}'
|
||||
|
||||
alias q='exit'
|
||||
|
||||
alias irc='${IRC_CLIENT:=irc}'
|
||||
|
||||
# Language aliases
|
||||
alias rb='ruby'
|
||||
alias py='python'
|
||||
alias ipy='ipython'
|
||||
|
||||
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
||||
|
||||
alias piano='pianobar'
|
||||
|
||||
alias ..='cd ..' # Go up one directory
|
||||
alias cd..='cd ..' # Common misspelling for going up one directory
|
||||
alias ...='cd ../..' # Go up two directories
|
||||
alias ....='cd ../../..' # Go up three directories
|
||||
alias -- -='cd -' # Go back
|
||||
|
||||
# Shell History
|
||||
alias h='history'
|
||||
|
||||
# Tree
|
||||
if ! _command_exists tree; then
|
||||
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
|
||||
fi
|
||||
|
||||
# Directory
|
||||
alias md='mkdir -p'
|
||||
alias rd='rmdir'
|
||||
|
||||
# Shorten extract
|
||||
alias xt='extract'
|
||||
|
||||
# sudo editors
|
||||
alias svim='sudo ${VISUAL:-vim}'
|
||||
alias snano='sudo nano'
|
||||
|
||||
# Display whatever file is regular file or folder
|
||||
function catt() {
|
||||
for i in "$@"; do
|
||||
if [[ -d "$i" ]]; then
|
||||
ls "$i"
|
||||
else
|
||||
cat "$i"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# The Bash-it aliases were moved to the `bash-it.aliases.bash` file. The intent of this
|
||||
# is to keep the script readable and less bloated. If you don't need to use
|
||||
# the `general` aliases, but you want the Bash-it aliases, you can disable the `general`
|
||||
# aliases and enable just the ones for Bash-it explicitly:
|
||||
# bash-it disable alias general
|
||||
# bash-it enable alias bash-it
|
||||
# shellcheck source-path=SCRIPTDIR
|
||||
source "$BASH_IT/aliases/available/bash-it.aliases.bash"
|
||||
207
dot_bash_it/aliases/available/git.aliases.bash
Normal file
207
dot_bash_it/aliases/available/git.aliases.bash
Normal file
@@ -0,0 +1,207 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'common git abbreviations'
|
||||
|
||||
alias g='git'
|
||||
alias get='git'
|
||||
|
||||
# add
|
||||
alias ga='git add'
|
||||
alias gall='git add -A'
|
||||
alias gap='git add -p'
|
||||
|
||||
# branch
|
||||
alias gb='git branch'
|
||||
alias gbD='git branch -D'
|
||||
alias gba='git branch -a'
|
||||
alias gbd='git branch -d'
|
||||
alias gbm='git branch -m'
|
||||
alias gbt='git branch --track'
|
||||
alias gdel='git branch -D'
|
||||
|
||||
# for-each-ref
|
||||
alias gbc='git for-each-ref --format="%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)" refs/remotes/ --sort=authorname DESC' # FROM https://stackoverflow.com/a/58623139/10362396
|
||||
|
||||
# commit
|
||||
alias gc='git commit -v'
|
||||
alias gca='git commit -v -a'
|
||||
alias gcaa='git commit -a --amend -C HEAD' # Add uncommitted and unstaged changes to the last commit
|
||||
alias gcam='git commit -v -am'
|
||||
alias gcamd='git commit --amend'
|
||||
alias gcm='git commit -v -m'
|
||||
alias gci='git commit --interactive'
|
||||
alias gcsam='git commit -S -am'
|
||||
|
||||
# checkout
|
||||
alias gcb='git checkout -b'
|
||||
alias gco='git checkout'
|
||||
alias gcob='git checkout -b'
|
||||
alias gcobu='git checkout -b ${USER}/'
|
||||
alias gcom='git checkout $(get_default_branch)'
|
||||
alias gcpd='git checkout $(get_default_branch); git pull; git branch -D'
|
||||
alias gct='git checkout --track'
|
||||
|
||||
# clone
|
||||
alias gcl='git clone'
|
||||
|
||||
# clean
|
||||
alias gclean='git clean -fd'
|
||||
|
||||
# cherry-pick
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcpx='git cherry-pick -x'
|
||||
|
||||
# diff
|
||||
alias gd='git diff'
|
||||
alias gds='git diff --staged'
|
||||
alias gdt='git difftool'
|
||||
|
||||
# archive
|
||||
alias gexport='git archive --format zip --output'
|
||||
|
||||
# fetch
|
||||
alias gf='git fetch --all --prune'
|
||||
alias gft='git fetch --all --prune --tags'
|
||||
alias gftv='git fetch --all --prune --tags --verbose'
|
||||
alias gfv='git fetch --all --prune --verbose'
|
||||
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch)'
|
||||
alias gup='git fetch && git rebase'
|
||||
|
||||
# log
|
||||
alias gg='git log --graph --pretty=format:'\''%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative'
|
||||
alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\'''
|
||||
alias ggs='gg --stat'
|
||||
alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits
|
||||
alias gll='git log --graph --pretty=oneline --abbrev-commit'
|
||||
alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
|
||||
alias gwc='git whatchanged'
|
||||
|
||||
# ls-files
|
||||
alias gu='git ls-files . --exclude-standard --others' # Show untracked files
|
||||
alias glsut='gu'
|
||||
alias glsum='git diff --name-only --diff-filter=U' # Show unmerged (conflicted) files
|
||||
|
||||
# gui
|
||||
alias ggui='git gui'
|
||||
|
||||
# home
|
||||
alias ghm='cd "$(git rev-parse --show-toplevel)"' # Git home
|
||||
# appendage to ghm
|
||||
if ! _command_exists gh; then
|
||||
alias gh='ghm'
|
||||
fi
|
||||
|
||||
# merge
|
||||
alias gm='git merge'
|
||||
|
||||
# mv
|
||||
alias gmv='git mv'
|
||||
|
||||
# patch
|
||||
alias gpatch='git format-patch -1'
|
||||
|
||||
# push
|
||||
alias gp='git push'
|
||||
alias gpd='git push --delete'
|
||||
alias gpf='git push --force'
|
||||
alias gpo='git push origin HEAD'
|
||||
alias gpom='git push origin $(get_default_branch)'
|
||||
alias gpu='git push --set-upstream'
|
||||
alias gpunch='git push --force-with-lease'
|
||||
alias gpuo='git push --set-upstream origin'
|
||||
alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
|
||||
|
||||
# pull
|
||||
alias gl='git pull'
|
||||
alias glum='git pull upstream $(get_default_branch)'
|
||||
alias gpl='git pull'
|
||||
alias gpp='git pull && git push'
|
||||
alias gpr='git pull --rebase'
|
||||
|
||||
# remote
|
||||
alias gr='git remote'
|
||||
alias gra='git remote add'
|
||||
alias grv='git remote -v'
|
||||
|
||||
# rm
|
||||
alias grm='git rm'
|
||||
|
||||
# rebase
|
||||
alias grb='git rebase'
|
||||
alias grbc='git rebase --continue'
|
||||
alias grm='git rebase $(get_default_branch)'
|
||||
alias grmi='git rebase $(get_default_branch) -i'
|
||||
alias grma='GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosquash'
|
||||
alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote
|
||||
|
||||
# reset
|
||||
alias gus='git reset HEAD'
|
||||
alias gpristine='git reset --hard && git clean -dfx'
|
||||
|
||||
# status
|
||||
alias gs='git status'
|
||||
alias gss='git status -s'
|
||||
|
||||
# shortlog
|
||||
alias gcount='git shortlog -sn'
|
||||
alias gsl='git shortlog -sn'
|
||||
|
||||
# show
|
||||
alias gsh='git show'
|
||||
|
||||
# svn
|
||||
alias gsd='git svn dcommit'
|
||||
alias gsr='git svn rebase' # Git SVN
|
||||
|
||||
# stash
|
||||
alias gst='git stash'
|
||||
alias gstb='git stash branch'
|
||||
alias gstd='git stash drop'
|
||||
alias gstl='git stash list'
|
||||
alias gstp='git stash pop' # kept due to long-standing usage
|
||||
alias gstpo='git stash pop' # recommended for it's symmetry with gstpu (push)
|
||||
|
||||
## 'stash push' introduced in git v2.13.2
|
||||
alias gstpu='git stash push'
|
||||
alias gstpum='git stash push -m'
|
||||
|
||||
## 'stash save' deprecated since git v2.16.0, alias is now push
|
||||
alias gsts='git stash push'
|
||||
alias gstsm='git stash push -m'
|
||||
|
||||
# submodules
|
||||
alias gsu='git submodule update --init --recursive'
|
||||
|
||||
# switch
|
||||
# these aliases requires git v2.23+
|
||||
alias gsw='git switch'
|
||||
alias gswc='git switch --create'
|
||||
alias gswm='git switch $(get_default_branch)'
|
||||
alias gswt='git switch --track'
|
||||
|
||||
# tag
|
||||
alias gt='git tag'
|
||||
alias gta='git tag -a'
|
||||
alias gtd='git tag -d'
|
||||
alias gtl='git tag -l'
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias gtls="git tag -l | gsort -V"
|
||||
;;
|
||||
*)
|
||||
alias gtls='git tag -l | sort -V'
|
||||
;;
|
||||
esac
|
||||
|
||||
# functions
|
||||
function gdv() {
|
||||
git diff --ignore-all-space "$@" | vim -R -
|
||||
}
|
||||
|
||||
function get_default_branch() {
|
||||
if git branch | grep -q '^. main\s*$'; then
|
||||
echo main
|
||||
else
|
||||
echo master
|
||||
fi
|
||||
}
|
||||
7
dot_bash_it/aliases/available/gitsvn.aliases.bash
Normal file
7
dot_bash_it/aliases/available/gitsvn.aliases.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'common git-svn abbreviations'
|
||||
|
||||
# Aliases
|
||||
alias gsr='git svn rebase'
|
||||
alias gsc='git svn dcommit'
|
||||
alias gsi='git svn info'
|
||||
34
dot_bash_it/aliases/available/heroku.aliases.bash
Normal file
34
dot_bash_it/aliases/available/heroku.aliases.bash
Normal file
@@ -0,0 +1,34 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'heroku task abbreviations'
|
||||
|
||||
# heroku
|
||||
alias h='heroku'
|
||||
alias hl='heroku list'
|
||||
alias hi='heroku info'
|
||||
alias ho='heroku open'
|
||||
|
||||
# dynos and workers
|
||||
alias hd='heroku dynos'
|
||||
alias hw='heroku workers'
|
||||
|
||||
# rake console
|
||||
alias hr='heroku rake'
|
||||
alias hcon='heroku console'
|
||||
|
||||
# new and restart
|
||||
alias hnew='heroku create'
|
||||
alias hrestart='heroku restart'
|
||||
|
||||
# logs
|
||||
alias hlog='heroku logs'
|
||||
alias hlogs='heroku logs'
|
||||
|
||||
# maint
|
||||
alias hon='heroku maintenance:on'
|
||||
alias hoff='heroku maintenance:off'
|
||||
|
||||
# heroku configs
|
||||
alias hc='heroku config'
|
||||
alias hca='heroku config:add'
|
||||
alias hcr='heroku config:remove'
|
||||
alias hcc='heroku config:clear'
|
||||
6
dot_bash_it/aliases/available/hg.aliases.bash
Normal file
6
dot_bash_it/aliases/available/hg.aliases.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'mercurial abbreviations'
|
||||
|
||||
alias hs='hg status'
|
||||
alias hsum='hg summary'
|
||||
alias hcm='hg commit -m'
|
||||
11
dot_bash_it/aliases/available/homebrew-cask.aliases.bash
Normal file
11
dot_bash_it/aliases/available/homebrew-cask.aliases.bash
Normal file
@@ -0,0 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Some aliases for Homebrew Cask'
|
||||
|
||||
alias bcin='brew cask install'
|
||||
alias bcrm='brew cask uninstall'
|
||||
alias bczp='brew cask zap'
|
||||
alias bccl='brew cask cleanup'
|
||||
alias bcls='brew cask list'
|
||||
alias bcinf='brew cask info'
|
||||
alias bcdr='brew cask doctor'
|
||||
alias bced='brew cask edit'
|
||||
13
dot_bash_it/aliases/available/homebrew.aliases.bash
Normal file
13
dot_bash_it/aliases/available/homebrew.aliases.bash
Normal file
@@ -0,0 +1,13 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Some aliases for Homebrew'
|
||||
|
||||
alias bup='brew update && brew upgrade'
|
||||
alias bout='brew outdated'
|
||||
alias bin='brew install'
|
||||
alias brm='brew uninstall'
|
||||
alias bcl='brew cleanup'
|
||||
alias bls='brew list'
|
||||
alias bsr='brew search'
|
||||
alias binf='brew info'
|
||||
alias bdr='brew doctor'
|
||||
alias bed='brew edit'
|
||||
23
dot_bash_it/aliases/available/homesick.aliases.bash
Normal file
23
dot_bash_it/aliases/available/homesick.aliases.bash
Normal file
@@ -0,0 +1,23 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'homesick aliases'
|
||||
|
||||
# Aliases
|
||||
alias sikhm="homesick cd dotfiles"
|
||||
alias sikclone="homesick clone"
|
||||
alias sikcomt="homesick commit dotfiles"
|
||||
alias sikdstry="homesick destroy"
|
||||
alias sikdif="homesick diff dotfiles"
|
||||
alias sikexec="homesick exec dotfiles"
|
||||
alias sikexeca="homesick exec_all"
|
||||
alias sikgen="homesick generate"
|
||||
alias sikhlp="homesick help"
|
||||
alias siklnk="homesick link dotfiles"
|
||||
alias sikls="homesick list"
|
||||
alias sikopn="homesick open dotfiles"
|
||||
alias sikpll="homesick pull dotfiles"
|
||||
alias sikpsh="homesick push dotfiles"
|
||||
alias sikrc="homesick rc dotfiles"
|
||||
alias sikpth="homesick show_path dotfiles"
|
||||
alias sikst="homesick status dotfiles"
|
||||
alias sikulnk="homesick unlink dotfiles"
|
||||
alias sikv="homesick version"
|
||||
49
dot_bash_it/aliases/available/jitsu.aliases.bash
Normal file
49
dot_bash_it/aliases/available/jitsu.aliases.bash
Normal file
@@ -0,0 +1,49 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'jitsu task abbreviations'
|
||||
|
||||
# jitsu
|
||||
alias j='jitsu'
|
||||
alias jl='jitsu login'
|
||||
alias jo='jitsu logout'
|
||||
|
||||
# deploy and update
|
||||
alias jd='jitsu apps deploy'
|
||||
alias ju='jitsu apps update'
|
||||
|
||||
# new and start, restart, stop
|
||||
alias jn='jitsu apps create'
|
||||
alias js='jitsu apps start'
|
||||
alias jr='jitsu apps restart'
|
||||
alias jx='jitsu apps stop'
|
||||
|
||||
# logs
|
||||
alias jll='jitsu logs'
|
||||
alias jlog='jitsu logs'
|
||||
alias jlogs='jitsu logs'
|
||||
|
||||
# env
|
||||
alias je='jitsu env'
|
||||
alias jel='jitsu env list'
|
||||
alias jes='jitsu env set'
|
||||
alias jeg='jitsu env get'
|
||||
alias jed='jitsu env delete'
|
||||
alias jec='jitsu env clear'
|
||||
alias jesv='jitsu env save'
|
||||
alias jeld='jitsu env load'
|
||||
|
||||
# configuration
|
||||
alias jc='jitsu conf'
|
||||
alias jcl='jitsu config list'
|
||||
alias jcs='jitsu config set'
|
||||
alias jcg='jitsu config get'
|
||||
alias jcd='jitsu config delete'
|
||||
|
||||
# list and install, view
|
||||
alias jls='jitsu list'
|
||||
alias jin='jitsu install'
|
||||
alias jv='jitsu apps view'
|
||||
|
||||
# Database, Snapshots and Tokens
|
||||
alias jdb='jitsu databases'
|
||||
alias jss='jitsu snapshots'
|
||||
alias jto='jitsu tokens'
|
||||
20
dot_bash_it/aliases/available/kubectl.aliases.bash
Normal file
20
dot_bash_it/aliases/available/kubectl.aliases.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'kubectl aliases'
|
||||
|
||||
function _set_pkg_aliases() {
|
||||
if _command_exists 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'
|
||||
# launches a disposable netshoot pod in the k8s cluster
|
||||
alias kcnetshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
|
||||
fi
|
||||
}
|
||||
|
||||
_set_pkg_aliases
|
||||
74
dot_bash_it/aliases/available/laravel.aliases.bash
Normal file
74
dot_bash_it/aliases/available/laravel.aliases.bash
Normal file
@@ -0,0 +1,74 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'laravel artisan abbreviations'
|
||||
|
||||
# A list of useful laravel aliases
|
||||
|
||||
alias laravel='${HOME?}/.composer/vendor/bin/laravel'
|
||||
# asset
|
||||
alias a:apub='php artisan asset:publish'
|
||||
|
||||
# auth
|
||||
alias a:remclear='php artisan auth:clear-reminders'
|
||||
alias a:remcontroller='php artisan auth:reminders-controller'
|
||||
alias a:remtable='php artisan auth:reminders-table'
|
||||
|
||||
# cache
|
||||
alias a:cacheclear='php artisan cache:clear'
|
||||
|
||||
# command
|
||||
alias a:command='php artisan command:make'
|
||||
|
||||
# config
|
||||
alias a:confpub='php artisan config:publish'
|
||||
|
||||
# controller
|
||||
alias a:controller='php artisan make:controller'
|
||||
|
||||
# db
|
||||
alias a:seed='php artisan db:seed'
|
||||
|
||||
# key
|
||||
alias a:key='php artisan key:generate'
|
||||
|
||||
# migrate
|
||||
alias a:migrate='php artisan migrate'
|
||||
alias a:mig='a:migrate'
|
||||
alias a:miginstall='php artisan migrate:install'
|
||||
alias a:migmake='php artisan migrate:make'
|
||||
alias a:migcreate='php artisan migrate:create'
|
||||
alias a:migpublish='php artisan migrate:publish'
|
||||
alias a:migrefresh='php artisan migrate:refresh'
|
||||
alias a:migreset='php artisan migrate:reset'
|
||||
alias a:migrollback='php artisan migrate:rollback'
|
||||
alias a:rollback='a:migrollback'
|
||||
|
||||
# queue
|
||||
alias a:qfailed='php artisan queue:failed'
|
||||
alias a:qfailedtable='php artisan queue:failed-table'
|
||||
alias a:qflush='php artisan queue:flush'
|
||||
alias a:qforget='php artisan queue:forget'
|
||||
alias a:qlisten='php artisan queue:listen'
|
||||
alias a:qretry='php artisan queue:retry'
|
||||
alias a:qsubscribe='php artisan queue:subscribe'
|
||||
alias a:qwork='php artisan queue:work'
|
||||
|
||||
# session
|
||||
alias a:stable='php artisan session:table'
|
||||
|
||||
# view
|
||||
alias a:vpub='php artisan view:publish'
|
||||
|
||||
# misc
|
||||
alias a:='php artisan'
|
||||
alias a:changes='php artisan changes'
|
||||
alias a:down='php artisan down'
|
||||
alias a:env='php artisan env'
|
||||
alias a:help='php artisan help'
|
||||
alias a:list='php artisan list'
|
||||
alias a:optimize='php artisan optimize'
|
||||
alias a:routes='php artisan routes'
|
||||
alias a:serve='php artisan serve'
|
||||
alias a:tail='php artisan tail'
|
||||
alias a:tinker='php artisan tinker'
|
||||
alias a:up='php artisan up'
|
||||
alias a:work='php artisan workbench'
|
||||
14
dot_bash_it/aliases/available/maven.aliases.bash
Normal file
14
dot_bash_it/aliases/available/maven.aliases.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
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'
|
||||
14
dot_bash_it/aliases/available/msys2.aliases.bash
Normal file
14
dot_bash_it/aliases/available/msys2.aliases.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'MSYS2 aliases'
|
||||
|
||||
LS_COMMON="-hG"
|
||||
LS_COMMON="$LS_COMMON --color=auto"
|
||||
LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*"
|
||||
|
||||
# alias
|
||||
# setup the main ls alias if we've established common args
|
||||
alias ls='command ls ${LS_COMMON:-}'
|
||||
alias ll="ls -l"
|
||||
alias la="ls -a"
|
||||
alias lal="ll -a"
|
||||
alias lf="ls -F"
|
||||
8
dot_bash_it/aliases/available/node.aliases.bash
Normal file
8
dot_bash_it/aliases/available/node.aliases.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'the Node.js environment aliases'
|
||||
|
||||
# alias to setup nodejs development environment
|
||||
alias node-dev='export NODE_ENV=development'
|
||||
|
||||
# alias to setup nodejs production environment
|
||||
alias node-prod='export NODE_ENV=production'
|
||||
43
dot_bash_it/aliases/available/npm.aliases.bash
Normal file
43
dot_bash_it/aliases/available/npm.aliases.bash
Normal file
@@ -0,0 +1,43 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'common npm abbreviations'
|
||||
|
||||
# Aliases
|
||||
|
||||
# npm
|
||||
alias ni='npm install'
|
||||
alias nis='npm install --save'
|
||||
alias nid='npm install --save-dev'
|
||||
alias nit='npm install-test'
|
||||
alias nits='npm install-test --save'
|
||||
alias nitd='npm install-test --save-dev'
|
||||
alias nu='npm uninstall'
|
||||
alias nus='npm uninstall --save'
|
||||
alias nusd='npm uninstall --save-dev'
|
||||
alias np='npm publish'
|
||||
alias nup='npm unpublish'
|
||||
alias nlk='npm link'
|
||||
alias nod='npm outdated'
|
||||
alias nrb='npm rebuild'
|
||||
alias nud='npm update'
|
||||
alias nr='npm run'
|
||||
alias nls='npm list --depth=0 2>/dev/null'
|
||||
alias nlsg='npm list -g --depth=0 2>/dev/null'
|
||||
alias nt='npm test'
|
||||
|
||||
# npx
|
||||
alias nx='npx'
|
||||
alias nxplease='npx $(fc -ln -1)'
|
||||
alias nxn='npx --no-install '
|
||||
alias nxp='npx -p '
|
||||
alias nxnp='npx --no-install -p '
|
||||
alias nxq='npx -q '
|
||||
alias nxnq='npx --no-install -q '
|
||||
alias nxqp='npx -q -p '
|
||||
alias nxnqp='npx --no-install -q -p '
|
||||
alias nxni='npx --no-install --ignore-existing '
|
||||
alias nxip='npx --ignore-existing -p '
|
||||
alias nxnip='npx --no-install --ignore-existing -p '
|
||||
alias nxqi='npx -q --ignore-existing '
|
||||
alias nxniq='npx --no-install --ignore-existing -q '
|
||||
alias nxiqp='npx --ignore-existing -q -p '
|
||||
alias nxniqp='npx --no-install --ignore-existing -q -p '
|
||||
57
dot_bash_it/aliases/available/osx.aliases.bash
Normal file
57
dot_bash_it/aliases/available/osx.aliases.bash
Normal file
@@ -0,0 +1,57 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'osx-specific aliases'
|
||||
|
||||
# Desktop Programs
|
||||
alias fireworks='open -a "/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app"'
|
||||
alias photoshop='open -a "/Applications/Adobe Photoshop CS3/Adobe Photoshop.app"'
|
||||
alias preview='open -a "${PREVIEW?}"'
|
||||
alias xcode='open -a "/Applications/XCode.app"'
|
||||
alias filemerge='open -a "/Developer/Applications/Utilities/FileMerge.app"'
|
||||
alias safari='open -a safari'
|
||||
alias firefox='open -a firefox'
|
||||
alias chrome='open -a "Google Chrome"'
|
||||
alias chromium='open -a chromium'
|
||||
alias brave='open -a "Brave Browser"'
|
||||
alias dashcode='open -a dashcode'
|
||||
alias f='open -a Finder '
|
||||
alias fh='open -a Finder .'
|
||||
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"'
|
||||
|
||||
if [[ -s /usr/bin/firefox ]]; then
|
||||
unalias firefox
|
||||
fi
|
||||
|
||||
# Requires growlnotify, which can be found in the Growl DMG under "Extras"
|
||||
alias grnot='growlnotify -s -t Terminal -m "Done"'
|
||||
|
||||
# Get rid of those pesky .DS_Store files recursively
|
||||
alias dsclean='find . -type f -name .DS_Store -delete'
|
||||
|
||||
# Track who is listening to your iTunes music
|
||||
alias whotunes='lsof -r 2 -n -P -F n -c iTunes -a -i TCP@`hostname`:3689'
|
||||
|
||||
# Flush your dns cache
|
||||
alias flush='dscacheutil -flushcache'
|
||||
|
||||
# Show/hide hidden files (for Mac OS X Mavericks)
|
||||
alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE'
|
||||
alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE'
|
||||
|
||||
# From http://apple.stackexchange.com/questions/110343/copy-last-command-in-terminal
|
||||
# shellcheck disable=SC2142 # The quoting confuses `shellcheck`...
|
||||
alias copyLastCmd="fc -ln -1 | awk '{\$1=\$1}1' ORS='' | pbcopy"
|
||||
|
||||
# Use Finder's Quick Look on a file (^C or space to close)
|
||||
alias ql='qlmanage -p 2>/dev/null'
|
||||
|
||||
# Mute/Unmute the system volume. Plays nice with all other volume settings.
|
||||
alias mute='osascript -e "set volume output muted true"'
|
||||
alias unmute='osascript -e "set volume output muted false"'
|
||||
|
||||
# Pin to the tail of long commands for an audible alert after long processes
|
||||
## curl http://downloads.com/hugefile.zip; lmk
|
||||
alias lmk='say "Process complete."'
|
||||
49
dot_bash_it/aliases/available/phoenix.aliases.bash
Normal file
49
dot_bash_it/aliases/available/phoenix.aliases.bash
Normal file
@@ -0,0 +1,49 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'phoenix abbreviations'
|
||||
|
||||
# Phoenix Commands
|
||||
alias i='iex'
|
||||
alias ips='iex -S mix phx.server'
|
||||
alias ism='iex -S mix'
|
||||
alias m='mix'
|
||||
alias mab='mix archive.build'
|
||||
alias mai='mix archive.install'
|
||||
alias mat='mix app.tree'
|
||||
alias mc='mix compile'
|
||||
alias mcv='mix compile --verbose'
|
||||
alias mcx='mix compile.xref'
|
||||
alias mdc='mix deps.compile'
|
||||
alias mdg='mix deps.get'
|
||||
alias mdgc='mix do deps.get, deps.compile'
|
||||
alias mdu='mix deps.update'
|
||||
alias mdt='mix deps.tree'
|
||||
alias mdua='mix deps.update --all'
|
||||
alias mdun='mix deps.unlock'
|
||||
alias mduu='mix deps.unlock --unused'
|
||||
alias meb='mix escript.build'
|
||||
alias mec='mix ecto.create'
|
||||
alias mecm='mix do ecto.create, ecto.migrate'
|
||||
alias med='mix ecto.drop'
|
||||
alias mem='mix ecto.migrate'
|
||||
alias megm='mix ecto.gen.migration'
|
||||
alias merb='mix ecto.rollback'
|
||||
alias mers='mix ecto.reset'
|
||||
alias mho='mix hex.outdated'
|
||||
alias mlh='mix local.hex'
|
||||
alias mn='mix new'
|
||||
alias mns='mix new --sup'
|
||||
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'
|
||||
alias mt='mix test'
|
||||
alias mts='mix test --stale'
|
||||
alias mtw='mix test.watch'
|
||||
alias mx='mix xref'
|
||||
9
dot_bash_it/aliases/available/puppet.aliases.bash
Normal file
9
dot_bash_it/aliases/available/puppet.aliases.bash
Normal file
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
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"
|
||||
152
dot_bash_it/aliases/available/pyrocms.aliases.bash
Normal file
152
dot_bash_it/aliases/available/pyrocms.aliases.bash
Normal file
@@ -0,0 +1,152 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'pyrocms abbreviations'
|
||||
|
||||
###
|
||||
## PyroCMS 3.4 bash aliases
|
||||
## @author Denis Efremov <efremov.a.denis@gmail.com>
|
||||
###
|
||||
|
||||
# general
|
||||
alias a:cl="php artisan clear-compiled" # Remove the compiled class file
|
||||
alias a:d="php artisan down" # Put the application into maintenance mode
|
||||
alias a:e="php artisan env" # Display the current framework environment
|
||||
alias a:h="php artisan help" # Displays help for a command
|
||||
alias a:i="php artisan install" # Install the Streams Platform.
|
||||
alias a:ls="php artisan list" # Lists commands
|
||||
alias a:mg="php artisan migrate" # Run the database migrations
|
||||
alias a:op="php artisan optimize" # Optimize the framework for better performance (deprecated)
|
||||
alias a:pr="php artisan preset" # Swap the front-end scaffolding for the application
|
||||
alias a:s="php artisan serve" # Serve the application on the PHP development server
|
||||
alias a:u="php artisan up" # Bring the application out of maintenance mode
|
||||
|
||||
# addon
|
||||
alias a:ad:i="php artisan addon:install" # Install an addon.
|
||||
alias a:ad:p="php artisan addon:publish" # Publish an the configuration and translations for an addon.
|
||||
alias a:ad:r="php artisan addon:reinstall" # Reinstall an addon.
|
||||
alias a:ad:u="php artisan addon:uninstall" # Uninstall an addon.
|
||||
|
||||
# app
|
||||
alias a:ap:n="php artisan app:name" # Set the application namespace
|
||||
alias a:ap:p="php artisan app:publish" # Publish general application override files.
|
||||
|
||||
# assets
|
||||
alias a:as:cl="php artisan assets:clear" # Clear compiled public assets.
|
||||
|
||||
# auth
|
||||
alias a:au:clrs="php artisan auth:clear-resets" # Flush expired password reset tokens
|
||||
|
||||
# cache
|
||||
alias a:ca:cl="php artisan cache:clear" # Flush the application cache
|
||||
alias a:ca:f="php artisan cache:forget" # Remove an item from the cache
|
||||
alias a:ca:t="php artisan cache:table" # Create a migration for the cache database table
|
||||
|
||||
# config
|
||||
alias a:co:ca="php artisan config:cache" # Create a cache file for faster configuration loading
|
||||
alias a:co:cl="php artisan config:clear" # Remove the configuration cache file
|
||||
|
||||
# db
|
||||
alias a:db:s="php artisan db:seed" # Seed the database with records
|
||||
|
||||
# env
|
||||
alias a:en:s="php artisan env:set" # Set an environmental value.
|
||||
|
||||
# event
|
||||
alias a:ev:g="php artisan event:generate" # Generate the missing events and listeners based on registration
|
||||
|
||||
# extension
|
||||
alias a:ex:i="php artisan extension:install" # Install a extension.
|
||||
alias a:ex:r="php artisan extension:reinstall" # Reinstall a extension.
|
||||
alias a:ex:u="php artisan extension:uninstall" # Uninstall a extension.
|
||||
|
||||
# files
|
||||
alias a:fi:cl="php artisan files:clean" # Clean missing files from the files table.
|
||||
|
||||
# key
|
||||
alias a:ke:g="php artisan key:generate" # Set the application key
|
||||
|
||||
# make
|
||||
alias a:mk:ad="php artisan make:addon" # Create a new addon.
|
||||
alias a:mk:au="php artisan make:auth" # Scaffold basic login and registration views and routes
|
||||
alias a:mk:cm="php artisan make:command" # Create a new Artisan command
|
||||
alias a:mk:ct="php artisan make:controller" # Create a new controller class
|
||||
alias a:mk:ev="php artisan make:event" # Create a new event class
|
||||
alias a:mk:fa="php artisan make:factory" # Create a new model factory
|
||||
alias a:mk:j="php artisan make:job" # Create a new job class
|
||||
alias a:mk:li="php artisan make:listener" # Create a new event listener class
|
||||
alias a:mk:ma="php artisan make:mail" # Create a new email class
|
||||
alias a:mk:mw="php artisan make:middleware" # Create a new middleware class
|
||||
alias a:mk:mg="php artisan make:migration" # Create a new migration file
|
||||
alias a:mk:md="php artisan make:model" # Create a new Eloquent model class
|
||||
alias a:mk:no="php artisan make:notification" # Create a new notification class
|
||||
alias a:mk:po="php artisan make:policy" # Create a new policy class
|
||||
alias a:mk:pr="php artisan make:provider" # Create a new service provider class
|
||||
alias a:mk:rq="php artisan make:request" # Create a new form request class
|
||||
alias a:mk:rs="php artisan make:resource" # Create a new resource
|
||||
alias a:mk:rl="php artisan make:rule" # Create a new validation rule
|
||||
alias a:mk:sd="php artisan make:seeder" # Create a new seeder class
|
||||
alias a:mk:st="php artisan make:stream" # Make a streams entity namespace.
|
||||
alias a:mk:ts="php artisan make:test" # Create a new test class
|
||||
|
||||
# migrate
|
||||
alias a:mg:fr="php artisan migrate:fresh" # Drop all tables and re-run all migrations
|
||||
alias a:mg:i="php artisan migrate:install" # Create the migration repository
|
||||
alias a:mg:rf="php artisan migrate:refresh" # Reset and re-run all migrations
|
||||
alias a:mg:rs="php artisan migrate:reset" # Rollback all database migrations
|
||||
alias a:mg:rl="php artisan migrate:rollback" # Rollback the last database migration
|
||||
alias a:mg:st="php artisan migrate:status" # Show the status of each migration
|
||||
|
||||
# module
|
||||
alias a:mo:i="php artisan module:install" # Install a module.
|
||||
alias a:mo:r="php artisan module:reinstall" # Reinstall a module.
|
||||
alias a:mo:u="php artisan module:uninstall" # Uninstall a module.
|
||||
|
||||
# notifications
|
||||
alias a:no:tb="php artisan notifications:table" # Create a migration for the notifications table
|
||||
|
||||
# package
|
||||
alias a:pk:d="php artisan package:discover" # Rebuild the cached package manifest
|
||||
|
||||
# queue
|
||||
alias a:qu:fa="php artisan queue:failed" # List all of the failed queue jobs
|
||||
alias a:qu:ft="php artisan queue:failed-table" # Create a migration for the failed queue jobs database table
|
||||
alias a:qu:fl="php artisan queue:flush" # Flush all of the failed queue jobs
|
||||
alias a:qu:fg="php artisan queue:forget" # Delete a failed queue job
|
||||
alias a:qu:li="php artisan queue:listen" # Listen to a given queue
|
||||
alias a:qu:rs="php artisan queue:restart" # Restart queue worker daemons after their current job
|
||||
alias a:qu:rt="php artisan queue:retry" # Retry a failed queue job
|
||||
alias a:qu:tb="php artisan queue:table" # Create a migration for the queue jobs database table
|
||||
alias a:qu:w="php artisan queue:work" # Start processing jobs on the queue as a daemon
|
||||
|
||||
# route
|
||||
alias a:ro:ca="php artisan route:cache" # Create a route cache file for faster route registration
|
||||
alias a:ro:cl="php artisan route:clear" # Remove the route cache file
|
||||
alias a:ro:ls="php artisan route:list" # List all registered routes
|
||||
|
||||
# schedule
|
||||
alias a:sc:r="php artisan schedule:run" # Run the scheduled commands
|
||||
|
||||
# scout
|
||||
alias a:su:fl="php artisan scout:flush" # Flush all of the model's records from the index
|
||||
alias a:su:im="php artisan scout:import" # Import the given model into the search index
|
||||
|
||||
# session
|
||||
alias a:se:tb="php artisan session:table" # Create a migration for the session database table
|
||||
|
||||
# storage
|
||||
alias a:sg:l="php artisan storage:link" # Create a symbolic link from "public/storage" to "storage/app/public"
|
||||
|
||||
# streams
|
||||
alias a:st:cl="php artisan streams:cleanup" # Cleanup streams entry models.
|
||||
alias a:st:co="php artisan streams:compile" # Compile streams entry models.
|
||||
alias a:st:d="php artisan streams:destroy" # Destroy a namespace.
|
||||
alias a:st:p="php artisan streams:publish" # Publish configuration and translations for streams.
|
||||
alias a:st:r="php artisan streams:refresh" # Refresh streams generated components.
|
||||
|
||||
# tntsearch
|
||||
alias a:tn:im="php artisan tntsearch:import" # Import the given model into the search index
|
||||
|
||||
# vendor
|
||||
alias a:ve:p="php artisan vendor:publish" # Publish any publishable assets from vendor packages
|
||||
|
||||
# view
|
||||
alias a:vi:cl="php artisan view:clear" # Clear all compiled view files
|
||||
22
dot_bash_it/aliases/available/rails.aliases.bash
Normal file
22
dot_bash_it/aliases/available/rails.aliases.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'rails abbreviations'
|
||||
|
||||
# Rails Commands
|
||||
alias r='rails'
|
||||
alias rg='rails g'
|
||||
alias rs='rails s'
|
||||
alias rc='rails c'
|
||||
alias rn='rails new'
|
||||
alias rb='rails dbconsole'
|
||||
alias rp='rails plugin'
|
||||
alias ra='rails application'
|
||||
alias rd='rails destroy'
|
||||
alias dbm='rake db:migrate'
|
||||
|
||||
alias ss='script/server'
|
||||
alias ts="thin start" # thin server
|
||||
alias sc='script/console'
|
||||
alias restartapp='touch tmp/restart.txt'
|
||||
alias restart='touch tmp/restart.txt' # restart passenger
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias taild='tail -f log/development.log' # tail dev log
|
||||
15
dot_bash_it/aliases/available/svn.aliases.bash
Normal file
15
dot_bash_it/aliases/available/svn.aliases.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'common svn abbreviations'
|
||||
|
||||
# Aliases
|
||||
alias svs='svn status'
|
||||
alias sa='svn add'
|
||||
alias sci='svn ci -m'
|
||||
alias sco='svn co'
|
||||
alias sup='svn up'
|
||||
alias scu='svn cleanup'
|
||||
alias sli='svn list'
|
||||
alias sdel='svn delete'
|
||||
alias sdif='svn diff'
|
||||
alias slog='svn log'
|
||||
alias smv='svn move'
|
||||
22
dot_bash_it/aliases/available/systemd.aliases.bash
Normal file
22
dot_bash_it/aliases/available/systemd.aliases.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'systemd service'
|
||||
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
# Improve aliases by bringing the common root `sc|scd` + `sre` for action + `u` for user
|
||||
alias sc='systemctl'
|
||||
alias scu='systemctl --user'
|
||||
alias scdr='systemctl daemon-reload'
|
||||
alias scdru='systemctl --user daemon-reload'
|
||||
alias scr='systemctl restart'
|
||||
alias scru='systemctl --user restart'
|
||||
alias sce='systemctl stop'
|
||||
alias sceu='systemctl --user stop'
|
||||
alias scs='systemctl start'
|
||||
alias scsu='systemctl --user start'
|
||||
# Keeping previous aliases for a non-breaking change.
|
||||
alias scue='sceu'
|
||||
alias scus='scsu'
|
||||
alias scur='scdru'
|
||||
;;
|
||||
esac
|
||||
8
dot_bash_it/aliases/available/terraform.aliases.bash
Normal file
8
dot_bash_it/aliases/available/terraform.aliases.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Aliases for Terraform and Terragrunt'
|
||||
|
||||
alias tf='terraform'
|
||||
alias tfv='terraform validate'
|
||||
alias tfp='terraform plan'
|
||||
alias tfa='terraform apply'
|
||||
alias tfd='terraform destroy'
|
||||
13
dot_bash_it/aliases/available/terragrunt.aliases.bash
Normal file
13
dot_bash_it/aliases/available/terragrunt.aliases.bash
Normal file
@@ -0,0 +1,13 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Aliases for Terraform and Terragrunt'
|
||||
|
||||
alias tg='terragrunt'
|
||||
alias tgv='terragrunt validate'
|
||||
alias tgp='terragrunt plan'
|
||||
alias tga='terragrunt apply'
|
||||
alias tgd='terragrunt destroy'
|
||||
|
||||
alias tgva='terragrunt validate-all'
|
||||
alias tgpa='terragrunt plan-all'
|
||||
alias tgaa='terragrunt apply-all'
|
||||
alias tgda='terragrunt destroy-all'
|
||||
10
dot_bash_it/aliases/available/textmate.aliases.bash
Normal file
10
dot_bash_it/aliases/available/textmate.aliases.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'textmate abbreviations'
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
# Textmate
|
||||
alias e='mate . &'
|
||||
alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &'
|
||||
;;
|
||||
esac
|
||||
6
dot_bash_it/aliases/available/tmux.aliases.bash
Normal file
6
dot_bash_it/aliases/available/tmux.aliases.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'Tmux terminal multiplexer'
|
||||
|
||||
alias txl='tmux ls'
|
||||
alias txn='tmux new -s'
|
||||
alias txa='tmux a -t'
|
||||
8
dot_bash_it/aliases/available/todo.txt-cli.aliases.bash
Normal file
8
dot_bash_it/aliases/available/todo.txt-cli.aliases.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'todo.txt-cli abbreviations'
|
||||
|
||||
alias tls='"${TODO?}" ls'
|
||||
alias ta='"${TODO?}" a'
|
||||
alias trm='"${TODO?}" rm'
|
||||
alias tdo='"${TODO?}" do'
|
||||
alias tpri='"${TODO?}" pri'
|
||||
11
dot_bash_it/aliases/available/uuidgen.aliases.bash
Normal file
11
dot_bash_it/aliases/available/uuidgen.aliases.bash
Normal file
@@ -0,0 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'uuidgen aliases'
|
||||
|
||||
if _command_exists uuid; then # Linux
|
||||
alias uuidu="uuid | tr '[:lower:]' '[:upper:]'"
|
||||
alias uuidl=uuid
|
||||
elif _command_exists uuidgen; then # macOS/BSD
|
||||
alias uuidu="uuidgen"
|
||||
alias uuid="uuidgen | tr '[:upper:]' '[:lower:]'" # because upper case is like YELLING
|
||||
alias uuidl=uuid
|
||||
fi
|
||||
22
dot_bash_it/aliases/available/vagrant.aliases.bash
Normal file
22
dot_bash_it/aliases/available/vagrant.aliases.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'vagrant aliases'
|
||||
|
||||
# Aliases
|
||||
alias vhl='vagrant hosts list'
|
||||
alias vscp='vagrant scp'
|
||||
alias vsl='vagrant snapshot list'
|
||||
alias vst='vagrant snapshot take'
|
||||
alias vup="vagrant up"
|
||||
alias vupl="vagrant up 2>&1 | tee vagrant.log"
|
||||
alias vh="vagrant halt"
|
||||
alias vs="vagrant suspend"
|
||||
alias vr="vagrant resume"
|
||||
alias vrl="vagrant reload"
|
||||
alias vssh="vagrant ssh"
|
||||
alias vst="vagrant status"
|
||||
alias vp="vagrant provision"
|
||||
alias vdstr="vagrant destroy"
|
||||
# requires vagrant-list plugin
|
||||
alias vl="vagrant list"
|
||||
# requires vagrant-hostmanager plugin
|
||||
alias vhst="vagrant hostmanager"
|
||||
15
dot_bash_it/aliases/available/vault.aliases.bash
Normal file
15
dot_bash_it/aliases/available/vault.aliases.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'vault aliases'
|
||||
|
||||
# Aliases
|
||||
alias vad="vault delete"
|
||||
alias val="vault list"
|
||||
alias var="vault read"
|
||||
alias varn="vault renew"
|
||||
alias varv="vault revoke"
|
||||
alias vasrv="vault server"
|
||||
alias vas="vault status"
|
||||
alias vav="vault version"
|
||||
alias vaw="vault write"
|
||||
alias vag="vault login -method=github"
|
||||
alias varv="vault read -field=value"
|
||||
14
dot_bash_it/aliases/available/vim.aliases.bash
Normal file
14
dot_bash_it/aliases/available/vim.aliases.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'vim abbreviations'
|
||||
|
||||
_command_exists vim || return
|
||||
|
||||
alias v='vim'
|
||||
# open the vim help in fullscreen incorporated from
|
||||
# https://stackoverflow.com/a/4687513
|
||||
alias vimh='vim -c ":h | only"'
|
||||
|
||||
# open vim in new tab is taken from
|
||||
# http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek
|
||||
_command_exists mvim && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
|
||||
_command_exists gvim && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }
|
||||
26
dot_bash_it/aliases/available/yarn.aliases.bash
Normal file
26
dot_bash_it/aliases/available/yarn.aliases.bash
Normal file
@@ -0,0 +1,26 @@
|
||||
# shellcheck shell=bash
|
||||
about-alias 'yarn package manager aliases'
|
||||
|
||||
# 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'
|
||||
alias yain='yarn info'
|
||||
alias yali='yarn licenses ls'
|
||||
alias yaloi='yarn login'
|
||||
alias yaloo='yarn logout'
|
||||
174
dot_bash_it/clean_files.txt
Normal file
174
dot_bash_it/clean_files.txt
Normal file
@@ -0,0 +1,174 @@
|
||||
#######################################################################
|
||||
# Allow-list of files to be lint-checked by CI
|
||||
#
|
||||
# Directory Support
|
||||
# Directory references are allowed within the file, ie:
|
||||
#
|
||||
# themes/powerline
|
||||
#
|
||||
# All files under the referenced directory will be checked
|
||||
#
|
||||
# Checking Files Locally
|
||||
# You can manually invoke the check via:
|
||||
#
|
||||
# lint_clean_files.sh
|
||||
#
|
||||
|
||||
# root directories
|
||||
#
|
||||
aliases/
|
||||
docs/
|
||||
hooks/
|
||||
scripts/
|
||||
|
||||
# root files
|
||||
#
|
||||
.gitattributes
|
||||
bash_it.sh
|
||||
clean_files.txt
|
||||
install.sh
|
||||
lint_clean_files.sh
|
||||
|
||||
# completions
|
||||
#
|
||||
completion/available/apm.completion.bash
|
||||
completion/available/awless.completion.bash
|
||||
completion/available/awscli.completion.bash
|
||||
completion/available/bash-it.completion.bash
|
||||
completion/available/brew.completion.bash
|
||||
completion/available/cargo.completion.bash
|
||||
completion/available/composer.completion.bash
|
||||
completion/available/conda.completion.bash
|
||||
completion/available/consul.completion.bash
|
||||
completion/available/dart.completion.bash
|
||||
completion/available/django.completion.bash
|
||||
completion/available/dmidecode.completion.bash
|
||||
completion/available/docker-machine.completion.bash
|
||||
completion/available/docker.completion.bash
|
||||
completion/available/dotnet.completion.bash
|
||||
completion/available/gcloud.completion.bash
|
||||
completion/available/gem.completion.bash
|
||||
completion/available/git.completion.bash
|
||||
completion/available/github-cli.completion.bash
|
||||
completion/available/go.completion.bash
|
||||
completion/available/helm.completion.bash
|
||||
completion/available/jboss5.completion.bash
|
||||
completion/available/jboss7.completion.bash
|
||||
completion/available/jungle.completion.bash
|
||||
completion/available/knife.completion.bash
|
||||
completion/available/kontena.completion.bash
|
||||
completion/available/kubectl.completion.bash
|
||||
completion/available/laravel.completion.bash
|
||||
completion/available/lerna.completion.bash
|
||||
completion/available/minikube.completion.bash
|
||||
completion/available/ngrok.completion.bash
|
||||
completion/available/notify-send.completion.bash
|
||||
completion/available/npm.completion.bash
|
||||
completion/available/packer.completion.bash
|
||||
completion/available/pip.completion.bash
|
||||
completion/available/pip3.completion.bash
|
||||
completion/available/pipenv.completion.bash
|
||||
completion/available/pipx.completion.bash
|
||||
completion/available/rustup.completion.bash
|
||||
completion/available/sdkman.completion.bash
|
||||
completion/available/system.completion.bash
|
||||
completion/available/vault.completion.bash
|
||||
completion/available/vuejs.completion.bash
|
||||
completion/available/wpscan.completion.bash
|
||||
|
||||
# libraries
|
||||
lib/appearance.bash
|
||||
lib/colors.bash
|
||||
lib/command_duration.bash
|
||||
lib/helpers.bash
|
||||
lib/history.bash
|
||||
lib/log.bash
|
||||
lib/preexec.bash
|
||||
lib/preview.bash
|
||||
lib/search.bash
|
||||
lib/utilities.bash
|
||||
|
||||
# plugins
|
||||
#
|
||||
plugins/available/alias-completion.plugin.bash
|
||||
plugins/available/autojump.plugin.bash
|
||||
plugins/available/base.plugin.bash
|
||||
plugins/available/basher.plugin.bash
|
||||
plugins/available/battery.plugin.bash
|
||||
plugins/available/blesh.plugin.bash
|
||||
plugins/available/cmd-returned-notify.plugin.bash
|
||||
plugins/available/colors.plugin.bash
|
||||
plugins/available/direnv.plugin.bash
|
||||
plugins/available/dirs.plugin.bash
|
||||
plugins/available/docker-machine.plugin.bash
|
||||
plugins/available/gif.plugin.bash
|
||||
plugins/available/git-subrepo.plugin.bash
|
||||
plugins/available/git.plugin.bash
|
||||
plugins/available/go.plugin.bash
|
||||
plugins/available/goenv.plugin.bash
|
||||
plugins/available/history-eternal.plugin.bash
|
||||
plugins/available/history-search.plugin.bash
|
||||
plugins/available/history-substring-search.plugin.bash
|
||||
plugins/available/history.plugin.bash
|
||||
plugins/available/hub.plugin.bash
|
||||
plugins/available/java.plugin.bash
|
||||
plugins/available/jekyll.plugin.bash
|
||||
plugins/available/jump.plugin.bash
|
||||
plugins/available/latex.plugin.bash
|
||||
plugins/available/less-pretty-cat.plugin.bash
|
||||
plugins/available/man.plugin.bash
|
||||
plugins/available/nginx.plugin.bash
|
||||
plugins/available/node.plugin.bash
|
||||
plugins/available/nodenv.plugin.bash
|
||||
plugins/available/osx-timemachine.plugin.bash
|
||||
plugins/available/osx.plugin.bash
|
||||
plugins/available/percol.plugin.bash
|
||||
plugins/available/plenv.plugin.bash
|
||||
plugins/available/projects.plugin.bash
|
||||
plugins/available/proxy.plugin.bash
|
||||
plugins/available/pyenv.plugin.bash
|
||||
plugins/available/python.plugin.bash
|
||||
plugins/available/rbenv.plugin.bash
|
||||
plugins/available/ruby.plugin.bash
|
||||
plugins/available/textmate.plugin.bash
|
||||
plugins/available/todo.plugin.bash
|
||||
plugins/available/xterm.plugin.bash
|
||||
plugins/available/zoxide.plugin.bash
|
||||
|
||||
# tests
|
||||
#
|
||||
test/completion/aliases.completion.bats
|
||||
test/run
|
||||
test/test_helper.bash
|
||||
|
||||
# themes
|
||||
#
|
||||
themes/90210
|
||||
themes/agnoster
|
||||
themes/atomic
|
||||
themes/axin
|
||||
themes/bakke
|
||||
themes/barbuk
|
||||
themes/base.theme.bash
|
||||
themes/binaryanomaly
|
||||
themes/bira
|
||||
themes/bobby
|
||||
themes/bobby-python
|
||||
themes/brainy
|
||||
themes/brunton
|
||||
themes/candy
|
||||
themes/easy
|
||||
themes/essential
|
||||
themes/githelpers.theme.bash
|
||||
themes/modern
|
||||
themes/norbu
|
||||
themes/oh-my-posh
|
||||
themes/p4helpers.theme.bash
|
||||
themes/pete
|
||||
themes/powerline
|
||||
themes/pure
|
||||
themes/purity
|
||||
|
||||
# vendor init files
|
||||
#
|
||||
vendor/.gitattributes
|
||||
112
dot_bash_it/completion/available/aliases.completion.bash
Normal file
112
dot_bash_it/completion/available/aliases.completion.bash
Normal file
@@ -0,0 +1,112 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'Automatic completion of aliases'
|
||||
# Load after all aliases and completions to understand what needs to be completed
|
||||
# BASH_IT_LOAD_PRIORITY: 800
|
||||
|
||||
# References:
|
||||
# http://superuser.com/a/437508/119764
|
||||
# http://stackoverflow.com/a/1793178/1228454
|
||||
|
||||
# Automatically add completion for all aliases to commands having completion functions
|
||||
function _bash-it-component-completion-callback-on-init-aliases() {
|
||||
local namespace="alias_completion"
|
||||
local tmp_file completion_loader alias_name line completions chars
|
||||
local alias_arg_words new_completion compl_func compl_wrapper alias_defn
|
||||
|
||||
# create array of function completion triggers, keeping multi-word triggers together
|
||||
IFS=$'\n' read -d '' -ra completions < <(complete -p)
|
||||
((${#completions[@]} == 0)) && return 0
|
||||
|
||||
completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s)
|
||||
completions=("${completions[@]#complete -}") # strip anything missed
|
||||
completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s)
|
||||
completions=("${completions[@]#? }") # strip anything missed
|
||||
#TODO: this will fail on some completions...
|
||||
|
||||
# create temporary file for wrapper functions and completions
|
||||
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
|
||||
|
||||
IFS=$'\n' read -r completion_loader < <(complete -p -D 2> /dev/null)
|
||||
if [[ "${completion_loader#complete }" =~ '-F'[[:space:]]([[:alnum:]_]+)[[:space:]] ]]; then
|
||||
completion_loader="${BASH_REMATCH[1]}"
|
||||
else
|
||||
completion_loader=""
|
||||
fi
|
||||
|
||||
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
|
||||
# some aliases do have backslashes that needs to be interpreted
|
||||
# shellcheck disable=SC2162
|
||||
while read line; do
|
||||
line="${line#alias -- }"
|
||||
line="${line#alias }"
|
||||
alias_name="${line%%=*}"
|
||||
alias_defn="${line#*=\'}" # alias definition
|
||||
alias_defn="${alias_defn%\'}"
|
||||
alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias
|
||||
if [[ ${alias_defn} == ${alias_cmd} ]]; then
|
||||
alias_args=''
|
||||
else
|
||||
alias_args="${alias_defn#*[[:space:]]}" # everything after first word
|
||||
fi
|
||||
|
||||
# skip aliases to pipes, boolean control structures and other command lists
|
||||
chars='\|\&\;\)\(\n\<\>'
|
||||
if [[ "${alias_defn}" =~ [$chars] ]]; then
|
||||
continue
|
||||
fi
|
||||
# avoid expanding wildcards
|
||||
read -ra alias_arg_words <<< "$alias_args"
|
||||
|
||||
# skip alias if there is no completion function triggered by the aliased command
|
||||
if ! _bash-it-array-contains-element "$alias_cmd" "${completions[@]}"; then
|
||||
if [[ -n "$completion_loader" ]]; then
|
||||
# force loading of completions for the aliased command
|
||||
"${completion_loader:?}" "${alias_cmd}"
|
||||
# 124 means completion loader was successful
|
||||
[[ $? -eq 124 ]] || continue
|
||||
completions+=("$alias_cmd")
|
||||
else
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
|
||||
|
||||
# create a wrapper inserting the alias arguments if any
|
||||
if [[ -n $alias_args ]]; then
|
||||
compl_func="${new_completion/#* -F /}"
|
||||
compl_func="${compl_func%% *}"
|
||||
# avoid recursive call loops by ignoring our own functions
|
||||
if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then
|
||||
compl_wrapper="_${namespace}::${alias_name}"
|
||||
echo "function $compl_wrapper {
|
||||
local compl_word=\${2?}
|
||||
local prec_word=\${3?}
|
||||
# check if prec_word is the alias itself. if so, replace it
|
||||
# with the last word in the unaliased form, i.e.,
|
||||
# alias_cmd + ' ' + alias_args.
|
||||
if [[ \$COMP_LINE == \"\$prec_word \$compl_word\" ]]; then
|
||||
prec_word='$alias_cmd $alias_args'
|
||||
prec_word=\${prec_word#* }
|
||||
fi
|
||||
(( COMP_CWORD += ${#alias_arg_words[@]} ))
|
||||
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\")
|
||||
(( COMP_POINT -= \${#COMP_LINE} ))
|
||||
COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args}
|
||||
(( COMP_POINT += \${#COMP_LINE} ))
|
||||
\"$compl_func\" \"$alias_cmd\" \"\$compl_word\" \"\$prec_word\"
|
||||
}" >> "$tmp_file"
|
||||
new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }"
|
||||
fi
|
||||
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)
|
||||
# shellcheck source=/dev/null
|
||||
source "$tmp_file" && command rm -f "$tmp_file"
|
||||
}
|
||||
|
||||
_bash-it-component-completion-callback-on-init-aliases
|
||||
4
dot_bash_it/completion/available/apm.completion.bash
Normal file
4
dot_bash_it/completion/available/apm.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "apm completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm
|
||||
5
dot_bash_it/completion/available/awless.completion.bash
Normal file
5
dot_bash_it/completion/available/awless.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists awless; then
|
||||
# shellcheck disable=SC1090
|
||||
source <(awless completion bash)
|
||||
fi
|
||||
5
dot_bash_it/completion/available/awscli.completion.bash
Normal file
5
dot_bash_it/completion/available/awscli.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists aws_completer; then
|
||||
complete -C "$(command -v aws_completer)" aws
|
||||
fi
|
||||
95
dot_bash_it/completion/available/bash-it.completion.bash
Normal file
95
dot_bash_it/completion/available/bash-it.completion.bash
Normal file
@@ -0,0 +1,95 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function _compreply_candidates() {
|
||||
local IFS=$'\n'
|
||||
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]}" -- "${cur}")
|
||||
}
|
||||
|
||||
function _bash-it() {
|
||||
local cur prev verb file_type candidates suffix
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
verb="${COMP_WORDS[1]}"
|
||||
file_type="${COMP_WORDS[2]:-}"
|
||||
candidates=('disable' 'enable' 'help' 'migrate' 'reload' 'restart' 'preview' 'profile' 'doctor' 'search' 'show' 'update' 'version')
|
||||
case "${verb}" in
|
||||
show)
|
||||
candidates=('aliases' 'completions' 'plugins')
|
||||
_compreply_candidates
|
||||
;;
|
||||
help)
|
||||
if [[ "${prev}" == "aliases" ]]; then
|
||||
candidates=('all' "$(_bash-it-component-list "${file_type}")")
|
||||
_compreply_candidates
|
||||
else
|
||||
candidates=('aliases' 'completions' 'migrate' 'plugins' 'update')
|
||||
_compreply_candidates
|
||||
fi
|
||||
;;
|
||||
profile)
|
||||
case "${file_type}" in
|
||||
load | rm)
|
||||
if [[ "${file_type}" == "$prev" ]]; then
|
||||
candidates=("${BASH_IT}/profiles"/*.bash_it)
|
||||
candidates=("${candidates[@]##*/}")
|
||||
candidates=("${candidates[@]%%.bash_it}")
|
||||
|
||||
_compreply_candidates
|
||||
fi
|
||||
;;
|
||||
save | list) ;;
|
||||
*)
|
||||
candidates=('load' 'save' 'list' 'rm')
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
doctor)
|
||||
candidates=('errors' 'warnings' 'all')
|
||||
_compreply_candidates
|
||||
;;
|
||||
update)
|
||||
if [[ "${cur}" == -* ]]; then
|
||||
candidates=('-s' '--silent')
|
||||
else
|
||||
candidates=('stable' 'dev')
|
||||
fi
|
||||
_compreply_candidates
|
||||
;;
|
||||
migrate | reload | restart | search | version) ;;
|
||||
preview)
|
||||
_bash-it-preview # completes itself
|
||||
return 0
|
||||
;;
|
||||
enable | disable)
|
||||
if [[ "${verb}" == "enable" ]]; then
|
||||
suffix="disabled"
|
||||
else
|
||||
suffix="enabled"
|
||||
fi
|
||||
case "${file_type}" in
|
||||
alias | completion | plugin)
|
||||
candidates=('all' "$("_bash-it-component-list-${suffix}" "${file_type}")")
|
||||
_compreply_candidates
|
||||
;;
|
||||
*)
|
||||
candidates=('alias' 'completion' 'plugin')
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Activate completion for bash-it and its common misspellings
|
||||
complete -F _bash-it bash-it
|
||||
complete -F _bash-it bash-ti
|
||||
complete -F _bash-it shit
|
||||
complete -F _bash-it bashit
|
||||
complete -F _bash-it batshit
|
||||
complete -F _bash-it bash_it
|
||||
30
dot_bash_it/completion/available/brew.completion.bash
Normal file
30
dot_bash_it/completion/available/brew.completion.bash
Normal file
@@ -0,0 +1,30 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "brew completion"
|
||||
|
||||
# Load late to make sure `system` completion loads first
|
||||
# BASH_IT_LOAD_PRIORITY: 375
|
||||
|
||||
if [[ "$OSTYPE" != 'darwin'* ]]; then
|
||||
_log_warning "unsupported operating system - only 'Darwin' is supported"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Make sure brew is installed
|
||||
_bash_it_homebrew_check || return 0
|
||||
|
||||
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
|
||||
|
||||
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
|
||||
|
||||
elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then
|
||||
# For the git-clone based installation, see here for more info:
|
||||
# https://github.com/Bash-it/bash-it/issues/1458
|
||||
# https://docs.brew.sh/Shell-Completion
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
|
||||
fi
|
||||
273
dot_bash_it/completion/available/bundler.completion.bash
Normal file
273
dot_bash_it/completion/available/bundler.completion.bash
Normal file
@@ -0,0 +1,273 @@
|
||||
#! bash
|
||||
# bash completion for the `bundle` command.
|
||||
#
|
||||
# Copyright (c) 2008 Daniel Luz
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use,
|
||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following
|
||||
# conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# To use, source this file on bash:
|
||||
# . completion-bundle
|
||||
|
||||
__bundle() {
|
||||
local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "$1")
|
||||
local cur prev
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local bundle_command
|
||||
local bundle_command_index
|
||||
__bundle_get_command
|
||||
COMPREPLY=()
|
||||
|
||||
local options
|
||||
if [[ $cur = -* && $bundle_command != exec ]]; then
|
||||
options="-V --help --no-color --no-no-color --verbose --no-verbose"
|
||||
case $bundle_command in
|
||||
"")
|
||||
options="$options --version";;
|
||||
check)
|
||||
options="$options --dry-run --gemfile --path -r --retry";;
|
||||
clean)
|
||||
options="$options --dry-run --force";;
|
||||
config)
|
||||
options="$options --local --global --delete";;
|
||||
doctor)
|
||||
options="$options --gemfile --quiet --no-quiet";;
|
||||
gem)
|
||||
options="$options -b -e -t --bin --coc --no-coc --edit --exe
|
||||
--no-exe --ext --no-ext --mit --no-mit --test";;
|
||||
init)
|
||||
options="$options --gemspec";;
|
||||
install)
|
||||
options="$options --binstubs --clean --deployment --force --frozen
|
||||
--full-index --gemfile --jobs --local --no-cache
|
||||
--no-prune --path --quiet --retry --shebang --standalone
|
||||
--system --trust-policy --with --without";;
|
||||
lock)
|
||||
options="$options --add-platform --conservative --full-index
|
||||
--local --lockfile --major --minor --patch --print
|
||||
--remove-platform --strict --update";;
|
||||
package)
|
||||
options="$options --all --all-platforms";;
|
||||
platform)
|
||||
options="$options --ruby";;
|
||||
show)
|
||||
options="$options --outdated --paths --no-paths";;
|
||||
update)
|
||||
options="$options --bundler --conservative --force --full-index
|
||||
--group --jobs --local --major --minor --patch --quiet
|
||||
--ruby --source --strict";;
|
||||
viz)
|
||||
options="$options -f -F -R -v -W --file --format --requirements
|
||||
--no-requirements --version --no-version --without";;
|
||||
esac
|
||||
else
|
||||
case $bundle_command in
|
||||
"" | help)
|
||||
options="help install update package exec config
|
||||
check show outdated console open lock viz init gem
|
||||
platform clean doctor"
|
||||
;;
|
||||
check | install)
|
||||
case $prev in
|
||||
--binstubs | --path)
|
||||
_filedir -d
|
||||
return;;
|
||||
--standalone | --with | --without)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
--trust-policy)
|
||||
options="HighSecurity MediumSecurity LowSecurity
|
||||
AlmostNoSecurity NoSecurity";;
|
||||
esac
|
||||
;;
|
||||
config)
|
||||
case $prev in
|
||||
config | --*)
|
||||
case $cur in
|
||||
local.*)
|
||||
options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys'))
|
||||
options=("${options[*]/#/local.}")
|
||||
;;
|
||||
*)
|
||||
options=(path frozen without bin gemfile ssl_ca_cert
|
||||
ssl_client_cert cache_path disable_multisource
|
||||
ignore_messages retry redirect timeout
|
||||
force_ruby_platform specific_platform
|
||||
disable_checksum_validation disable_version_check
|
||||
allow_offline_install auto_install
|
||||
cache_all_platforms cache_all clean console
|
||||
disable_exec_load disable_local_branch_check
|
||||
disable_shared_gems jobs major_deprecations
|
||||
no_install no_prune only_update_to_newer_versions
|
||||
plugins shebang silence_root_warning
|
||||
ssl_verify_mode system_bindir user_agent)
|
||||
# We want to suggest the options above as complete words,
|
||||
# and also "local." and "mirror." as prefixes
|
||||
# To achieve that, disable automatic space insertion,
|
||||
# insert it manually, then add the non-spaced prefixes
|
||||
compopt -o nospace
|
||||
options=("${options[@]/%/ }")
|
||||
# And add prefix suggestions
|
||||
options+=(local. mirror.)
|
||||
# Override $IFS for completion to work
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=($(compgen -W '${options[@]}' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
path | local.*)
|
||||
_filedir -d
|
||||
return;;
|
||||
esac
|
||||
;;
|
||||
exec)
|
||||
if [[ $COMP_CWORD -eq $bundle_command_index ]]; then
|
||||
# Figure out Bundler's binaries dir
|
||||
local bundler_bin=$(__bundle_exec_ruby 'puts Bundler.bundle_path + "bin"')
|
||||
if [[ -d $bundler_bin ]]; then
|
||||
local binaries=("$bundler_bin"/*)
|
||||
# If there are binaries, strip directory name and use them
|
||||
[[ -f "$binaries" ]] && options="${binaries[@]##*/}"
|
||||
else
|
||||
# No binaries found; use full command completion
|
||||
COMPREPLY=($(compgen -c -- "$cur"))
|
||||
return
|
||||
fi
|
||||
else
|
||||
local _RUBY_COMMAND_PREFIX=("${bundle_bin[@]}" exec)
|
||||
_command_offset $bundle_command_index
|
||||
return
|
||||
fi
|
||||
;;
|
||||
gem)
|
||||
case $prev in
|
||||
-e | --edit)
|
||||
COMPREPLY=($(compgen -c -- "$cur"))
|
||||
return;;
|
||||
-t | --test)
|
||||
options="minitest rspec";;
|
||||
esac
|
||||
;;
|
||||
update)
|
||||
case $prev in
|
||||
--group)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
*)
|
||||
options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys'))
|
||||
esac
|
||||
;;
|
||||
viz)
|
||||
case $prev in
|
||||
-F | --format)
|
||||
options="dot jpg png svg";;
|
||||
-W | --without)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "${options[*]}" -- "$cur"))
|
||||
}
|
||||
|
||||
__bundle_get_command() {
|
||||
local i
|
||||
for ((i=1; i < $COMP_CWORD; ++i)); do
|
||||
local arg=${COMP_WORDS[$i]}
|
||||
|
||||
case $arg in
|
||||
[^-]*)
|
||||
bundle_command=$arg
|
||||
bundle_command_index=$((i + 1))
|
||||
return;;
|
||||
--version)
|
||||
# Command-killer
|
||||
bundle_command=-
|
||||
return;;
|
||||
--help)
|
||||
bundle_command=help
|
||||
bundle_command_index=$((i + 1))
|
||||
return;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Provides completion for Bundler group names.
|
||||
#
|
||||
# Multiple groups can be entered, separated either by spaces or by colons.
|
||||
# Input is read from $cur, and the result is directly written to $COMPREPLY.
|
||||
__bundle_complete_groups() {
|
||||
# Group being currently written
|
||||
local cur_group=${cur##*[ :]}
|
||||
# All groups written before
|
||||
local prefix=${cur%"$cur_group"}
|
||||
local groups=$(__bundle_exec_ruby 'puts Bundler.definition.dependencies.map(&:groups).reduce(:|).map(&:to_s)')
|
||||
if [[ ! $groups ]]; then
|
||||
COMPREPLY=()
|
||||
return
|
||||
fi
|
||||
# Duplicate "default" and anything already in $prefix, so that `uniq`
|
||||
# strips it; groups may be separated by ':', ' ', or '\ '
|
||||
local excluded=$'\ndefault\n'${prefix//[: \'\"\\]/$'\n'}
|
||||
# Include them twice to ensure they are duplicates
|
||||
groups=$groups$excluded$excluded
|
||||
COMPREPLY=($(compgen -W "$(sort <<<"$groups" | uniq -u)" -- "$cur_group"))
|
||||
# Prepend prefix to all entries
|
||||
COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
|
||||
__ltrim_colon_completions "$cur"
|
||||
}
|
||||
|
||||
# __bundle_exec_ruby <script> [args...]
|
||||
#
|
||||
# Runs a Ruby script with Bundler loaded.
|
||||
# Results may be cached.
|
||||
__bundle_exec_ruby() {
|
||||
local bundle_bin=(${bundle_bin[@]:-bundle})
|
||||
# Lockfile is inferred here, and might not be correct (for example, when
|
||||
# running on a subdirectory). However, a wrong file path won't be a
|
||||
# cadastrophic mistake; it just means the cache won't be invalidated when
|
||||
# the local gem list changes (but will still invalidate if the command is
|
||||
# run on another directory)
|
||||
local lockfile=$PWD/Gemfile.lock
|
||||
local cachedir=${XDG_CACHE_HOME:-~/.cache}/completion-ruby
|
||||
local cachefile=$cachedir/bundle--exec-ruby
|
||||
# A representation of all arguments with newlines replaced by spaces,
|
||||
# to fit in a single line as a cache identifier
|
||||
local cache_id_line="${bundle_bin[*]} @ $lockfile: ${*//$'\n'/ }"
|
||||
|
||||
if [[ (! -f $lockfile || $cachefile -nt $lockfile) &&
|
||||
$(head -n 1 -- "$cachefile" 2>/dev/null) = "$cache_id_line" ]]; then
|
||||
tail -n +2 -- "$cachefile"
|
||||
else
|
||||
local output=$("${bundle_bin[@]}" exec ruby -e "$@" 2>/dev/null)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
(mkdir -p -- "$cachedir" &&
|
||||
echo "$cache_id_line"$'\n'"$output" >$cachefile) 2>/dev/null
|
||||
echo "$output"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
complete -F __bundle -o bashdefault -o default bundle
|
||||
# vim: ai ft=sh sw=4 sts=4 et
|
||||
24
dot_bash_it/completion/available/capistrano.completion.bash
Normal file
24
dot_bash_it/completion/available/capistrano.completion.bash
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for Capistrano.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_capcomplete() {
|
||||
if [ -f Capfile ]; then
|
||||
recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1`
|
||||
if [[ $recent != '.cap_tasks~' ]]; then
|
||||
cap --version | grep 'Capistrano v2.' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Capistrano 2.x
|
||||
cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~
|
||||
else
|
||||
# Capistrano 3.x
|
||||
cap --all --tasks | cut -d " " -f 2 > .cap_tasks~
|
||||
fi
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _capcomplete cap
|
||||
6
dot_bash_it/completion/available/cargo.completion.bash
Normal file
6
dot_bash_it/completion/available/cargo.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# cargo (Rust package manager) completion
|
||||
|
||||
if _binary_exists rustup && _binary_exists cargo; then
|
||||
eval "$(rustup completions bash cargo)"
|
||||
fi
|
||||
129
dot_bash_it/completion/available/composer.completion.bash
Normal file
129
dot_bash_it/completion/available/composer.completion.bash
Normal file
@@ -0,0 +1,129 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "composer completion"
|
||||
|
||||
function __composer_completion() {
|
||||
local cur coms opts com words
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur words
|
||||
|
||||
# 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
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
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"
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
|
||||
__ltrim_colon_completions "${cur}"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F __composer_completion composer
|
||||
11
dot_bash_it/completion/available/conda.completion.bash
Normal file
11
dot_bash_it/completion/available/conda.completion.bash
Normal file
@@ -0,0 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "conda completion"
|
||||
|
||||
if _command_exists conda; then
|
||||
if _command_exists register-python-argcomplete; then
|
||||
eval "$(register-python-argcomplete conda)"
|
||||
else
|
||||
_log_warning "Argcomplete not found. Please run 'conda install argcomplete'"
|
||||
fi
|
||||
fi
|
||||
7
dot_bash_it/completion/available/consul.completion.bash
Normal file
7
dot_bash_it/completion/available/consul.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "Hashicorp consul completion"
|
||||
|
||||
if _command_exists consul; then
|
||||
complete -C "$(command -v consul)" consul
|
||||
fi
|
||||
1
dot_bash_it/completion/available/crystal.completion.bash
Normal file
1
dot_bash_it/completion/available/crystal.completion.bash
Normal file
@@ -0,0 +1 @@
|
||||
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'
|
||||
48
dot_bash_it/completion/available/dart.completion.bash
Normal file
48
dot_bash_it/completion/available/dart.completion.bash
Normal file
@@ -0,0 +1,48 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__dart_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local HELP="--help -h"
|
||||
local VERBOSE="-v --verbose"
|
||||
|
||||
case $prev in
|
||||
analyze)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --fatal-infos --no-fatal-warnings --fatal-warnings" -- "$curr"))
|
||||
;;
|
||||
compile)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP aot-snapshot exe js jit-snapshot kernel" -- "$curr"))
|
||||
;;
|
||||
create)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --template -t --no-pub --pub --force" -- "$curr"))
|
||||
;;
|
||||
-t | --template)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "console-simple console-full package-simple web-simple" -- "$curr"))
|
||||
;;
|
||||
format)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE -o --output --fix -l --line-length" -- "$curr"))
|
||||
;;
|
||||
pub)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --no-trace --trace --verbosity cache deps downgrade get global logout outdated publish run upgrade uploader version" -- "$curr"))
|
||||
;;
|
||||
run)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --observe --enable-vm-service --no-pause-isolates-on-exit --no-pause-isolates-on-unhandled-exceptions --no-warn-on-pause-with-no-debugger --pause-isolates-on-exit --pause-isolates-on-unhandled-exceptions --warn-on-pause-with-no-debugger" -- "$curr"))
|
||||
;;
|
||||
dart)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --enable-analytics --disable-analytics help analyze compile create format pub run test" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dart_completion dart
|
||||
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
|
||||
source "$_"
|
||||
fi
|
||||
15
dot_bash_it/completion/available/dirs.completion.bash
Normal file
15
dot_bash_it/completion/available/dirs.completion.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for the 'dirs' plugin (commands G, R).
|
||||
|
||||
_dirs-complete() {
|
||||
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
# parse all defined shortcuts from ~/.dirs
|
||||
if [ -r "$HOME/.dirs" ]; then
|
||||
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _dirs-complete G R
|
||||
4
dot_bash_it/completion/available/django.completion.bash
Normal file
4
dot_bash_it/completion/available/django.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "django completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/django/django/extras/django_bash_completion
|
||||
22
dot_bash_it/completion/available/dmidecode.completion.bash
Normal file
22
dot_bash_it/completion/available/dmidecode.completion.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function __dmidecode_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
-s | --string | -t | --type)
|
||||
OPTS=$(dmidecode "$prev" 2>&1 | grep -E '^ ' | sed 's/ *//g')
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$OPTS" -- "$curr"))
|
||||
;;
|
||||
dmidecode)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-d --dev-mem -h --help -q --quiet -s --string -t --type -H --handle -u --dump{,-bin} --from-dump --no-sysfs --oem-string -V --version" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dmidecode_completion dmidecode
|
||||
@@ -0,0 +1,3 @@
|
||||
# shellcheck shell=bash
|
||||
_log_warning '"docker-machine" is now deprecated, and as such the bash completion for it is also deprecated.
|
||||
Please disable this completion.'
|
||||
24
dot_bash_it/completion/available/docker.completion.bash
Normal file
24
dot_bash_it/completion/available/docker.completion.bash
Normal file
@@ -0,0 +1,24 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "docker completion"
|
||||
|
||||
# Make sure docker is installed
|
||||
_command_exists docker || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
_completion_exists docker && return
|
||||
|
||||
_docker_bash_completion_paths=(
|
||||
# MacOS
|
||||
'/Applications/Docker.app/Contents/Resources/etc/docker.bash-completion'
|
||||
# Linux
|
||||
'/usr/share/bash-completion/completions/docker'
|
||||
)
|
||||
|
||||
for fn in "${_docker_bash_completion_paths[@]}"; do
|
||||
if [ -r "$fn" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$fn"
|
||||
break
|
||||
fi
|
||||
done
|
||||
14
dot_bash_it/completion/available/dotnet.completion.bash
Normal file
14
dot_bash_it/completion/available/dotnet.completion.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "bash parameter completion for the dotnet CLI"
|
||||
# see https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash
|
||||
|
||||
function _dotnet_bash_complete() {
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
|
||||
local candidates
|
||||
|
||||
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2> /dev/null)
|
||||
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
|
||||
}
|
||||
|
||||
complete -f -F _dotnet_bash_complete dotnet
|
||||
2
dot_bash_it/completion/available/drush.completion.bash
Normal file
2
dot_bash_it/completion/available/drush.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
|
||||
Please disable this completion and use the instructions from "drush" developers instead.'
|
||||
@@ -0,0 +1,688 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Copyright (c) 2014 Docker, Inc
|
||||
|
||||
# bash completion for docker-compose
|
||||
#
|
||||
# This work is based on the completion for the docker command.
|
||||
#
|
||||
# This script provides completion of:
|
||||
# - commands and their options
|
||||
# - service names
|
||||
# - filepaths
|
||||
#
|
||||
# To enable the completions either:
|
||||
# - place this file in /etc/bash_completion.d
|
||||
# or
|
||||
# - copy this file to e.g. ~/.docker-compose-completion.sh and add the line
|
||||
# below to your .bashrc after bash completion features are loaded
|
||||
# . ~/.docker-compose-completion.sh
|
||||
|
||||
__docker_compose_previous_extglob_setting=$(shopt -p extglob)
|
||||
shopt -s extglob
|
||||
|
||||
__docker_compose_q() {
|
||||
docker-compose 2>/dev/null "${top_level_options[@]}" "$@"
|
||||
}
|
||||
|
||||
# Transforms a multiline list of strings into a single line string
|
||||
# with the words separated by "|".
|
||||
__docker_compose_to_alternatives() {
|
||||
local parts=( $1 )
|
||||
local IFS='|'
|
||||
echo "${parts[*]}"
|
||||
}
|
||||
|
||||
# Transforms a multiline list of options into an extglob pattern
|
||||
# suitable for use in case statements.
|
||||
__docker_compose_to_extglob() {
|
||||
local extglob=$( __docker_compose_to_alternatives "$1" )
|
||||
echo "@($extglob)"
|
||||
}
|
||||
|
||||
# Determines whether the option passed as the first argument exist on
|
||||
# the commandline. The option may be a pattern, e.g. `--force|-f`.
|
||||
__docker_compose_has_option() {
|
||||
local pattern="$1"
|
||||
for (( i=2; i < $cword; ++i)); do
|
||||
if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Returns `key` if we are currently completing the value of a map option (`key=value`)
|
||||
# which matches the extglob passed in as an argument.
|
||||
# This function is needed for key-specific completions.
|
||||
__docker_compose_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
|
||||
return
|
||||
fi
|
||||
|
||||
[ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
|
||||
|
||||
[[ ${words[$glob_pos]} == @($glob) ]] && echo "$key"
|
||||
}
|
||||
|
||||
# suppress trailing whitespace
|
||||
__docker_compose_nospace() {
|
||||
# compopt is not available in ancient bash versions
|
||||
type compopt &>/dev/null && compopt -o nospace
|
||||
}
|
||||
|
||||
|
||||
# Outputs a list of all defined services, regardless of their running state.
|
||||
# Arguments for `docker-compose ps` may be passed in order to filter the service list,
|
||||
# e.g. `status=running`.
|
||||
__docker_compose_services() {
|
||||
__docker_compose_q ps --services "$@"
|
||||
}
|
||||
|
||||
# Applies completion of services based on the current value of `$cur`.
|
||||
# Arguments for `docker-compose ps` may be passed in order to filter the service list,
|
||||
# see `__docker_compose_services`.
|
||||
__docker_compose_complete_services() {
|
||||
COMPREPLY=( $(compgen -W "$(__docker_compose_services "$@")" -- "$cur") )
|
||||
}
|
||||
|
||||
# The services for which at least one running container exists
|
||||
__docker_compose_complete_running_services() {
|
||||
local names=$(__docker_compose_services --filter status=running)
|
||||
COMPREPLY=( $(compgen -W "$names" -- "$cur") )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_build() {
|
||||
case "$prev" in
|
||||
--build-arg)
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--memory|-m)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--build-arg --compress --force-rm --help --memory -m --no-cache --no-rm --pull --parallel -q --quiet" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter source=build
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_bundle() {
|
||||
case "$prev" in
|
||||
--output|-o)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $( compgen -W "--push-images --help --output -o" -- "$cur" ) )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_config() {
|
||||
case "$prev" in
|
||||
--hash)
|
||||
if [[ $cur == \\* ]] ; then
|
||||
COMPREPLY=( '\*' )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$(__docker_compose_services) \\\* " -- "$cur") )
|
||||
fi
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $( compgen -W "--hash --help --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_create() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--build --force-recreate --help --no-build --no-recreate" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_docker_compose() {
|
||||
case "$prev" in
|
||||
--tlscacert|--tlscert|--tlskey)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--file|-f)
|
||||
_filedir "y?(a)ml"
|
||||
return
|
||||
;;
|
||||
--log-level)
|
||||
COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--project-directory)
|
||||
_filedir -d
|
||||
return
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$daemon_options_with_args") )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "$daemon_boolean_options $daemon_options_with_args $top_level_options_with_args --help -h --no-ansi --verbose --version -v" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_down() {
|
||||
case "$prev" in
|
||||
--rmi)
|
||||
COMPREPLY=( $( compgen -W "all local" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --rmi --timeout -t --volumes -v --remove-orphans" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_events() {
|
||||
case "$prev" in
|
||||
--json)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --json" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_exec() {
|
||||
case "$prev" in
|
||||
--index|--user|-u|--workdir|-w)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "-d --detach --help --index --privileged -T --user -u --workdir -w" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_help() {
|
||||
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_docker_compose_images() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_docker_compose_kill() {
|
||||
case "$prev" in
|
||||
-s)
|
||||
COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help -s" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_logs() {
|
||||
case "$prev" in
|
||||
--tail)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--follow -f --help --no-color --tail --timestamps -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_pause() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_port() {
|
||||
case "$prev" in
|
||||
--protocol)
|
||||
COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) )
|
||||
return;
|
||||
;;
|
||||
--index)
|
||||
return;
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --index --protocol" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_ps() {
|
||||
local key=$(__docker_compose_map_key_of_current_option '--filter')
|
||||
case "$key" in
|
||||
source)
|
||||
COMPREPLY=( $( compgen -W "build image" -- "${cur##*=}" ) )
|
||||
return
|
||||
;;
|
||||
status)
|
||||
COMPREPLY=( $( compgen -W "paused restarting running stopped" -- "${cur##*=}" ) )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$prev" in
|
||||
--filter)
|
||||
COMPREPLY=( $( compgen -W "source status" -S "=" -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return;
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--all -a --filter --help --quiet -q --services" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_pull() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures --include-deps --no-parallel --quiet -q" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter source=image
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_push() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_restart() {
|
||||
case "$prev" in
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_rm() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--force -f --help --stop -s -v" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
if __docker_compose_has_option "--stop|-s" ; then
|
||||
__docker_compose_complete_services
|
||||
else
|
||||
__docker_compose_complete_services --filter status=stopped
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_run() {
|
||||
case "$prev" in
|
||||
-e)
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--entrypoint|--label|-l|--name|--user|-u|--volume|-v|--workdir|-w)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--detach -d --entrypoint -e --help --label -l --name --no-deps --publish -p --rm --service-ports -T --use-aliases --user -u --volume -v --workdir -w" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_scale() {
|
||||
case "$prev" in
|
||||
=)
|
||||
COMPREPLY=("$cur")
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") )
|
||||
__docker_compose_nospace
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_start() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter status=stopped
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_stop() {
|
||||
case "$prev" in
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_top() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_unpause() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter status=paused
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_up() {
|
||||
case "$prev" in
|
||||
=)
|
||||
COMPREPLY=("$cur")
|
||||
return
|
||||
;;
|
||||
--exit-code-from)
|
||||
__docker_compose_complete_services
|
||||
return
|
||||
;;
|
||||
--scale)
|
||||
COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--abort-on-container-exit --always-recreate-deps --build -d --detach --exit-code-from --force-recreate --help --no-build --no-color --no-deps --no-recreate --no-start --renew-anon-volumes -V --remove-orphans --scale --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_version() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--short" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose() {
|
||||
local previous_extglob_setting=$(shopt -p extglob)
|
||||
shopt -s extglob
|
||||
|
||||
local commands=(
|
||||
build
|
||||
bundle
|
||||
config
|
||||
create
|
||||
down
|
||||
events
|
||||
exec
|
||||
help
|
||||
images
|
||||
kill
|
||||
logs
|
||||
pause
|
||||
port
|
||||
ps
|
||||
pull
|
||||
push
|
||||
restart
|
||||
rm
|
||||
run
|
||||
scale
|
||||
start
|
||||
stop
|
||||
top
|
||||
unpause
|
||||
up
|
||||
version
|
||||
)
|
||||
|
||||
# Options for the docker daemon that have to be passed to secondary calls to
|
||||
# docker-compose executed by this script.
|
||||
local daemon_boolean_options="
|
||||
--skip-hostname-check
|
||||
--tls
|
||||
--tlsverify
|
||||
"
|
||||
local daemon_options_with_args="
|
||||
--file -f
|
||||
--host -H
|
||||
--project-directory
|
||||
--project-name -p
|
||||
--tlscacert
|
||||
--tlscert
|
||||
--tlskey
|
||||
"
|
||||
|
||||
# These options are require special treatment when searching the command.
|
||||
local top_level_options_with_args="
|
||||
--log-level
|
||||
"
|
||||
|
||||
COMPREPLY=()
|
||||
local cur prev words cword
|
||||
_get_comp_words_by_ref -n : cur prev words cword
|
||||
|
||||
# search subcommand and invoke its handler.
|
||||
# special treatment of some top-level options
|
||||
local command='docker_compose'
|
||||
local top_level_options=()
|
||||
local counter=1
|
||||
|
||||
while [ $counter -lt $cword ]; do
|
||||
case "${words[$counter]}" in
|
||||
$(__docker_compose_to_extglob "$daemon_boolean_options") )
|
||||
local opt=${words[counter]}
|
||||
top_level_options+=($opt)
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$daemon_options_with_args") )
|
||||
local opt=${words[counter]}
|
||||
local arg=${words[++counter]}
|
||||
top_level_options+=($opt $arg)
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$top_level_options_with_args") )
|
||||
(( counter++ ))
|
||||
;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
command="${words[$counter]}"
|
||||
break
|
||||
;;
|
||||
esac
|
||||
(( counter++ ))
|
||||
done
|
||||
|
||||
local completions_func=_docker_compose_${command//-/_}
|
||||
_is_function $completions_func && $completions_func
|
||||
|
||||
eval "$previous_extglob_setting"
|
||||
return 0
|
||||
}
|
||||
|
||||
eval "$__docker_compose_previous_extglob_setting"
|
||||
unset __docker_compose_previous_extglob_setting
|
||||
|
||||
complete -F _docker_compose docker-compose docker-compose.exe
|
||||
1
dot_bash_it/completion/available/export.completion.bash
Normal file
1
dot_bash_it/completion/available/export.completion.bash
Normal file
@@ -0,0 +1 @@
|
||||
complete -o nospace -S = -W '$(printenv | awk -F= "{print \$1}")' export
|
||||
133
dot_bash_it/completion/available/fabric.completion.bash
Normal file
133
dot_bash_it/completion/available/fabric.completion.bash
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Bash completion support for Fabric (http://fabfile.org/)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2011 by Konstantin Bakulin
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
# Thanks to:
|
||||
# - Adam Vandenberg,
|
||||
# https://github.com/adamv/dotfiles/blob/master/completion_scripts/fab_completion.bash
|
||||
#
|
||||
# - Enrico Batista da Luz,
|
||||
# https://github.com/ricobl/dotfiles/blob/master/bin/fab_bash_completion
|
||||
#
|
||||
|
||||
|
||||
# Use cache files for fab tasks or not.
|
||||
# If set to "false" command "fab --shortlist" will be executed every time.
|
||||
export FAB_COMPLETION_CACHE_TASKS=true
|
||||
|
||||
# File name where tasks cache will be stored (in current dir).
|
||||
export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
|
||||
|
||||
|
||||
# Set command to get time of last file modification as seconds since Epoch
|
||||
case "$OSTYPE" in
|
||||
'darwin'*|'freebsd'*)
|
||||
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
|
||||
;;
|
||||
*)
|
||||
__FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# Get time of last fab cache file modification as seconds since Epoch
|
||||
#
|
||||
function __fab_chache_mtime() {
|
||||
${__FAB_COMPLETION_MTIME_COMMAND} \
|
||||
$FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Get time of last fabfile file/module modification as seconds since Epoch
|
||||
#
|
||||
function __fab_fabfile_mtime() {
|
||||
local f="fabfile"
|
||||
if [[ -e "$f.py" ]]; then
|
||||
${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr
|
||||
else
|
||||
# Suppose that it's a fabfile dir
|
||||
find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
|
||||
| xargs -n 1 expr | sort -n -r | head -1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Completion for "fab" command
|
||||
#
|
||||
function __fab_completion() {
|
||||
# Return if "fab" command doesn't exists
|
||||
[[ -e `which fab 2> /dev/null` ]] || return 0
|
||||
|
||||
# Variables to hold the current word and possible matches
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local opts=()
|
||||
|
||||
# Generate possible matches and store them in variable "opts"
|
||||
case "${cur}" in
|
||||
-*)
|
||||
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
|
||||
export __FAB_COMPLETION_LONG_OPT=$(
|
||||
fab --help | egrep -o "\-\-[A-Za-z_\-]+\=?" | sort -u)
|
||||
fi
|
||||
opts="${__FAB_COMPLETION_LONG_OPT}"
|
||||
;;
|
||||
|
||||
# Completion for short options is not nessary.
|
||||
# It's left here just for history.
|
||||
# -*)
|
||||
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
|
||||
# export __FAB_COMPLETION_SHORT_OPT=$(
|
||||
# fab --help | egrep -o "^ +\-[A-Za-z_\]" | sort -u)
|
||||
# fi
|
||||
# opts="${__FAB_COMPLETION_SHORT_OPT}"
|
||||
# ;;
|
||||
|
||||
*)
|
||||
# If "fabfile.py" or "fabfile" dir with "__init__.py" file exists
|
||||
local f="fabfile"
|
||||
if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]]; then
|
||||
# Build a list of the available tasks
|
||||
if $FAB_COMPLETION_CACHE_TASKS; then
|
||||
# If use cache
|
||||
if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} ||
|
||||
$(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then
|
||||
fab --shortlist > ${FAB_COMPLETION_CACHED_TASKS_FILENAME} \
|
||||
2> /dev/null
|
||||
fi
|
||||
opts=$(cat ${FAB_COMPLETION_CACHED_TASKS_FILENAME})
|
||||
else
|
||||
# Without cache
|
||||
opts=$(fab --shortlist 2> /dev/null)
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set possible completions
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
}
|
||||
complete -o default -o nospace -F __fab_completion fab
|
||||
5
dot_bash_it/completion/available/flutter.completion.bash
Normal file
5
dot_bash_it/completion/available/flutter.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if _command_exists flutter; then
|
||||
eval "$(flutter bash-completion)"
|
||||
fi
|
||||
14
dot_bash_it/completion/available/gcloud.completion.bash
Normal file
14
dot_bash_it/completion/available/gcloud.completion.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "Google Cloud SDK completion"
|
||||
|
||||
if _command_exists gcloud; then
|
||||
# get install path
|
||||
GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")}
|
||||
|
||||
# source all the bash completion file that are available
|
||||
for i in "${GOOGLE_SDK_ROOT}"/*.bash.inc; do
|
||||
# shellcheck disable=SC1090
|
||||
source "$i"
|
||||
done
|
||||
fi
|
||||
35
dot_bash_it/completion/available/gem.completion.bash
Normal file
35
dot_bash_it/completion/available/gem.completion.bash
Normal file
@@ -0,0 +1,35 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "gem completion"
|
||||
|
||||
__gem_completion() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
local prev=${COMP_WORDS[COMP_CWORD - 1]}
|
||||
case $prev in
|
||||
install)
|
||||
# list the remote gems and add to completion
|
||||
if [ -z "$REMOTE_GEMS" ]; then
|
||||
read -r -a REMOTE_GEMS <<< "$(gem list --remote --no-versions | sed 's/\*\*\* REMOTE GEMS \*\*\*//' | tr '\n' ' ')"
|
||||
fi
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${REMOTE_GEMS[*]}" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
uninstall)
|
||||
# list all local installed gems and add to completion
|
||||
read -r -a LOCAL_GEMS <<< "$(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ')"
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${LOCAL_GEMS[*]}" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur"))
|
||||
}
|
||||
|
||||
complete -F __gem_completion gem
|
||||
42
dot_bash_it/completion/available/git.completion.bash
Normal file
42
dot_bash_it/completion/available/git.completion.bash
Normal file
@@ -0,0 +1,42 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Locate and load completions for `git`.
|
||||
|
||||
# Make sure git is installed
|
||||
_command_exists git || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
if complete -p git &> /dev/null; then
|
||||
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
|
||||
return 0
|
||||
fi
|
||||
|
||||
_git_bash_completion_xcrun_git=
|
||||
if _command_exists xcrun; then
|
||||
_git_bash_completion_xcrun_git="$(xcrun --find git)"
|
||||
fi
|
||||
_git_bash_completion_paths=(
|
||||
# Standard locations
|
||||
"${GIT_EXE%/*}/../share/git-core/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash"
|
||||
# MacOS non-system locations
|
||||
"${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash"
|
||||
)
|
||||
|
||||
# Load the first completion file found
|
||||
_git_bash_completion_found=false
|
||||
for _comp_path in "${_git_bash_completion_paths[@]}"; do
|
||||
if [[ -r "$_comp_path" ]]; then
|
||||
_git_bash_completion_found=true
|
||||
# shellcheck disable=SC1090 # don't follow
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "${_git_bash_completion_found}" == false ]]; then
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
fi
|
||||
unset "${!_git_bash_completion@}"
|
||||
178
dot_bash_it/completion/available/git_flow.completion.bash
Normal file
178
dot_bash_it/completion/available/git_flow.completion.bash
Normal file
@@ -0,0 +1,178 @@
|
||||
#!bash
|
||||
#
|
||||
# git-flow-completion
|
||||
# ===================
|
||||
#
|
||||
# Bash completion support for [git-flow](http://github.com/nvie/gitflow)
|
||||
#
|
||||
# The contained completion routines provide support for completing:
|
||||
#
|
||||
# * git-flow init and version
|
||||
# * feature, hotfix and release branches
|
||||
# * remote feature branch names (for `git-flow feature track`)
|
||||
#
|
||||
#
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# To achieve git-flow completion nirvana:
|
||||
#
|
||||
# 0. Install git-completion.
|
||||
#
|
||||
# 1. Install this file. Either:
|
||||
#
|
||||
# a. Place it in a `bash-completion.d` folder:
|
||||
#
|
||||
# * /etc/bash-completion.d
|
||||
# * /usr/local/etc/bash-completion.d
|
||||
# * ~/bash-completion.d
|
||||
#
|
||||
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in
|
||||
# your .bashrc:
|
||||
#
|
||||
# source ~/.git-flow-completion.sh
|
||||
#
|
||||
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant
|
||||
# $command case in _git:
|
||||
#
|
||||
# flow) _git_flow ;;
|
||||
#
|
||||
#
|
||||
# The Fine Print
|
||||
# --------------
|
||||
#
|
||||
# Copyright (c) 2010 [Justin Hileman](http://justinhileman.com)
|
||||
#
|
||||
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||
|
||||
_git_flow ()
|
||||
{
|
||||
local subcommands="init feature release hotfix"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_feature ()
|
||||
{
|
||||
local subcommands="list start finish publish track diff rebase checkout pull"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout|finish|diff|rebase)
|
||||
__gitcomp "$(__git_flow_list_features)"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp "$(comm -23 <(__git_flow_list_features) <(__git_flow_list_remote_features))"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp "$(__git_flow_list_remote_features)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_features ()
|
||||
{
|
||||
git flow feature list 2> /dev/null | tr -d ' |*'
|
||||
}
|
||||
|
||||
__git_flow_list_remote_features ()
|
||||
{
|
||||
git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
|
||||
}
|
||||
|
||||
__git_flow_feature_prefix ()
|
||||
{
|
||||
git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
|
||||
}
|
||||
|
||||
__git_flow_release ()
|
||||
{
|
||||
local subcommands="list start finish"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
__gitcomp "$(__git_flow_list_releases)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
__git_flow_list_releases ()
|
||||
{
|
||||
git flow release list 2> /dev/null
|
||||
}
|
||||
|
||||
__git_flow_hotfix ()
|
||||
{
|
||||
local subcommands="list start finish"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
__gitcomp "$(__git_flow_list_hotfixes)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_hotfixes ()
|
||||
{
|
||||
git flow hotfix list 2> /dev/null
|
||||
}
|
||||
|
||||
# temporarily wrap __git_find_on_cmdline() for backwards compatibility
|
||||
if ! _command_exists __git_find_subcommand
|
||||
then
|
||||
alias __git_find_subcommand=__git_find_on_cmdline
|
||||
fi
|
||||
511
dot_bash_it/completion/available/git_flow_avh.completion.bash
Normal file
511
dot_bash_it/completion/available/git_flow_avh.completion.bash
Normal file
@@ -0,0 +1,511 @@
|
||||
#!bash
|
||||
#
|
||||
# git-flow-completion
|
||||
# ===================
|
||||
#
|
||||
# Bash completion support for [git-flow (AVH Edition)](http://github.com/petervanderdoes/gitflow)
|
||||
#
|
||||
# The contained completion routines provide support for completing:
|
||||
#
|
||||
# * git-flow init and version
|
||||
# * feature, hotfix and release branches
|
||||
# * remote feature, hotfix and release branch names
|
||||
#
|
||||
#
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# To achieve git-flow completion nirvana:
|
||||
#
|
||||
# 0. Install git-completion.
|
||||
#
|
||||
# 1. Install this file. Either:
|
||||
#
|
||||
# a. Place it in a `bash-completion.d` folder:
|
||||
#
|
||||
# * /etc/bash-completion.d
|
||||
# * /usr/local/etc/bash-completion.d
|
||||
# * ~/bash-completion.d
|
||||
#
|
||||
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in
|
||||
# your .bashrc:
|
||||
#
|
||||
# source ~/.git-flow-completion.sh
|
||||
#
|
||||
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant
|
||||
# $command case in _git:
|
||||
#
|
||||
# flow) _git_flow ;;
|
||||
#
|
||||
#
|
||||
# The Fine Print
|
||||
# --------------
|
||||
#
|
||||
# Author:
|
||||
# Copyright 2012-2013 Peter van der Does.
|
||||
#
|
||||
# Original Author:
|
||||
# Copyright (c) 2011 [Justin Hileman](http://justinhileman.com)
|
||||
#
|
||||
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||
|
||||
__git_flow_config_file_options="
|
||||
--local --global --system --file=
|
||||
"
|
||||
|
||||
_git_flow ()
|
||||
{
|
||||
local subcommands="init feature release hotfix support help version config finish delete publish rebase"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
init)
|
||||
__git_flow_init
|
||||
return
|
||||
;;
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
support)
|
||||
__git_flow_support
|
||||
return
|
||||
;;
|
||||
config)
|
||||
__git_flow_config
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_init ()
|
||||
{
|
||||
local subcommands="help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
fi
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nodefaults --defaults
|
||||
--noforce --force
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_feature ()
|
||||
{
|
||||
local subcommands="list start finish publish track diff rebase checkout pull help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp_nl "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--norebase --rebase
|
||||
--nopreserve-merges --preserve-merges
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--nosquash --squash
|
||||
--no-ff
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
diff)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_release ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
--nosquash --squash
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
__git_flow_hotfix ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_support ()
|
||||
{
|
||||
local subcommands="list start help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'support')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_config ()
|
||||
{
|
||||
local subcommands="list set base"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
set)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp "
|
||||
master develop
|
||||
feature hotfix release support
|
||||
versiontagprefix
|
||||
"
|
||||
return
|
||||
;;
|
||||
base)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
set get
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_prefix ()
|
||||
{
|
||||
case "$1" in
|
||||
feature|release|hotfix|support)
|
||||
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_local_branches ()
|
||||
{
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref#$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
__git_flow_list_remote_branches ()
|
||||
{
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
}
|
||||
|
||||
__git_flow_list_branches ()
|
||||
{
|
||||
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
|
||||
if [ -n "$1" ]; then
|
||||
local prefix="$(__git_flow_prefix $1)"
|
||||
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
|
||||
fi
|
||||
}
|
||||
|
||||
# alias __git_find_on_cmdline for backwards compatibility
|
||||
if ! _command_exists __git_find_on_cmdline
|
||||
then
|
||||
alias __git_find_on_cmdline=__git_find_subcommand
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "GitHub CLI completion"
|
||||
|
||||
if _binary_exists gh; then
|
||||
# If gh already completed, stop
|
||||
_completion_exists gh && return
|
||||
eval "$(gh completion --shell=bash)"
|
||||
fi
|
||||
15
dot_bash_it/completion/available/go.completion.bash
Normal file
15
dot_bash_it/completion/available/go.completion.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "completion for go command using gocomplete"
|
||||
|
||||
# bash completion for go tool
|
||||
# https://github.com/posener/complete
|
||||
|
||||
# Test `go version` because goenv creates shim scripts that will be found in PATH
|
||||
# but do not always resolve to a working install.
|
||||
if _command_exists go && go version &> /dev/null; then
|
||||
# Same idea here, but no need to test a subcommand
|
||||
if _command_exists gocomplete && gocomplete &> /dev/null; then
|
||||
# finally, apply completion
|
||||
complete -C gocomplete go
|
||||
fi
|
||||
fi
|
||||
316
dot_bash_it/completion/available/gradle.completion.bash
Normal file
316
dot_bash_it/completion/available/gradle.completion.bash
Normal file
@@ -0,0 +1,316 @@
|
||||
# Copyright (c) 2017 Eric Wendelin
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Bash breaks words on : by default. Subproject tasks have ':'
|
||||
# Avoid inaccurate completions for subproject tasks
|
||||
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
|
||||
|
||||
function __gradle-set-project-root-dir() {
|
||||
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
__gradle-init-cache-dir() {
|
||||
cache_dir="$HOME/.gradle/completion"
|
||||
mkdir -p $cache_dir
|
||||
}
|
||||
|
||||
__gradle-set-build-file() {
|
||||
# Look for default build script in the settings file (settings.gradle by default)
|
||||
# Otherwise, default is the file 'build.gradle' in the current directory.
|
||||
gradle_build_file="$project_root_dir/build.gradle"
|
||||
if [[ -f "$project_root_dir/settings.gradle" ]]; then
|
||||
local build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" | \
|
||||
sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")
|
||||
gradle_build_file="$project_root_dir/${build_file_name:-build.gradle}"
|
||||
fi
|
||||
}
|
||||
|
||||
__gradle-set-cache-name() {
|
||||
# Cache name is constructed from the absolute path of the build file.
|
||||
cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g')
|
||||
}
|
||||
|
||||
__gradle-set-files-checksum() {
|
||||
# Cache MD5 sum of all Gradle scripts and modified timestamps
|
||||
if _command_exists md5; then
|
||||
gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)")
|
||||
elif _command_exists md5sum; then
|
||||
gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}')
|
||||
else
|
||||
echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
__gradle-generate-script-cache() {
|
||||
# Invalidate cache after 3 weeks by default
|
||||
local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
|
||||
local script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"}
|
||||
|
||||
if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then
|
||||
# Cache all Gradle scripts
|
||||
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern")
|
||||
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
|
||||
fi
|
||||
}
|
||||
|
||||
__gradle-long-options() {
|
||||
local args="--build-cache - Enables the Gradle build cache
|
||||
--build-file - Specifies the build file
|
||||
--configure-on-demand - Only relevant projects are configured
|
||||
--console - Type of console output to generate (plain auto rich)
|
||||
--continue - Continues task execution after a task failure
|
||||
--continuous - Continuous mode. Automatically re-run build after changes
|
||||
--daemon - Use the Gradle Daemon
|
||||
--debug - Log at the debug level
|
||||
--dry-run - Runs the build with all task actions disabled
|
||||
--exclude-task - Specify a task to be excluded
|
||||
--full-stacktrace - Print out the full (very verbose) stacktrace
|
||||
--gradle-user-home - Specifies the Gradle user home directory
|
||||
--gui - Launches the Gradle GUI app (Deprecated)
|
||||
--help - Shows a help message
|
||||
--include-build - Run the build as a composite, including the specified build
|
||||
--info - Set log level to INFO
|
||||
--init-script - Specifies an initialization script
|
||||
--max-workers - Set the maximum number of workers that Gradle may use
|
||||
--no-build-cache - Do not use the Gradle build cache
|
||||
--no-daemon - Do not use the Gradle Daemon
|
||||
--no-rebuild - Do not rebuild project dependencies
|
||||
--no-scan - Do not create a build scan
|
||||
--no-search-upwards - Do not search in parent directories for a settings.gradle
|
||||
--offline - Build without accessing network resources
|
||||
--parallel - Build projects in parallel
|
||||
--profile - Profile build time and create report
|
||||
--project-cache-dir - Specifies the project-specific cache directory
|
||||
--project-dir - Specifies the start directory for Gradle
|
||||
--project-prop - Sets a project property of the root project
|
||||
--quiet - Log errors only
|
||||
--recompile-scripts - Forces scripts to be recompiled, bypassing caching
|
||||
--refresh-dependencies - Refresh the state of dependencies
|
||||
--rerun-tasks - Specifies that any task optimization is ignored
|
||||
--scan - Create a build scan
|
||||
--settings-file - Specifies the settings file
|
||||
--stacktrace - Print out the stacktrace also for user exceptions
|
||||
--status - Print Gradle Daemon status
|
||||
--stop - Stop all Gradle Daemons
|
||||
--system-prop - Set a system property
|
||||
--version - Prints Gradle version info
|
||||
--warn - Log warnings and errors only"
|
||||
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
|
||||
}
|
||||
|
||||
__gradle-properties() {
|
||||
local args="-Dorg.gradle.cache.reserved.mb= - Reserve Gradle Daemon memory for operations
|
||||
-Dorg.gradle.caching= - Set true to enable Gradle build cache
|
||||
-Dorg.gradle.daemon.debug= - Set true to debug Gradle Daemon
|
||||
-Dorg.gradle.daemon.idletimeout= - Kill Gradle Daemon after # idle millis
|
||||
-Dorg.gradle.debug= - Set true to debug Gradle Client
|
||||
-Dorg.gradle.jvmargs= - Set JVM arguments
|
||||
-Dorg.gradle.java.home= - Set JDK home dir
|
||||
-Dorg.gradle.logging.level= - Set default Gradle log level (quiet warn lifecycle info debug)
|
||||
-Dorg.gradle.parallel= - Set true to enable parallel project builds (incubating)
|
||||
-Dorg.gradle.parallel.intra= - Set true to enable intra-project parallel builds (incubating)
|
||||
-Dorg.gradle.workers.max= - Set the number of workers Gradle is allowed to use"
|
||||
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
|
||||
return 0
|
||||
}
|
||||
|
||||
__gradle-short-options() {
|
||||
local args="-? - Shows a help message
|
||||
-a - Do not rebuild project dependencies
|
||||
-b - Specifies the build file
|
||||
-c - Specifies the settings file
|
||||
-d - Log at the debug level
|
||||
-g - Specifies the Gradle user home directory
|
||||
-h - Shows a help message
|
||||
-i - Set log level to INFO
|
||||
-m - Runs the build with all task actions disabled
|
||||
-p - Specifies the start directory for Gradle
|
||||
-q - Log errors only
|
||||
-s - Print out the stacktrace also for user exceptions
|
||||
-t - Continuous mode. Automatically re-run build after changes
|
||||
-u - Do not search in parent directories for a settings.gradle
|
||||
-v - Prints Gradle version info
|
||||
-w - Log warnings and errors only
|
||||
-x - Specify a task to be excluded
|
||||
-D - Set a system property
|
||||
-I - Specifies an initialization script
|
||||
-P - Sets a project property of the root project
|
||||
-S - Print out the full (very verbose) stacktrace"
|
||||
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
|
||||
}
|
||||
|
||||
__gradle-notify-tasks-cache-build() {
|
||||
# Notify user of cache rebuild
|
||||
echo -e " (Building completion cache. Please wait)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
|
||||
__gradle-generate-tasks-cache
|
||||
# Remove "please wait" message by writing a bunch of spaces then moving back to the left
|
||||
echo -e " \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
|
||||
}
|
||||
|
||||
__gradle-generate-tasks-cache() {
|
||||
__gradle-set-files-checksum
|
||||
|
||||
# Use Gradle wrapper when it exists.
|
||||
local gradle_cmd="gradle"
|
||||
if [[ -x "$project_root_dir/gradlew" ]]; then
|
||||
gradle_cmd="$project_root_dir/gradlew"
|
||||
fi
|
||||
|
||||
# Run gradle to retrieve possible tasks and cache.
|
||||
# Reuse Gradle Daemon if IDLE but don't start a new one.
|
||||
local gradle_tasks_output
|
||||
if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then
|
||||
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --daemon -q tasks --all)"
|
||||
else
|
||||
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)"
|
||||
fi
|
||||
local output_line
|
||||
local task_description
|
||||
local -a gradle_all_tasks=()
|
||||
local -a root_tasks=()
|
||||
local -a subproject_tasks=()
|
||||
for output_line in $gradle_tasks_output; do
|
||||
if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
||||
task_name="${BASH_REMATCH[1]}"
|
||||
task_description="${BASH_REMATCH[3]}"
|
||||
gradle_all_tasks+=( "$task_name - $task_description" )
|
||||
# Completion for subproject tasks with ':' prefix
|
||||
if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then
|
||||
gradle_all_tasks+=( ":$task_name - $task_description" )
|
||||
subproject_tasks+=( "${BASH_REMATCH[2]}" )
|
||||
else
|
||||
root_tasks+=( "$task_name" )
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# subproject tasks can be referenced implicitly from root project
|
||||
if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
|
||||
local -a implicit_tasks=()
|
||||
implicit_tasks=( $(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort)) )
|
||||
for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
|
||||
gradle_all_tasks+=( $task )
|
||||
done
|
||||
fi
|
||||
|
||||
printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum
|
||||
echo $gradle_files_checksum > $cache_dir/$cache_name.md5
|
||||
}
|
||||
|
||||
__gradle-completion-init() {
|
||||
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
|
||||
|
||||
local OLDIFS="$IFS"
|
||||
local IFS=$'\n'
|
||||
|
||||
__gradle-init-cache-dir
|
||||
__gradle-set-project-root-dir
|
||||
__gradle-set-build-file
|
||||
if [[ -f $gradle_build_file ]]; then
|
||||
__gradle-set-cache-name
|
||||
__gradle-generate-script-cache
|
||||
__gradle-set-files-checksum
|
||||
__gradle-notify-tasks-cache-build
|
||||
fi
|
||||
|
||||
IFS="$OLDIFS"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_gradle() {
|
||||
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# Set bash internal field separator to '\n'
|
||||
# This allows us to provide descriptions for options and tasks
|
||||
local OLDIFS="$IFS"
|
||||
local IFS=$'\n'
|
||||
|
||||
if [[ ${cur} == --* ]]; then
|
||||
__gradle-long-options
|
||||
elif [[ ${cur} == -D* ]]; then
|
||||
__gradle-properties
|
||||
elif [[ ${cur} == -* ]]; then
|
||||
__gradle-short-options
|
||||
else
|
||||
__gradle-init-cache-dir
|
||||
__gradle-set-project-root-dir
|
||||
__gradle-set-build-file
|
||||
if [[ -f $gradle_build_file ]]; then
|
||||
__gradle-set-cache-name
|
||||
__gradle-generate-script-cache
|
||||
__gradle-set-files-checksum
|
||||
|
||||
# The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
|
||||
if [[ -f $cache_dir/$cache_name.md5 ]]; then
|
||||
local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
|
||||
local -a cached_tasks
|
||||
if [[ -z $cur ]]; then
|
||||
cached_tasks=( $(cat $cache_dir/$cached_checksum) )
|
||||
else
|
||||
cached_tasks=( $(grep "^$cur" $cache_dir/$cached_checksum) )
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "$cur") )
|
||||
else
|
||||
__gradle-notify-tasks-cache-build
|
||||
fi
|
||||
|
||||
# Regenerate tasks cache in the background
|
||||
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then
|
||||
$(__gradle-generate-tasks-cache 1>&2 2>/dev/null &)
|
||||
fi
|
||||
else
|
||||
# Default tasks available outside Gradle projects
|
||||
local args="buildEnvironment - Displays all buildscript dependencies declared in root project.
|
||||
components - Displays the components produced by root project.
|
||||
dependencies - Displays all dependencies declared in root project.
|
||||
dependencyInsight - Displays the insight into a specific dependency in root project.
|
||||
dependentComponents - Displays the dependent components of components in root project.
|
||||
help - Displays a help message.
|
||||
init - Initializes a new Gradle build.
|
||||
model - Displays the configuration model of root project.
|
||||
projects - Displays the sub-projects of root project.
|
||||
properties - Displays the properties of root project.
|
||||
tasks - Displays the tasks runnable from root project.
|
||||
wrapper - Generates Gradle wrapper files."
|
||||
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
|
||||
fi
|
||||
fi
|
||||
|
||||
IFS="$OLDIFS"
|
||||
|
||||
# Remove description ("[:space:]" and after) if only one possibility
|
||||
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[0]%% *} )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -F _gradle gradle
|
||||
complete -F _gradle gradle.bat
|
||||
complete -F _gradle gradlew
|
||||
complete -F _gradle gradlew.bat
|
||||
complete -F _gradle ./gradlew
|
||||
complete -F _gradle ./gradlew.bat
|
||||
|
||||
if hash gw 2>/dev/null || alias gw >/dev/null 2>&1; then
|
||||
complete -F _gradle gw
|
||||
fi
|
||||
75
dot_bash_it/completion/available/grunt.completion.bash
Normal file
75
dot_bash_it/completion/available/grunt.completion.bash
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# grunt-cli
|
||||
# http://gruntjs.com/
|
||||
#
|
||||
# Copyright jQuery Foundation and other contributors, https://jquery.org/
|
||||
|
||||
# This software consists of voluntary contributions made by many
|
||||
# individuals. For exact contribution history, see the revision history
|
||||
# available at https://github.com/gruntjs/grunt .
|
||||
|
||||
# The following license applies to all parts of this software except as
|
||||
# documented below:
|
||||
|
||||
# ====
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# To enable bash <tab> completion for grunt, add the following line (minus the
|
||||
# leading #, which is the bash comment character) to your ~/.bashrc file:
|
||||
#
|
||||
# eval "$(grunt --completion=bash)"
|
||||
|
||||
# Search the current directory and all parent directories for a gruntfile.
|
||||
function _grunt_gruntfile() {
|
||||
local curpath="$PWD"
|
||||
while [[ "$curpath" ]]; do
|
||||
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
|
||||
if [[ -e "$gruntfile" ]]; then
|
||||
echo "$gruntfile"
|
||||
return
|
||||
fi
|
||||
done
|
||||
curpath="${curpath%/*}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Enable bash autocompletion.
|
||||
function _grunt_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
# The current gruntfile, if it exists.
|
||||
local gruntfile="$(_grunt_gruntfile)"
|
||||
# The current grunt version, available tasks, options, etc.
|
||||
local gruntinfo="$(grunt --version --verbose 2>/dev/null)"
|
||||
# Options and tasks.
|
||||
local opts="$(echo "$gruntinfo" | awk '/Available options: / {$1=$2=""; print $0}')"
|
||||
local compls="$(echo "$gruntinfo" | awk '/Available tasks: / {$1=$2=""; print $0}')"
|
||||
# Only add -- or - options if the user has started typing -
|
||||
[[ "$cur" == -* ]] && compls="$compls $opts"
|
||||
# Tell complete what stuff to show.
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
|
||||
complete -o default -F _grunt_completions grunt
|
||||
50
dot_bash_it/completion/available/gulp.completion.bash
Normal file
50
dot_bash_it/completion/available/gulp.completion.bash
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Borrowed from grunt-cli
|
||||
# http://gruntjs.com/
|
||||
#
|
||||
# Copyright jQuery Foundation and other contributors, https://jquery.org/
|
||||
|
||||
# This software consists of voluntary contributions made by many
|
||||
# individuals. For exact contribution history, see the revision history
|
||||
# available at https://github.com/gruntjs/grunt .
|
||||
|
||||
# The following license applies to all parts of this software except as
|
||||
# documented below:
|
||||
|
||||
# ====
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# To enable bash <tab> completion for gulp, add the following line (minus the
|
||||
# leading #, which is the bash comment character) to your ~/.bashrc file:
|
||||
#
|
||||
# eval "$(gulp --completion=bash)"
|
||||
# Enable bash autocompletion.
|
||||
function _gulp_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
#Grab tasks
|
||||
local compls=$(gulp --tasks-simple)
|
||||
# Tell complete what stuff to show.
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
complete -o default -F _gulp_completions gulp
|
||||
7
dot_bash_it/completion/available/helm.completion.bash
Normal file
7
dot_bash_it/completion/available/helm.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "helm (Kubernetes Package Manager) completion"
|
||||
|
||||
if _command_exists helm; then
|
||||
eval "$(helm completion bash)"
|
||||
fi
|
||||
@@ -0,0 +1,2 @@
|
||||
_log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
|
||||
Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
|
||||
408
dot_bash_it/completion/available/hub.completion.bash
Normal file
408
dot_bash_it/completion/available/hub.completion.bash
Normal file
@@ -0,0 +1,408 @@
|
||||
# hub tab-completion script for bash.
|
||||
# This script complements the completion script that ships with git.
|
||||
|
||||
# Copyright (c) 2009 Chris Wanstrath
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# If there is no git tab completion, but we have the _completion loader try to load it
|
||||
if ! _is_function _git && _is_function _completion_loader; then
|
||||
_completion_loader git
|
||||
fi
|
||||
|
||||
# Check that git tab completion is available and we haven't already set up completion
|
||||
if _is_function _git && ! _is_function __git_list_all_commands_without_hub; then
|
||||
# Duplicate and rename the 'list_all_commands' function
|
||||
eval "$(declare -f __git_list_all_commands | \
|
||||
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
|
||||
|
||||
# Wrap the 'list_all_commands' function with extra hub commands
|
||||
__git_list_all_commands() {
|
||||
cat <<-EOF
|
||||
alias
|
||||
pull-request
|
||||
pr
|
||||
issue
|
||||
release
|
||||
fork
|
||||
create
|
||||
delete
|
||||
browse
|
||||
compare
|
||||
ci-status
|
||||
sync
|
||||
EOF
|
||||
__git_list_all_commands_without_hub
|
||||
}
|
||||
|
||||
# Ensure cached commands are cleared
|
||||
__git_all_commands=""
|
||||
|
||||
##########################
|
||||
# hub command completions
|
||||
##########################
|
||||
|
||||
# hub alias [-s] [SHELL]
|
||||
_git_alias() {
|
||||
local i c=2 s=-s sh shells="bash zsh sh ksh csh fish"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
__gitcomp "$s $shells"
|
||||
}
|
||||
|
||||
# hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE]
|
||||
_git_browse() {
|
||||
local i c=2 u=-u repo subpage
|
||||
local subpages_="commits issues tree wiki pulls branches stargazers
|
||||
contributors network network/ graphs graphs/"
|
||||
local subpages_network="members"
|
||||
local subpages_graphs="commit-activity code-frequency punch-card"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
if [ -z "$repo" ]; then
|
||||
__gitcomp "$u -- $(__hub_github_repos '\p')"
|
||||
elif [ -z "$subpage" ]; then
|
||||
case "$cur" in
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
}
|
||||
|
||||
# hub compare [-u] [USER[/REPOSITORY]] [[START...]END]
|
||||
_git_compare() {
|
||||
local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev
|
||||
while [ $c -gt 1 ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
arg_repo=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c--))
|
||||
done
|
||||
|
||||
# Here we want to find out the git remote name of user/repo, in order to
|
||||
# generate an appropriate revision list
|
||||
if [ -z "$arg_repo" ]; then
|
||||
user=$(__hub_github_user)
|
||||
if [ -z "$user" ]; then
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
if [ "$remote" = origin ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
owner=${repo%%/*}
|
||||
if [ "$user" = "$owner" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
owner=${repo%%/*}
|
||||
case "$arg_repo" in
|
||||
"$repo"|"$owner")
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
local pfx cur_="$cur"
|
||||
case "$cur_" in
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]
|
||||
_git_create() {
|
||||
local i c=2 name repo flags="-p -d -h"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
if [ -z "$name" ]; then
|
||||
repo="$(basename "${PWD}")"
|
||||
fi
|
||||
case "$prev" in
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION]
|
||||
_git_fork() {
|
||||
local i c=2 flags="--no-remote --remote-name --org"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
--org)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
--remote-name)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
flags=${flags/--no-remote/}
|
||||
;;
|
||||
--no-remote)
|
||||
flags=${flags/$i/}
|
||||
flags=${flags/--remote-name/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
--remote-name|--org)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] [-a <USER>] [-M <MILESTONE>] [-l <LABELS>]
|
||||
_git_pull_request() {
|
||||
local i c=2 flags="-f -m -F -i -b -h -a -M -l"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-m|-F|-i|-b|-h|-a|-M|-l)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h|-a|-M|-l)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
###################
|
||||
# Helper functions
|
||||
###################
|
||||
|
||||
# __hub_github_user [HOST]
|
||||
# Return $GITHUB_USER or the default github user defined in hub config
|
||||
# HOST - Host to be looked-up in hub config. Default is "github.com"
|
||||
__hub_github_user() {
|
||||
if [ -n "$GITHUB_USER" ]; then
|
||||
echo $GITHUB_USER
|
||||
return
|
||||
fi
|
||||
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub}
|
||||
if [ -f "$config" ]; then
|
||||
while read line; do
|
||||
if [ "$line" = "---" ]; then
|
||||
continue
|
||||
fi
|
||||
k=${line%%:*}
|
||||
v=${line#*:}
|
||||
if [ -z "$v" ]; then
|
||||
if [ "$h" = "$host" ]; then
|
||||
break
|
||||
fi
|
||||
h=$k
|
||||
continue
|
||||
fi
|
||||
k=${k#* }
|
||||
v=${v#* }
|
||||
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
|
||||
echo "$v"
|
||||
break
|
||||
fi
|
||||
done < "$config"
|
||||
fi
|
||||
}
|
||||
|
||||
# __hub_github_repos [FORMAT]
|
||||
# List all github hosted repository
|
||||
# FORMAT - Format string contains multiple of these:
|
||||
# \m remote
|
||||
# \p owner/repo
|
||||
# \o owner
|
||||
# escaped characters (\n, \t ...etc) work
|
||||
# If omitted, prints all github repos in the format of "remote:owner/repo"
|
||||
__hub_github_repos() {
|
||||
local f format=$1
|
||||
if [ -z "$(__gitdir)" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -z "$format" ]; then
|
||||
format='\1:\2'
|
||||
else
|
||||
format=${format//\m/\1}
|
||||
format=${format//\p/\2}
|
||||
format=${format//\o/\3}
|
||||
fi
|
||||
command git config --get-regexp 'remote\.[^.]*\.url' |
|
||||
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
|
||||
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
|
||||
}
|
||||
|
||||
# __hub_heads
|
||||
# List all local "branch", and remote "owner/repo:branch"
|
||||
__hub_heads() {
|
||||
local i remote repo branch dir=$(__gitdir)
|
||||
if [ -d "$dir" ]; then
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/heads/"
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/remotes/${remote}/" | while read branch; do
|
||||
echo "${repo}:${branch#${remote}/}"
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# __hub_revlist [REMOTE]
|
||||
# List all tags, and branches under REMOTE, without the "remote/" prefix
|
||||
# REMOTE - Remote name to search branches from. Default is "origin"
|
||||
__hub_revlist() {
|
||||
local i remote=${1:-origin} dir=$(__gitdir)
|
||||
if [ -d "$dir" ]; then
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/remotes/${remote}/" | while read i; do
|
||||
echo "${i#${remote}/}"
|
||||
done
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/tags/"
|
||||
fi
|
||||
}
|
||||
|
||||
# Enable completion for hub even when not using the alias
|
||||
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
|
||||
|| complete -o default -o nospace -F _git hub
|
||||
fi
|
||||
54
dot_bash_it/completion/available/invoke.completion.bash
Normal file
54
dot_bash_it/completion/available/invoke.completion.bash
Normal file
@@ -0,0 +1,54 @@
|
||||
# Invoke (pyinvoke.org) tab-completion script to be sourced with Bash shell.
|
||||
|
||||
# Copyright (c) 2020 Jeff Forcier.
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# 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
|
||||
4
dot_bash_it/completion/available/jboss5.completion.bash
Normal file
4
dot_bash_it/completion/available/jboss5.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "jboss5 completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss5
|
||||
4
dot_bash_it/completion/available/jboss7.completion.bash
Normal file
4
dot_bash_it/completion/available/jboss7.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "jboss7 completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss7
|
||||
7
dot_bash_it/completion/available/jungle.completion.bash
Normal file
7
dot_bash_it/completion/available/jungle.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "jungle(AWS cli tool) completion"
|
||||
|
||||
if _command_exists jungle; then
|
||||
eval "$(_JUNGLE_COMPLETE=source jungle)"
|
||||
fi
|
||||
5
dot_bash_it/completion/available/kind.completion.bash
Normal file
5
dot_bash_it/completion/available/kind.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if _command_exists kind; then
|
||||
eval "$(kind completion bash)"
|
||||
fi
|
||||
205
dot_bash_it/completion/available/knife.completion.bash
Normal file
205
dot_bash_it/completion/available/knife.completion.bash
Normal file
@@ -0,0 +1,205 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Published originally as public domain code at https://github.com/wk8/knife-bash-autocomplete
|
||||
|
||||
##############
|
||||
### 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"
|
||||
# shellcheck disable=SC2155
|
||||
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
|
||||
shift 1
|
||||
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
|
||||
if ! "$@" > "$TMP_FILE" 2> /dev/null; then
|
||||
[[ $(wc -l "$TMP_FILE") == 0 ]] && rm -f "$TMP_FILE" && touch "$CACHE_PATH" && return 1
|
||||
else
|
||||
mv -f "$TMP_FILE" "$CACHE_PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
# cached files can't have spaces in their names
|
||||
_KAC_get_cache_name_from_command() {
|
||||
echo "${@// /_SPACE_}"
|
||||
}
|
||||
|
||||
# the reverse operation from the function above
|
||||
_KAC_get_command_from_cache_name() {
|
||||
echo "${@//_SPACE_/ }"
|
||||
}
|
||||
|
||||
# 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)
|
||||
# shellcheck disable=SC2155
|
||||
_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
|
||||
if [[ -f "$_KAC_CACHE_PATH" ]]; then
|
||||
($REGEN_CMD &)
|
||||
else
|
||||
$REGEN_CMD
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 "$_KAC_CACHE_TMP_DIR"/*; do
|
||||
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" || rm -f "$FILE"
|
||||
done
|
||||
# refresh really stale caches
|
||||
find "$_KNIFE_AUTOCOMPLETE_CACHE_DIR" -maxdepth 1 -type f -not -name '.*' \
|
||||
| while read -r FILE; 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
|
||||
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
|
||||
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _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]}"
|
||||
grep -E "^$CURRENT" "$_KAC_CACHE_PATH" > /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
|
||||
# shellcheck disable=SC2155
|
||||
_KAC_get_current_arg_position() {
|
||||
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
|
||||
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
|
||||
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
|
||||
# shellcheck disable=SC2034
|
||||
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=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | 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 $(cut -d ' ' -f 1 < "$_KAC_CACHE_PATH")"
|
||||
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
|
||||
# shellcheck disable=SC2207,SC2086
|
||||
COMPREPLY=($(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
}
|
||||
|
||||
complete -F _knife knife
|
||||
5
dot_bash_it/completion/available/kontena.completion.bash
Normal file
5
dot_bash_it/completion/available/kontena.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists kontena; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$(kontena whoami --bash-completion-path)"
|
||||
fi
|
||||
7
dot_bash_it/completion/available/kubectl.completion.bash
Normal file
7
dot_bash_it/completion/available/kubectl.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "kubectl (Kubernetes CLI) completion"
|
||||
|
||||
if _binary_exists kubectl; then
|
||||
eval "$(kubectl completion bash)"
|
||||
fi
|
||||
16
dot_bash_it/completion/available/laravel.completion.bash
Normal file
16
dot_bash_it/completion/available/laravel.completion.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
_command_exists laravel || return
|
||||
|
||||
function __laravel_completion() {
|
||||
local OPTS=('-h' '--help' '-q' '--quiet' '--ansi' '--no-ansi' '-n' '--no-interaction' '-v' '-vv' '-vvv' '--verbose' 'help' 'list' 'new')
|
||||
local _opt_
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __laravel_completion laravel
|
||||
22
dot_bash_it/completion/available/lerna.completion.bash
Normal file
22
dot_bash_it/completion/available/lerna.completion.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "lerna(javascript project manager tool) completion"
|
||||
|
||||
function __lerna_completion() {
|
||||
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.
|
||||
# shellcheck disable=2207
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
complete -o default -F __lerna_completion lerna
|
||||
34
dot_bash_it/completion/available/makefile.completion.bash
Normal file
34
dot_bash_it/completion/available/makefile.completion.bash
Normal file
@@ -0,0 +1,34 @@
|
||||
# Bash completion for Makefile
|
||||
# Loosely adapted from http://stackoverflow.com/a/38415982/1472048
|
||||
|
||||
_makecomplete() {
|
||||
COMPREPLY=()
|
||||
|
||||
# https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html
|
||||
local files=()
|
||||
for f in 'GNUmakefile' 'makefile' 'Makefile' ; do
|
||||
[ -f "$f" ] && files+=("$f")
|
||||
done
|
||||
|
||||
[ "${#files[@]}" -eq 0 ] && return 0
|
||||
|
||||
# collect all targets
|
||||
local targets=()
|
||||
for f in "${files[@]}" ; do
|
||||
while IFS='' read -r line ; do
|
||||
targets+=("$line")
|
||||
done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1)
|
||||
done
|
||||
|
||||
[ "${#targets[@]}" -eq 0 ] && return 0
|
||||
|
||||
# use the targets for completion
|
||||
while IFS='' read -r line ; do
|
||||
COMPREPLY+=("$line")
|
||||
done < <(compgen -W "$(tr ' ' '\n' <<<"${targets[@]}" | sort -u)" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o nospace -F _makecomplete make
|
||||
complete -o nospace -F _makecomplete gnumake
|
||||
36
dot_bash_it/completion/available/maven.completion.bash
Normal file
36
dot_bash_it/completion/available/maven.completion.bash
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash Maven completion
|
||||
|
||||
_mvn()
|
||||
{
|
||||
local cmds cur colonprefixes
|
||||
cmds="clean validate compile test package integration-test \
|
||||
verify install deploy test-compile site generate-sources \
|
||||
process-sources generate-resources process-resources \
|
||||
eclipse:eclipse eclipse:add-maven-repo eclipse:clean \
|
||||
idea:idea -DartifactId= -DgroupId= -Dmaven.test.skip=true \
|
||||
-Declipse.workspace= -DarchetypeArtifactId= \
|
||||
netbeans-freeform:generate-netbeans-project \
|
||||
tomcat:run tomcat:run-war tomcat:deploy jboss-as:deploy \
|
||||
versions:display-dependency-updates \
|
||||
versions:display-plugin-updates dependency:analyze \
|
||||
dependency:analyze-dep-mgt dependency:resolve \
|
||||
dependency:sources dependency:tree release:prepare \
|
||||
release:rollback release:perform --batch-mode"
|
||||
|
||||
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
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _mvn mvn
|
||||
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# minikube (Local Kubernetes) completion
|
||||
|
||||
if _command_exists minikube; then
|
||||
eval "$(minikube completion bash)"
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
_command_exists minishift && source <(minishift completion bash)
|
||||
8
dot_bash_it/completion/available/ng.completion.bash
Normal file
8
dot_bash_it/completion/available/ng.completion.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
if _command_exists ng; then
|
||||
# No longer supported, please see https://github.com/angular/angular-cli/issues/11043
|
||||
# Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists
|
||||
# . <(ng completion --bash)
|
||||
|
||||
NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n"
|
||||
complete -W "$NG_COMMANDS" ng
|
||||
fi
|
||||
47
dot_bash_it/completion/available/ngrok.completion.bash
Normal file
47
dot_bash_it/completion/available/ngrok.completion.bash
Normal file
@@ -0,0 +1,47 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__ngrok_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local BASE_NO_CONF="--log --log-format --log-level --help"
|
||||
local BASE="--config $BASE_NO_CONF"
|
||||
local DEFAULT="$BASE --authtoken --region"
|
||||
|
||||
case $prev in
|
||||
authtoken)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$BASE" -- "$curr"))
|
||||
;;
|
||||
http)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr"))
|
||||
;;
|
||||
start)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr"))
|
||||
;;
|
||||
tcp)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr"))
|
||||
;;
|
||||
tls)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr"))
|
||||
;;
|
||||
update)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr"))
|
||||
;;
|
||||
ngrok)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr"))
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __ngrok_completion ngrok
|
||||
21
dot_bash_it/completion/available/notify-send.completion.bash
Normal file
21
dot_bash_it/completion/available/notify-send.completion.bash
Normal file
@@ -0,0 +1,21 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function __notify-send_completions() {
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
|
||||
case $prev in
|
||||
-u | --urgency)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "low normal critical" -- "$curr"))
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-? --help -u --urgency -t --expire-time -a --app-name -i --icon -c --category -h --hint -v --version" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __notify-send_completions notify-send
|
||||
7
dot_bash_it/completion/available/npm.completion.bash
Normal file
7
dot_bash_it/completion/available/npm.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "npm (Node Package Manager) completion"
|
||||
|
||||
if _command_exists npm; then
|
||||
eval "$(npm completion)"
|
||||
fi
|
||||
8
dot_bash_it/completion/available/nvm.completion.bash
Normal file
8
dot_bash_it/completion/available/nvm.completion.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# nvm (Node Version Manager) completion
|
||||
|
||||
if [ "$NVM_DIR" ] && [ -r "$NVM_DIR"/bash_completion ];
|
||||
then
|
||||
. "$NVM_DIR"/bash_completion
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
_command_exists oc && source <(oc completion bash)
|
||||
7
dot_bash_it/completion/available/packer.completion.bash
Normal file
7
dot_bash_it/completion/available/packer.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "packer completion"
|
||||
|
||||
if _binary_exists packer; then
|
||||
complete -C packer packer
|
||||
fi
|
||||
6
dot_bash_it/completion/available/pew.completion.bash
Normal file
6
dot_bash_it/completion/available/pew.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists pew
|
||||
then
|
||||
source "$(pew shell_config)"
|
||||
fi
|
||||
20
dot_bash_it/completion/available/pip.completion.bash
Normal file
20
dot_bash_it/completion/available/pip.completion.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# https://pip.pypa.io/en/stable/user_guide/#command-completion
|
||||
# Of course, you should first install pip, say on Debian:
|
||||
# sudo apt-get install python-pip
|
||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip is in the system's path.
|
||||
_command_exists pip || return
|
||||
|
||||
function __bash_it_complete_pip() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip pip
|
||||
20
dot_bash_it/completion/available/pip3.completion.bash
Normal file
20
dot_bash_it/completion/available/pip3.completion.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# https://pip.pypa.io/en/stable/user_guide/#command-completion
|
||||
# Of course, you should first install pip, say on Debian:
|
||||
# sudo apt-get install python3-pip
|
||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip3 is in the system's path.
|
||||
_command_exists pip3 || return
|
||||
|
||||
function __bash_it_complete_pip3() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip3
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip3 completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip3 pip3
|
||||
4
dot_bash_it/completion/available/pipenv.completion.bash
Normal file
4
dot_bash_it/completion/available/pipenv.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists pipenv; then
|
||||
eval "$(_PIPENV_COMPLETE=bash_source pipenv)"
|
||||
fi
|
||||
6
dot_bash_it/completion/available/pipx.completion.bash
Normal file
6
dot_bash_it/completion/available/pipx.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# pipx completion
|
||||
|
||||
if _command_exists register-python-argcomplete && _command_exists pipx; then
|
||||
eval "$(register-python-argcomplete pipx)"
|
||||
fi
|
||||
46
dot_bash_it/completion/available/projects.completion.bash
Normal file
46
dot_bash_it/completion/available/projects.completion.bash
Normal file
@@ -0,0 +1,46 @@
|
||||
# Ensure that we log to doctor so the user can address these issues
|
||||
_is_function _init_completion ||
|
||||
_log_error '_init_completion not found. Ensure bash-completion 2.0 or newer is installed and configured properly.'
|
||||
_is_function _rl_enabled ||
|
||||
_log_error '_rl_enabled not found. Ensure bash-completion 2.0 or newer is installed and configured properly.'
|
||||
|
||||
_pj() {
|
||||
_is_function _init_completion || return
|
||||
_is_function _rl_enabled || return
|
||||
[ -n "$PROJECT_PATHS" ] || return
|
||||
shift
|
||||
[ "$1" == "open" ] && shift
|
||||
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local IFS=$'\n' i j k
|
||||
|
||||
compopt -o filenames
|
||||
|
||||
local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
|
||||
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
|
||||
|
||||
for i in ${PROJECT_PATHS//:/$'\n'}; do
|
||||
# create an array of matched subdirs
|
||||
k="${#COMPREPLY[@]}"
|
||||
for j in $( compgen -d $i/$cur ); do
|
||||
if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
|
||||
j+="/"
|
||||
fi
|
||||
COMPREPLY[k++]=${j#$i/}
|
||||
done
|
||||
done
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
|
||||
i=${COMPREPLY[0]}
|
||||
if [[ "$i" == "$cur" && $i != "*/" ]]; then
|
||||
COMPREPLY[0]="${i}/"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _pj -o nospace pj
|
||||
complete -F _pj -o nospace pjo
|
||||
17
dot_bash_it/completion/available/rake.completion.bash
Normal file
17
dot_bash_it/completion/available/rake.completion.bash
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for Rake, Ruby Make.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_rakecomplete() {
|
||||
if [ -f Rakefile ]; then
|
||||
recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1`
|
||||
if [[ $recent != '.rake_tasks~' ]]; then
|
||||
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "`cat .rake_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _rakecomplete rake
|
||||
7
dot_bash_it/completion/available/rustup.completion.bash
Normal file
7
dot_bash_it/completion/available/rustup.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# rustup (Rust toolchain installer) completion
|
||||
|
||||
if _binary_exists rustup; then
|
||||
eval "$(rustup completions bash)"
|
||||
fi
|
||||
5
dot_bash_it/completion/available/rvm.completion.bash
Normal file
5
dot_bash_it/completion/available/rvm.completion.bash
Normal file
@@ -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
|
||||
343
dot_bash_it/completion/available/salt.completion.bash
Normal file
343
dot_bash_it/completion/available/salt.completion.bash
Normal file
@@ -0,0 +1,343 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Copyright (c) 2020 SaltStack Team
|
||||
|
||||
# Original Author:
|
||||
# written by David Pravec
|
||||
# - feel free to /msg alekibango on IRC if you want to talk about this file
|
||||
|
||||
# TODO: check if --config|-c was used and use configured config file for queries
|
||||
# TODO: solve somehow completion for salt -G pythonversion:[tab]
|
||||
# (not sure what to do with lists)
|
||||
# TODO: --range[tab] -- how?
|
||||
# TODO: --compound[tab] -- how?
|
||||
# TODO: use history to extract some words, esp. if ${cur} is empty
|
||||
# TODO: TEST EVERYTHING a lot
|
||||
# TODO: cache results of some functions? where? how long?
|
||||
# TODO: is it ok to use '--timeout 2' ?
|
||||
|
||||
|
||||
_salt_get_grains(){
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
fi
|
||||
}
|
||||
|
||||
_salt_get_grain_values(){
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_salt(){
|
||||
local cur prev opts _salt_grains _salt_coms pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
|
||||
opts="-h --help -d --doc --documentation --version --versions-report -c \
|
||||
--config-dir= -v --verbose -t --timeout= -s --static -b --batch= \
|
||||
--batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \
|
||||
--nodegroup -R --range -C --compound -I --pillar \
|
||||
--return= -a --auth= --eauth= --extended-auth= -T --make-token -S \
|
||||
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
|
||||
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 2 special cases for filling up grain values
|
||||
case "${pprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${cur}" = ":" ]; then
|
||||
COMPREPLY=($(compgen -W "`_salt_get_grain_values ${prev}`" ))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case "${ppprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${prev}" = ":" ]; then
|
||||
COMPREPLY=( $(compgen -W "`_salt_get_grain_values ${pprev}`" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
salt)
|
||||
COMPREPLY=($(compgen -W "\'*\' ${opts} `salt-key --no-color -l acc`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W "`salt-key --no-color -l acc`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
COMPREPLY=() # TODO: finish this one? how?
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
COMPREPLY=($( compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-b|--batch|--batch-size)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 50 60 70 80 90 100 120 150 200"))
|
||||
return 0
|
||||
;;
|
||||
-N|--nodegroup)
|
||||
MASTER_CONFIG='/etc/salt/master'
|
||||
COMPREPLY=($(compgen -W "`awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' <${MASTER_CONFIG}`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
_salt_coms="$(salt '*' --timeout 2 --out=txt -- sys.list_functions | sed 's/^.*\[//' | tr -d ",']" )"
|
||||
all="${opts} ${_salt_coms}"
|
||||
COMPREPLY=( $(compgen -W "${all}" -- ${cur}) )
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _salt salt
|
||||
|
||||
|
||||
_saltkey(){
|
||||
local cur prev opts prev pprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-c --config-dir= -h --help --version --versions-report -q --quiet \
|
||||
-y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \
|
||||
-l --list= -L --list-all -a --accept= -A --accept-all \
|
||||
-r --reject= -R --reject-all -p --print= -P --print-all \
|
||||
-d --delete= -D --delete-all -f --finger= -F --finger-all \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
-a|--accept)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-r|--reject)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-d|--delete)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--keysize)
|
||||
COMPREPLY=($(compgen -W "2048 3072 4096 5120 6144" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--gen-keys)
|
||||
return 0
|
||||
;;
|
||||
--gen-keys-dir)
|
||||
COMPREPLY=($(compgen -d -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-p|--print)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-l|--list)
|
||||
COMPREPLY=($(compgen -W "pre un acc accepted unaccepted rej rejected all" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--accept-all)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=($(compgen -W "${opts} " -- ${cur}))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltkey salt-key
|
||||
|
||||
_saltcall(){
|
||||
local cur prev opts _salt_coms pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-h --help -d --doc --documentation --version --versions-report \
|
||||
-m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
-m|--module-dirs)
|
||||
COMPREPLY=( $(compgen -d ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
-l|--log-level)
|
||||
COMPREPLY=( $(compgen -W "info none garbage trace warning error debug" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-g|grains)
|
||||
return 0
|
||||
;;
|
||||
salt-call)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
_salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )"
|
||||
COMPREPLY=( $(compgen -W "${opts} ${_salt_coms}" -- ${cur} ))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltcall salt-call
|
||||
|
||||
|
||||
_saltcp(){
|
||||
local cur prev opts target prefpart postpart helper filt pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-t --timeout= -s --static -b --batch= --batch-size= \
|
||||
-h --help --version --versions-report -c --config-dir= \
|
||||
-E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \
|
||||
-R --range -C --compound -I --pillar \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev=${pprev}
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
salt-cp)
|
||||
COMPREPLY=($(compgen -W "${opts} `salt-key -l acc --no-color`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
# those numbers are just a hint
|
||||
COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W "`salt-key -l acc --no-color`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-L|--list)
|
||||
# IMPROVEMENTS ARE WELCOME
|
||||
prefpart="${cur%,*},"
|
||||
postpart=${cur##*,}
|
||||
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
|
||||
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
|
||||
COMPREPLY=($(compgen -W "${helper[*]}" -- ${cur}))
|
||||
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
# FIXME
|
||||
-R|--range)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# default is using opts:
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
}
|
||||
|
||||
complete -F _saltcp salt-cp
|
||||
86
dot_bash_it/completion/available/sdkman.completion.bash
Normal file
86
dot_bash_it/completion/available/sdkman.completion.bash
Normal file
@@ -0,0 +1,86 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function _sdkman_complete() {
|
||||
local CANDIDATES
|
||||
local CANDIDATE_VERSIONS
|
||||
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
if [ "$COMP_CWORD" -eq 1 ]; then
|
||||
mapfile -t COMPREPLY < <(compgen -W "install uninstall rm list ls use default home env current upgrade ug version broadcast help offline selfupdate update flush" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
elif [ "$COMP_CWORD" -eq 2 ]; then
|
||||
case "${COMP_WORDS[COMP_CWORD - 1]}" in
|
||||
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
|
||||
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"env")
|
||||
mapfile -t COMPREPLY < <(compgen -W "init" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"offline")
|
||||
mapfile -t COMPREPLY < <(compgen -W "enable disable" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"selfupdate")
|
||||
mapfile -t COMPREPLY < <(compgen -W "force" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"flush")
|
||||
mapfile -t COMPREPLY < <(compgen -W "archives tmp broadcast version" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
elif [ "$COMP_CWORD" -eq 3 ]; then
|
||||
case "${COMP_WORDS[COMP_CWORD - 2]}" in
|
||||
"uninstall" | "rm" | "use" | "u" | "default" | "d" | "home" | "h")
|
||||
_sdkman_candidate_local_versions "${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"install" | "i")
|
||||
_sdkman_candidate_all_versions "${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function _sdkman_candidate_local_versions() {
|
||||
|
||||
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
|
||||
|
||||
}
|
||||
|
||||
function _sdkman_candidate_all_versions() {
|
||||
|
||||
candidate="$1"
|
||||
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
|
||||
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
|
||||
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
|
||||
else
|
||||
# sdkman has a specific output format for Java candidate since
|
||||
# there are multiple vendors and builds.
|
||||
if [ "$candidate" = "java" ]; then
|
||||
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 62-)"
|
||||
else
|
||||
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 6-)"
|
||||
fi
|
||||
# the last grep is used to filter out sdkman flags, such as:
|
||||
# "+" - local version
|
||||
# "*" - installed
|
||||
# ">" - currently in use
|
||||
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function __sdkman_cleanup_local_versions() {
|
||||
|
||||
__sdkman_build_version_csv "$1" | tr ',' ' '
|
||||
|
||||
}
|
||||
|
||||
complete -F _sdkman_complete sdk
|
||||
168
dot_bash_it/completion/available/sqlmap.completion.bash
Normal file
168
dot_bash_it/completion/available/sqlmap.completion.bash
Normal file
@@ -0,0 +1,168 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# ---------------------------------------------------------------------------+
|
||||
# |
|
||||
# Thanks to Alexander Korznikov |
|
||||
# http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html |
|
||||
# |
|
||||
# ---------------------------------------------------------------------------+
|
||||
|
||||
if _command_exists sqlmap
|
||||
then
|
||||
|
||||
function _sqlmap()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
cur="$(_get_cword)"
|
||||
prev="$(_get_pword)"
|
||||
|
||||
case $prev in
|
||||
|
||||
# List directory content
|
||||
--tamper)
|
||||
COMPREPLY=( $( compgen -W "$tamper" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--output-dir|-t|-l|-m|-r|--load-cookies|--proxy-file|--sql-file|--shared-lib|--file-write)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
-c)
|
||||
_filedir ini
|
||||
return 0
|
||||
;;
|
||||
--method)
|
||||
COMPREPLY=( $( compgen -W 'GET POST PUT' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--auth-type)
|
||||
COMPREPLY=( $( compgen -W 'Basic Digest NTLM PKI' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--tor-type)
|
||||
COMPREPLY=( $( compgen -W 'HTTP SOCKS4 SOCKS5' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-v)
|
||||
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--dbms)
|
||||
COMPREPLY=( $( compgen -W 'mysql mssql access postgres' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--level|--crawl)
|
||||
COMPREPLY=( $( compgen -W '1 2 3 4 5' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--risk)
|
||||
COMPREPLY=( $( compgen -W '0 1 2 3' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--technique)
|
||||
COMPREPLY=( $( compgen -W 'B E U S T Q' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-s)
|
||||
_filedir sqlite
|
||||
return 0
|
||||
;;
|
||||
--dump-format)
|
||||
COMPREPLY=( $( compgen -W 'CSV HTML SQLITE' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-x)
|
||||
_filedir xml
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$cur" == * ]]; then
|
||||
COMPREPLY=( $( compgen -W '-h --help -hh --version -v -d -u --url -l -x -m -r -g -c --method \
|
||||
--data --param-del --cookie --cookie-del --load-cookies \
|
||||
--drop-set-cookie --user-agent --random-agent --host --referer \
|
||||
--headers --auth-type --auth-cred --auth-private --ignore-401 \
|
||||
--proxy --proxy-cred --proxy-file --ignore-proxy --tor --tor-port \
|
||||
--tor-type --check-tor --delay --timeout --retries --randomize \
|
||||
--safe-url --safe-freq --skip-urlencode --csrf-token --csrf-url \
|
||||
--force-ssl --hpp --eval -o --predict-output --keep-alive \
|
||||
--null-connection --threads -p --skip --dbms --dbms-cred \
|
||||
--os --invalid-bignum --invalid-logical --invalid-string \
|
||||
--no-cast --no-escape --prefix --suffix --tamper --level \
|
||||
--risk --string --not-string --regexp --code --text-only \
|
||||
--titles --technique --time-sec --union-cols --union-char \
|
||||
--union-from --dns-domain --second-order -f --fingerprint \
|
||||
-a --all -b --banner --current-user --current-db --hostname \
|
||||
--is-dba --users --passwords --privileges --roles --dbs --tables \
|
||||
--columns --schema --count --dump --dump-all --search --comments \
|
||||
-D -T -C -X -U --exclude-sysdbs --where --start --stop \
|
||||
--first --last --sql-query --sql-shell --sql-file --common-tables \
|
||||
--common-columns --udf-inject --shared-lib --file-read --file-write \
|
||||
--file-dest --os-cmd --os-shell --os-pwn --os-smbrelay --os-bof \
|
||||
--priv-esc --msf-path --tmp-path --reg-read --reg-add --reg-del \
|
||||
--reg-key --reg-value --reg-data --reg-type -s -t --batch \
|
||||
--charset --crawl --csv-del --dump-format --eta --flush-session \
|
||||
--forms --fresh-queries --hex --output-dir --parse-errors \
|
||||
--pivot-column --save --scope --test-filter --update \
|
||||
-z --alert --answers --beep --check-waf --cleanup \
|
||||
--dependencies --disable-coloring --gpage --identify-waf \
|
||||
--mobile --page-rank --purge-output --smart \
|
||||
--sqlmap-shell --wizard' -- "$cur" ) )
|
||||
# this removes any options from the list of completions that have
|
||||
# already been specified somewhere on the command line, as long as
|
||||
# these options can only be used once (in a word, "options", in
|
||||
# opposition to "tests" and "actions", as in the find(1) manpage).
|
||||
onlyonce=' -h --help -hh --version -v -d -u --url -l -x -m -r -g -c \
|
||||
--drop-set-cookie --random-agent \
|
||||
--ignore-401 \
|
||||
--ignore-proxy --tor \
|
||||
--check-tor \
|
||||
--skip-urlencode \
|
||||
--force-ssl --hpp -o --predict-output --keep-alive \
|
||||
--null-connection -p \
|
||||
--invalid-bignum --invalid-logical --invalid-string \
|
||||
--no-cast --no-escape \
|
||||
--text-only \
|
||||
--titles \
|
||||
-f --fingerprint \
|
||||
-a --all -b --banner --current-user --current-db --hostname \
|
||||
--is-dba --users --passwords --privileges --roles --dbs --tables \
|
||||
--columns --schema --count --dump --dump-all --search --comments \
|
||||
-D -T -C -X -U --exclude-sysdbs \
|
||||
--sql-shell --common-tables \
|
||||
--common-columns --udf-inject \
|
||||
--os-shell --os-pwn --os-smbrelay --os-bof \
|
||||
--priv-esc --reg-read --reg-add --reg-del \
|
||||
-s -t --batch \
|
||||
--eta --flush-session \
|
||||
--forms --fresh-queries --hex --parse-errors \
|
||||
--save --update \
|
||||
-z --beep --check-waf --cleanup \
|
||||
--dependencies --disable-coloring --identify-waf \
|
||||
--mobile --page-rank --purge-output --smart \
|
||||
--sqlmap-shell --wizard '
|
||||
COMPREPLY=( $( \
|
||||
(while read -d ' ' i; do
|
||||
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
|
||||
continue
|
||||
# flatten array with spaces on either side,
|
||||
# otherwise we cannot grep on word boundaries of
|
||||
# first and last word
|
||||
COMPREPLY=" ${COMPREPLY[@]} "
|
||||
# remove word from list of completions
|
||||
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
|
||||
done
|
||||
printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
|
||||
) )
|
||||
|
||||
# else
|
||||
# _filedir bat
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
complete -F _sqlmap sqlmap
|
||||
|
||||
fi
|
||||
40
dot_bash_it/completion/available/ssh.completion.bash
Normal file
40
dot_bash_it/completion/available/ssh.completion.bash
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for ssh.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_sshcomplete() {
|
||||
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ ${CURRENT_PROMPT} == *@* ]] ; then
|
||||
local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}"
|
||||
else
|
||||
local OPTIONS=" -- ${CURRENT_PROMPT}"
|
||||
fi
|
||||
|
||||
# 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 -Ee "s|^([^/~])|$HOME/.ssh/\1|" -e "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
|
||||
if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | grep -v ^\| | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) )
|
||||
fi
|
||||
fi
|
||||
|
||||
# parse hosts defined in /etc/hosts
|
||||
if [ -r /etc/hosts ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _sshcomplete ssh scp slogin sftp
|
||||
40
dot_bash_it/completion/available/svn.completion.bash
Normal file
40
dot_bash_it/completion/available/svn.completion.bash
Normal file
@@ -0,0 +1,40 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Locate and load completions for `svn`.
|
||||
|
||||
# Make sure svn is installed
|
||||
_command_exists svn || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
if _completion_exists svn; then
|
||||
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
|
||||
return 0
|
||||
fi
|
||||
|
||||
_svn_bash_completion_xcrun_svn=
|
||||
if _command_exists xcrun; then
|
||||
_svn_bash_completion_xcrun_svn="$(xcrun --find svn)"
|
||||
fi
|
||||
_svn_bash_completion_paths=(
|
||||
# Standard locations
|
||||
"${SVN_EXE%/*}/../etc/bash_completion.d/subversion"
|
||||
# MacOS non-system locations
|
||||
"${_svn_bash_completion_xcrun_svn%/bin/svn}/etc/bash_completion.d/subversion"
|
||||
)
|
||||
|
||||
# Load the first completion file found
|
||||
_svn_bash_completion_found=false
|
||||
for _comp_path in "${_svn_bash_completion_paths[@]}"; do
|
||||
if [[ -r "$_comp_path" ]]; then
|
||||
_svn_bash_completion_found=true
|
||||
# shellcheck disable=SC1090 # don't follow
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "${_svn_bash_completion_found}" == false ]]; then
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
fi
|
||||
unset "${!_svn_bash_completion@}"
|
||||
52
dot_bash_it/completion/available/system.completion.bash
Normal file
52
dot_bash_it/completion/available/system.completion.bash
Normal file
@@ -0,0 +1,52 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Loads the system's Bash completion modules.
|
||||
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
|
||||
|
||||
# Load before other completions
|
||||
# BASH_IT_LOAD_PRIORITY: 325
|
||||
|
||||
# Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
|
||||
if shopt -qo nounset; then
|
||||
__bash_it_restore_nounset=true
|
||||
shopt -uo nounset
|
||||
else
|
||||
__bash_it_restore_nounset=false
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090 disable=SC1091
|
||||
if [[ -r "${BASH_COMPLETION:-}" ]]; then
|
||||
source "${BASH_COMPLETION}"
|
||||
elif [[ -r /etc/bash_completion ]]; then
|
||||
source /etc/bash_completion
|
||||
# Some distribution makes use of a profile.d script to import completion.
|
||||
elif [[ -r /etc/profile.d/bash_completion.sh ]]; then
|
||||
source /etc/profile.d/bash_completion.sh
|
||||
elif _bash_it_homebrew_check; then
|
||||
: "${BASH_COMPLETION_COMPAT_DIR:=${BASH_IT_HOMEBREW_PREFIX}/etc/bash_completion.d}"
|
||||
case "${BASH_VERSION}" in
|
||||
1* | 2* | 3.0* | 3.1*)
|
||||
_log_warning "Cannot load completion due to version of shell. Are you using Bash 3.2+?"
|
||||
;;
|
||||
3.2* | 4.0* | 4.1*)
|
||||
# Import version 1.x of bash-completion, if installed.
|
||||
BASH_COMPLETION="${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@1/etc/bash_completion"
|
||||
if [[ -r "$BASH_COMPLETION" ]]; then
|
||||
source "$BASH_COMPLETION"
|
||||
else
|
||||
unset BASH_COMPLETION
|
||||
fi
|
||||
;;
|
||||
4.2* | 5* | *)
|
||||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
||||
if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh" ]]; then
|
||||
source "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ ${__bash_it_restore_nounset:-false} == "true" ]]; then
|
||||
shopt -so nounset
|
||||
fi
|
||||
unset __bash_it_restore_nounset
|
||||
10
dot_bash_it/completion/available/terraform.completion.bash
Normal file
10
dot_bash_it/completion/available/terraform.completion.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Make sure terraform is installed
|
||||
_command_exists terraform || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
complete -p terraform &>/dev/null && return
|
||||
|
||||
# Terraform completes itself
|
||||
complete -C terraform terraform
|
||||
@@ -0,0 +1,30 @@
|
||||
__kitchen_instance_list () {
|
||||
# cache to .kitchen.list.yml
|
||||
if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then
|
||||
# update list if config has updated
|
||||
kitchen list --bare > .kitchen.list.yml
|
||||
fi
|
||||
cat .kitchen.list.yml
|
||||
}
|
||||
|
||||
__kitchen_options () {
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
COMPREPLY=()
|
||||
|
||||
case $prev in
|
||||
converge|create|destroy|diagnose|list|login|setup|test|verify)
|
||||
COMPREPLY=( $(compgen -W "$(__kitchen_instance_list)" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
driver)
|
||||
COMPREPLY=( $(compgen -W "create discover help" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "console converge create destroy driver help init list login setup test verify version" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
complete -F __kitchen_options kitchen
|
||||
186
dot_bash_it/completion/available/tmux.completion.bash
Normal file
186
dot_bash_it/completion/available/tmux.completion.bash
Normal file
@@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# tmux completion
|
||||
# See: http://www.debian-administration.org/articles/317 for how to write more.
|
||||
# Usage: Put "source bash_completion_tmux.sh" into your .bashrc
|
||||
|
||||
_tmux_expand ()
|
||||
{
|
||||
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
|
||||
if [[ "$cur" == \~*/* ]]; then
|
||||
eval cur=$cur;
|
||||
else
|
||||
if [[ "$cur" == \~* ]]; then
|
||||
cur=${cur#\~};
|
||||
COMPREPLY=($( compgen -P '~' -u $cur ));
|
||||
return ${#COMPREPLY[@]};
|
||||
fi;
|
||||
fi
|
||||
}
|
||||
|
||||
_tmux_filedir ()
|
||||
{
|
||||
local IFS='
|
||||
';
|
||||
_tmux_expand || return 0;
|
||||
if [ "$1" = -d ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
|
||||
return 0;
|
||||
fi;
|
||||
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
|
||||
}
|
||||
|
||||
function _tmux_complete_client() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_session() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_window() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
|
||||
local sessions
|
||||
|
||||
sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')"
|
||||
if [[ -n "${session_name}" ]]; then
|
||||
sessions="${sessions}
|
||||
$(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')"
|
||||
fi
|
||||
cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
|
||||
sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
|
||||
}
|
||||
|
||||
_tmux() {
|
||||
local cur prev
|
||||
local i cmd cmd_index option option_index
|
||||
local opts=""
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ ${prev} == -f ]; then
|
||||
_tmux_filedir
|
||||
else
|
||||
# Search for the command
|
||||
local skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
cmd="${COMP_WORDS[i]}"
|
||||
cmd_index=${i}
|
||||
break
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Search for the last option command
|
||||
skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} == -* ]]; then
|
||||
option="${COMP_WORDS[i]}"
|
||||
option_index=${i}
|
||||
if [[ ${COMP_WORDS[i]} == -- ]]; then
|
||||
break;
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $COMP_CWORD -le $cmd_index ]]; then
|
||||
# The user has not specified a command yet
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") )
|
||||
else
|
||||
case ${cmd} in
|
||||
attach-session|attach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
detach-client|detach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-client|lockc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-session|locks)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
new-session|new)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
-[n|d|s]) options="-d -n -s -t --" ;;
|
||||
*)
|
||||
if [[ ${COMP_WORDS[option_index]} == -- ]]; then
|
||||
_command_offset ${option_index}
|
||||
else
|
||||
options="-d -n -s -t --"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
refresh-client|refresh)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
rename-session|rename)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
source-file|source) _tmux_filedir ;;
|
||||
has-session|has|kill-session)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
suspend-client|suspendc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
switch-client|switchc)
|
||||
case "$prev" in
|
||||
-c) _tmux_complete_client "${cur}" ;;
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-l -n -p -c -t" ;;
|
||||
esac ;;
|
||||
|
||||
send-keys|send)
|
||||
case "$option" in
|
||||
-t) _tmux_complete_window "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
esac # case ${cmd}
|
||||
fi # command specified
|
||||
fi # not -f
|
||||
|
||||
if [[ -n "${options}" ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
complete -F _tmux tmux
|
||||
|
||||
# END tmux completion
|
||||
2
dot_bash_it/completion/available/todo.completion.bash
Normal file
2
dot_bash_it/completion/available/todo.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_log_warning 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license.
|
||||
Please disable this completion and use the instructions from "todo.txt-cli" developers instead.'
|
||||
10
dot_bash_it/completion/available/travis.completion.bash
Normal file
10
dot_bash_it/completion/available/travis.completion.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists travis
|
||||
then
|
||||
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]
|
||||
then
|
||||
source "${__TRAVIS_COMPLETION_SCRIPT}"
|
||||
fi
|
||||
unset __TRAVIS_COMPLETION_SCRIPT
|
||||
fi
|
||||
163
dot_bash_it/completion/available/vagrant.completion.bash
Normal file
163
dot_bash_it/completion/available/vagrant.completion.bash
Normal file
@@ -0,0 +1,163 @@
|
||||
#!/bin/bash
|
||||
|
||||
# (The MIT License)
|
||||
#
|
||||
# Copyright (c) 2014 Kura
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the 'Software'), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
__pwdln() {
|
||||
pwdmod="${PWD}/"
|
||||
itr=0
|
||||
until [[ -z "$pwdmod" ]];do
|
||||
itr=$(($itr+1))
|
||||
pwdmod="${pwdmod#*/}"
|
||||
done
|
||||
echo -n $(($itr-1))
|
||||
}
|
||||
|
||||
__vagrantinvestigate() {
|
||||
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
|
||||
echo "${PWD}/.vagrant"
|
||||
return 0
|
||||
else
|
||||
pwdmod2="${PWD}"
|
||||
for (( i=2; i<=$(__pwdln); i++ ));do
|
||||
pwdmod2="${pwdmod2%/*}"
|
||||
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ];then
|
||||
echo "${pwdmod2}/.vagrant"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
_vagrant() {
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
commands="box cloud destroy global-status halt help hostmanager init login package plugin port powershell provision push rdp reload resume scp snapshot ssh ssh-config status suspend up upload validate vbguest version winrm winrm-config"
|
||||
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
"init")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"up")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -d $vagrant_state_file ]]
|
||||
then
|
||||
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||
fi
|
||||
local up_commands="--no-provision"
|
||||
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||
if [[ -f $vagrant_state_file ]]
|
||||
then
|
||||
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
||||
else
|
||||
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"box")
|
||||
box_commands="add list outdated prune remove repackage update"
|
||||
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"plugin")
|
||||
plugin_commands="expunge install license list repair uninstall update"
|
||||
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"help")
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"snapshot")
|
||||
snapshot_commands="delete list pop push restore save"
|
||||
COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 3 ]
|
||||
then
|
||||
action="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "$action" in
|
||||
"up")
|
||||
if [ "$prev" == "--no-provision" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"box")
|
||||
case "$prev" in
|
||||
"remove"|"repackage")
|
||||
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
;;
|
||||
"snapshot")
|
||||
if [ "$prev" == "restore" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 4 ]
|
||||
then
|
||||
action="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "$action" in
|
||||
"snapshot")
|
||||
if [ "$prev" == "restore" ]; then
|
||||
local snapshot_list="$(vagrant snapshot list ${cur} 2>/dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
|
||||
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
complete -F _vagrant vagrant
|
||||
7
dot_bash_it/completion/available/vault.completion.bash
Normal file
7
dot_bash_it/completion/available/vault.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "vault completion"
|
||||
|
||||
if _binary_exists vault; then
|
||||
complete -C vault vault
|
||||
fi
|
||||
2
dot_bash_it/completion/available/virsh.completion.bash
Normal file
2
dot_bash_it/completion/available/virsh.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_log_warning 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license.
|
||||
Please disable this completion and use the instructions from "virsh" developers instead.'
|
||||
222
dot_bash_it/completion/available/virtualbox.completion.bash
Normal file
222
dot_bash_it/completion/available/virtualbox.completion.bash
Normal file
@@ -0,0 +1,222 @@
|
||||
#!/usr/bin/bash
|
||||
_vboxmanage_realopts() {
|
||||
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
|
||||
echo " "
|
||||
}
|
||||
|
||||
__vboxmanage_startvm() {
|
||||
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
|
||||
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
|
||||
|
||||
AVAILABLE=""
|
||||
for VM in $TOTAL; do
|
||||
MATCH=0;
|
||||
for RUN in $RUNNING "x"; do
|
||||
if [ "$VM" == "$RUN" ]; then
|
||||
MATCH=1
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
|
||||
done
|
||||
echo $AVAILABLE
|
||||
}
|
||||
|
||||
__vboxmanage_list() {
|
||||
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
|
||||
|
||||
PRUNED=""
|
||||
if [ "$1" == "long" ]; then
|
||||
for WORD in $INPUT; do
|
||||
[ "$WORD" == "-l" ] && continue;
|
||||
[ "$WORD" == "--long" ] && continue;
|
||||
|
||||
PRUNED="$PRUNED $WORD"
|
||||
done
|
||||
else
|
||||
PRUNED=$INPUT
|
||||
fi
|
||||
|
||||
echo $PRUNED
|
||||
}
|
||||
|
||||
|
||||
__vboxmanage_list_vms() {
|
||||
VMS=""
|
||||
if [ "x$1" == "x" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
}
|
||||
|
||||
__vboxmanage_list_runningvms() {
|
||||
VMS=""
|
||||
if [ "$1" == "" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
|
||||
}
|
||||
|
||||
__vboxmanage_controlvm() {
|
||||
echo "pause resume reset poweroff savestate acpipowerbutton"
|
||||
echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
|
||||
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
|
||||
echo "vrdeproperty vrdevideochannelquality setvideomodehint"
|
||||
echo "screenshotpng setcredentials teleport plugcpu unplugcpu"
|
||||
echo "cpuexecutioncap"
|
||||
|
||||
# setlinkstate<1-N>
|
||||
# nic<1-N> null|nat|bridged|intnet|hostonly|generic
|
||||
# [<devicename>] |
|
||||
# nictrace<1-N> on|off
|
||||
# nictracefile<1-N> <filename>
|
||||
# nicproperty<1-N> name=[value]
|
||||
# natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
|
||||
# <hostport>,[<guestip>],<guestport>
|
||||
# natpf<1-N> delete <rulename>
|
||||
|
||||
}
|
||||
|
||||
__vboxmanage_default() {
|
||||
realopts=$(_vboxmanage_realopts)
|
||||
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
|
||||
pruned=""
|
||||
|
||||
# echo ""
|
||||
# echo "DEBUG: cur: $cur, prev: $prev"
|
||||
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
|
||||
case ${cur} in
|
||||
-*)
|
||||
echo $opts
|
||||
# COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac;
|
||||
|
||||
for WORD in $opts; do
|
||||
MATCH=0
|
||||
for OPT in "${COMP_WORDS[@]}"; do
|
||||
# opts=$(echo ${opts} | grep -v $OPT);
|
||||
if [ "$OPT" == "$WORD" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 1 )) && continue;
|
||||
pruned="$pruned $WORD"
|
||||
|
||||
done
|
||||
|
||||
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
|
||||
echo $pruned
|
||||
return 0
|
||||
}
|
||||
|
||||
_vboxmanage() {
|
||||
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
|
||||
local cur p1 p2 p3 p4 opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# echo "cur: |$cur|"
|
||||
# echo "prev: |$prev|"
|
||||
|
||||
# In case current is complete command
|
||||
case $cur in
|
||||
startvm|list|controlvm)
|
||||
COMPREPLY=($(compgen -W "$cur "))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case $prev in
|
||||
-v|--version)
|
||||
return 0
|
||||
;;
|
||||
|
||||
-l|--long)
|
||||
opts=$(__vboxmanage_list "long")
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
startvm|list)
|
||||
opts=$(__vboxmanage_$prev)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--type)
|
||||
COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
gui|headless)
|
||||
# Done. no more completion possible
|
||||
return 0
|
||||
;;
|
||||
vboxmanage|-q|--nologo)
|
||||
# echo "Got vboxmanage"
|
||||
opts=$(__vboxmanage_default)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_list_vms)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
for VM in $(__vboxmanage_list_vms); do
|
||||
if [ "$VM" == "$prev" ]; then
|
||||
pprev=${COMP_WORDS[COMP_CWORD-2]}
|
||||
# echo "previous: $pprev"
|
||||
case $pprev in
|
||||
startvm)
|
||||
opts="--type"
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_controlvm)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0;
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
# echo "Got to end withoug completion"
|
||||
}
|
||||
complete -F _vboxmanage vboxmanage
|
||||
61
dot_bash_it/completion/available/vuejs.completion.bash
Normal file
61
dot_bash_it/completion/available/vuejs.completion.bash
Normal file
@@ -0,0 +1,61 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__vuejs_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
create)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr"))
|
||||
;;
|
||||
add | invoke)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
|
||||
;;
|
||||
inspect)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
|
||||
;;
|
||||
serve)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
|
||||
;;
|
||||
build)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
|
||||
;;
|
||||
ui)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
|
||||
;;
|
||||
init)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
|
||||
;;
|
||||
config)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
|
||||
;;
|
||||
outdated)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
|
||||
;;
|
||||
upgrade)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
|
||||
;;
|
||||
migrate)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __vuejs_completion vue
|
||||
16
dot_bash_it/completion/available/wpscan.completion.bash
Normal file
16
dot_bash_it/completion/available/wpscan.completion.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
_command_exists wpscan || return
|
||||
|
||||
function __wpscan_completion() {
|
||||
local _opt_
|
||||
local OPTS=('--help' '--hh' '--version' '--url' '--ignore-main-redirect' '--verbose' '--output' '--format' '--detection-mode' '--scope' '--headers' '--user-agent' '--vhost' '--random-user-agent' '--user-agents-list' '--http-auth' '--max-threads' '--throttle' '--request-timeout' '--connect-timeout' '--disable-tlc-checks' '--proxy' '--proxy-auth' '--cookie-string' '--cookie-jar' '--cache-ttl' '--clear-cache' '--server' '--cache-dir' '--update' '--no-update' '--wp-content-dir' '--wp-plugins-dir' '--wp-version-detection' '--main-theme-detection' '--enumerate' '--exclude-content-based' '--plugins-list' '--plugins-detection' '--plugins-version-all' '--plugins-version-detection' '--themes-list' '--themes-detection' '--themes-version-all' '--themes-version-detection' '--timthumbs-list' '--timthumbs-detection' '--config-backups-list' '--config-backups-detection' '--db-exports-list' '--db-exports-detection' '--medias-detection' '--users-list' '--users-detection' '--passwords' '--usernames' '--multicall-max-passwords' '--password-attack' '--stealthy')
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __wpscan_completion wpscan
|
||||
4
dot_bash_it/custom/example.bash
Normal file
4
dot_bash_it/custom/example.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This is an example file. Don't use this for your custom scripts. Instead, create another file within the
|
||||
# custom directory.
|
||||
20
dot_bash_it/docs/Makefile
Normal file
20
dot_bash_it/docs/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
64
dot_bash_it/docs/README.md
Normal file
64
dot_bash_it/docs/README.md
Normal file
@@ -0,0 +1,64 @@
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
[](https://web.libera.chat/?channel=#bash-it)
|
||||
|
||||
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
|
||||
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
|
||||
|
||||
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
|
||||
|
||||
Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work.
|
||||
If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you!
|
||||
Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away.
|
||||
|
||||
- [Main Page](https://bash-it.readthedocs.io/en/latest)
|
||||
- [Contributing](#contributing)
|
||||
- [Installation](#installation)
|
||||
- [Install Options](https://bash-it.readthedocs.io/en/latest/installation/#install-options)
|
||||
- [via Docker](https://bash-it.readthedocs.io/en/latest/installation/#install-using-docker)
|
||||
- [Updating](https://bash-it.readthedocs.io/en/latest/installation/#updating)
|
||||
- [Help](https://bash-it.readthedocs.io/en/latest/misc/#help-screens)
|
||||
- [Search](https://bash-it.readthedocs.io/en/latest/commands/search)
|
||||
- [Syntax](https://bash-it.readthedocs.io/en/latest/commands/search/#syntax)
|
||||
- [Searching with Negations](
|
||||
https://bash-it.readthedocs.io/en/latest/commands/search/#searching-with-negations)
|
||||
- [Using Search to Enable or Disable Components](https://bash-it.readthedocs.io/en/latest/commands/search/#using-search-to-enable-or-disable-components)
|
||||
- [Disabling ASCII Color](https://bash-it.readthedocs.io/en/latest/commands/search/#disabling-ascii-color)
|
||||
- [Custom scripts, aliases, themes, and functions](
|
||||
https://bash-it.readthedocs.io/en/latest/custom)
|
||||
- [Themes](https://bash-it.readthedocs.io/en/latest/themes)
|
||||
- [Uninstalling](https://bash-it.readthedocs.io/en/latest/uninstalling)
|
||||
- [Misc](https://bash-it.readthedocs.io/en/latest/misc)
|
||||
- [Help Out](https://bash-it.readthedocs.io/en/latest/#help-out)
|
||||
- [Contributors](#contributors)
|
||||
|
||||
## Installation
|
||||
|
||||
1) Check out a clone of this repo to a location of your choice, such as
|
||||
``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it``
|
||||
2) Run ``~/.bash_it/install.sh``
|
||||
|
||||
That's it! :smiley:
|
||||
|
||||
You can check out more components of Bash-it, and customize it to your desire.
|
||||
For more information, see detailed instructions [here](https://bash-it.readthedocs.io/en/latest/installation/).
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Please take a look at the [Contribution Guidelines](https://bash-it.readthedocs.io/en/latest/contributing) before reporting a bug or providing a new feature.
|
||||
|
||||
The [Development Guidelines](https://bash-it.readthedocs.io/en/latest/development) have more information on some of the internal workings of Bash-it,
|
||||
please feel free to read through this page if you're interested in how Bash-it loads its components.
|
||||
|
||||
## Contributors
|
||||
|
||||
[List of contributors](https://github.com/Bash-it/bash-it/contributors)
|
||||
|
||||
## License
|
||||
|
||||
Bash-it is licensed under the [MIT License](https://github.com/Bash-it/bash-it/blob/master/LICENSE).
|
||||
20
dot_bash_it/docs/commands/doctor.rst
Normal file
20
dot_bash_it/docs/commands/doctor.rst
Normal file
@@ -0,0 +1,20 @@
|
||||
.. _doctor:
|
||||
|
||||
Bash-it doctor
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
If you encounter problems with any part of Bash-it, run the following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it doctor
|
||||
|
||||
This will reload your bash profile and print out logs of various parts in Bash-it.
|
||||
Note that this command at default will print all logs, including debug logs.
|
||||
You can call it like this:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it doctor [errors/warnings/all]
|
||||
|
||||
In order to get wanted verbosity.
|
||||
16
dot_bash_it/docs/commands/index.rst
Normal file
16
dot_bash_it/docs/commands/index.rst
Normal file
@@ -0,0 +1,16 @@
|
||||
.. _commands:
|
||||
|
||||
Bash-it Commands
|
||||
================
|
||||
|
||||
**Bash-it** boasts a wide range of available commands.
|
||||
You should be familiar with them in order to fully utilize Bash-it.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
update
|
||||
search
|
||||
reload
|
||||
doctor
|
||||
profile
|
||||
31
dot_bash_it/docs/commands/profile.rst
Normal file
31
dot_bash_it/docs/commands/profile.rst
Normal file
@@ -0,0 +1,31 @@
|
||||
.. _profile:
|
||||
|
||||
Bash-it Profile
|
||||
---------------
|
||||
|
||||
Have you ever wanted to port your *Bash-it* configuration into another machine?
|
||||
|
||||
If you did, then ``bash-it profile`` is for you!
|
||||
|
||||
This command can save and load custom *"profile"* files, that can be later
|
||||
used to load and recreate your configuration, in any machine you would like |:smile:|
|
||||
|
||||
When porting your configuration into a new machine, you just need to save your current profile, copy the resulting *"profile"* file, and load it in the other machine.
|
||||
|
||||
Example
|
||||
^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Saves your current profile
|
||||
bash-it profile save my_profile
|
||||
# Load the default profile, which is the one used in the default installation.
|
||||
bash-it profile load default
|
||||
|
||||
# Do whatever you want:
|
||||
# Disable stuff
|
||||
bash-it disable ...
|
||||
# Enable stuff
|
||||
bash-it enable ...
|
||||
# If you want to get back into your original configuration, you can do it easily
|
||||
bash-it profile load my_profile
|
||||
23
dot_bash_it/docs/commands/reload.rst
Normal file
23
dot_bash_it/docs/commands/reload.rst
Normal file
@@ -0,0 +1,23 @@
|
||||
.. _reload:
|
||||
|
||||
Bash-it reload
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Bash-it creates a ``reload`` alias that makes it convenient to reload
|
||||
your Bash profile when you make changes.
|
||||
|
||||
Additionally, if you export ``BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE`` as a non-null value,
|
||||
Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions.
|
||||
|
||||
.. warning::
|
||||
When changing theme, do not use ``bash-it reload``. Instead, use :ref:`restart`.
|
||||
|
||||
.. _restart:
|
||||
|
||||
Bash-it restart
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Similar to :ref:`reload`, ``bash-it restart`` can be used to restart your shell.
|
||||
Instead of reloading your Bash profile, this command re-runs Bash (using exec).
|
||||
|
||||
This is stronger than simple reload, and is similar to the effect of closing and reopening your terminal.
|
||||
59
dot_bash_it/docs/commands/search.rst
Normal file
59
dot_bash_it/docs/commands/search.rst
Normal file
@@ -0,0 +1,59 @@
|
||||
.. _searching:
|
||||
|
||||
Bash-it search
|
||||
--------------
|
||||
|
||||
If you need to quickly find out which of the plugins, aliases or completions are available for a specific framework, programming language, or an environment, you can *search* for multiple terms related to the commands you use frequently.
|
||||
Search will find and print out modules with the name or description matching the terms provided.
|
||||
|
||||
Syntax
|
||||
^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it search term1 [[-]term2] [[-]term3]....
|
||||
|
||||
As an example, a ruby developer might want to enable everything related to the commands such as ``ruby``\ , ``rake``\ , ``gem``\ , ``bundler``\ , and ``rails``.
|
||||
Search command helps you find related modules so that you can decide which of them you'd like to use:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
❯ bash-it search ruby rake gem bundle irb rails
|
||||
aliases: bundler rails
|
||||
plugins: chruby chruby-auto ruby
|
||||
completions: bundler gem rake
|
||||
|
||||
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.
|
||||
In the above example, if we wanted to hide ``chruby`` and ``chruby-auto``\ ,
|
||||
we could change the command as follows:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
❯ bash-it search ruby rake gem bundle irb rails -chruby
|
||||
aliases: bundler rails
|
||||
plugins: ruby
|
||||
completions: bundler gem rake
|
||||
|
||||
Using Search to Enable or Disable Components
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
By adding a ``--enable`` or ``--disable`` to the search command, you can automatically enable all modules that come up as a result of a search query.
|
||||
This could be quite handy if you like to enable a bunch of components related to the same topic.
|
||||
|
||||
Disabling ASCII Color
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To remove non-printing non-ASCII characters responsible for the coloring of the search output, you can set environment variable ``NO_COLOR``.
|
||||
Enabled components will then be shown with a checkmark:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
❯ NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby
|
||||
aliases => ✓bundler ✓rails
|
||||
plugins => ✓ruby
|
||||
completions => bundler gem rake
|
||||
38
dot_bash_it/docs/commands/update.rst
Normal file
38
dot_bash_it/docs/commands/update.rst
Normal file
@@ -0,0 +1,38 @@
|
||||
.. _update:
|
||||
|
||||
Bash-it update
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
To update Bash-it to the latest stable version, simply run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it update stable
|
||||
|
||||
If you want to update to the latest dev version (directly from master), run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it update dev
|
||||
|
||||
If you want to update automatically and unattended, you can add the optional
|
||||
``-s/--silent`` flag, for example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it update dev --silent
|
||||
|
||||
.. _migrate:
|
||||
|
||||
Bash-it migrate
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
If you are using an older version of Bash-it, it's possible that some functionality has changed, or that the internal structure of how Bash-it organizes its functionality has been updated.
|
||||
For these cases, we provide a ``migrate`` command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it migrate
|
||||
|
||||
This command will automatically migrate the Bash-it structure to the latest version.
|
||||
The ``migrate`` command is run automatically if you run the ``update``\ , ``enable`` or ``disable`` commands.
|
||||
57
dot_bash_it/docs/conf.py
Normal file
57
dot_bash_it/docs/conf.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'Bash-it'
|
||||
copyright = '2020, Bash-it Team'
|
||||
author = 'Bash-it Team'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = ''
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx_rtd_theme',
|
||||
'sphinxemoji.sphinxemoji',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
115
dot_bash_it/docs/contributing.rst
Normal file
115
dot_bash_it/docs/contributing.rst
Normal file
@@ -0,0 +1,115 @@
|
||||
.. _contributing:
|
||||
|
||||
Contribution Guidelines
|
||||
=======================
|
||||
|
||||
When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines.
|
||||
Most of this is common sense, but please try to stick to the conventions listed here.
|
||||
|
||||
Issues
|
||||
------
|
||||
|
||||
|
||||
* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature.
|
||||
Don't be afraid, most things aren't that complex...
|
||||
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
|
||||
* Fork the Bash-it repo, create a new feature branch from *master* and apply your changes there.
|
||||
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 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
|
||||
----------
|
||||
|
||||
|
||||
* When adding new files, be sure to add them into `clean_files.txt`, which is a growing list of linted files in the project.
|
||||
* When changing existing files, consider also adding them into `clean_files.txt` and fixing the linting errors that arise. See :ref:`linting_your_changes` for more information.
|
||||
* Indentation is using tabs, not spaces. Most of the code is indented with 2 spaces, some with 4 spaced tabs. Please try to stick to tabs.
|
||||
If you're using an editor that supports `EditorConfig <http://EditorConfig.org>`_\ , the editor should automatically use the settings defined in Bash-it's `.editorconfig file <.editorconfig>`_.
|
||||
* Prefer to invoke commands directly using the ``command`` shell builtin. This way, your code
|
||||
will always execute the command you wanted and not an alias/function that overrides the name of the command. (For example, use ``command rm`` instead of ``rm``)
|
||||
* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. ``my-new-function``.
|
||||
Don't use underscores, e.g. ``my_new_function``.
|
||||
* Internal functions that aren't to be used by the end user should start with an underscore, e.g. ``_my-new-internal-function``.
|
||||
* Use the provided meta functions to document your code, e.g. ``about-plugin``\ , ``about``\ , ``group``\ , ``param``\ , ``example``.
|
||||
This will make it easier for other people to use your new functionality.
|
||||
Take a look at the existing code for an example (e.g. `the base plugin <plugins/available/base.plugin.bash>`_\ ).
|
||||
* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in ``.plugin.bash``.
|
||||
This is important for the installation functionality.
|
||||
* When using the ``$BASH_IT`` variable, please always enclose it in double quotes to ensure that the code also works when Bash-it is installed in a directory that contains spaces in its name: ``for f in "${BASH_IT}/plugins/available"/*.bash ; do echo "$f" ; done``
|
||||
* Bash-it supports Bash 3.2 and higher. Please don't use features only available in Bash 4, such as associative arrays.
|
||||
|
||||
Unit Tests
|
||||
----------
|
||||
|
||||
When adding features or making changes/fixes, please run our growing unit test suite to ensure that you did not break existing functionality.
|
||||
The test suite does not cover all aspects of Bash-it, but please run it anyway to verify that you did not introduce any regression issues.
|
||||
|
||||
Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on `GitHub Actions <https://github.com/Bash-it/bash-it/actions>`_\ , where the test suite is run on both Linux and macOS.
|
||||
The Pull Request will then show the result of the CI build, indicating whether all tests ran fine, or whether there were issues.
|
||||
Please pay attention to this, Pull Requests with build issues will not be merged.
|
||||
|
||||
Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage.
|
||||
When you're changing the Bash-it codebase, please consider adding some unit tests that cover the new or changed functionality.
|
||||
Ideally, when fixing a bug, a matching unit test that verifies that the bug is no longer present, is added at the same time.
|
||||
|
||||
To run the test suite, simply execute the following in the directory where you cloned Bash-it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
test/run
|
||||
|
||||
This command will ensure that the `Bats Test Framework <https://github.com/bats-core/bats-core>`_ is available in the local ``test_lib`` directory (Bats is included as a Git submodule) and then run the test suite found in the `test <test>`_ folder.
|
||||
The test script will execute each test in turn, and will print a status for each test case.
|
||||
|
||||
When adding new test cases, please take a look at the existing test cases for examples.
|
||||
|
||||
The following libraries are used to help with the tests:
|
||||
|
||||
|
||||
* Test Framework: https://github.com/bats-core/bats-core
|
||||
* Support library for Bats-Assert: https://github.com/ztombol/bats-support
|
||||
* General ``assert`` functions: https://github.com/ztombol/bats-assert
|
||||
* File ``assert`` functions: https://github.com/ztombol/bats-file
|
||||
|
||||
When verifying test results, please try to use the ``assert`` functions found in these libraries.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
|
||||
* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead.
|
||||
An example is using ``nvm``\ : Instead of copying the existing ``nvm`` script into Bash-it, the ``nvm.plugin.bash`` file tries to load an existing installation of ``nvm``.
|
||||
This means an additional step for the user (installing ``nvm`` from its own repo, or through a package manager),
|
||||
but it will also ensure that ``nvm`` can be upgraded in an easy way.
|
||||
|
||||
.. _contributing_theme:
|
||||
|
||||
Themes
|
||||
------
|
||||
|
||||
|
||||
* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request's description field.
|
||||
Please do not add theme screenshots to the main PR itself, as they will add unnecessary bloat to the main branch in the repo.
|
||||
The project's docs has a `Themes page <https://github.com/Bash-it/bash-it/blob/master/docs/themes-list/index.rst>`_ where you should add a screenshot, see how :ref:`here<add_screenshot>`.
|
||||
* Ideally, you should add a ``<theme_name>.rst`` file describing the theme and its configuration options to ``docs/themes-list`` folder.
|
||||
|
||||
.. _add_screenshot:
|
||||
|
||||
Adding a Screenshot
|
||||
-------------------
|
||||
|
||||
In order to add a new screenshot, use the ``gh-pages`` branch.
|
||||
Add your new screenshot to the ``docs/images`` folder, and open a PR.
|
||||
In the `Themes page <https://github.com/Bash-it/bash-it/blob/master/docs/themes-list/index.rst>`_, see the other screenshots to know what kind of link you should use.
|
||||
18
dot_bash_it/docs/custom.rst
Normal file
18
dot_bash_it/docs/custom.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
.. _custom:
|
||||
|
||||
Custom Content
|
||||
--------------
|
||||
|
||||
For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo):
|
||||
|
||||
|
||||
* ``aliases/custom.aliases.bash``
|
||||
* ``completion/custom.completion.bash``
|
||||
* ``lib/custom.bash``
|
||||
* ``plugins/custom.plugins.bash``
|
||||
* ``custom/themes/<custom theme name>/<custom theme name>.theme.bash``
|
||||
|
||||
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.
|
||||
In this case, any ``*.bash`` file under every directory below ``BASH_IT_CUSTOM`` folder will be used.
|
||||
180
dot_bash_it/docs/development.rst
Normal file
180
dot_bash_it/docs/development.rst
Normal file
@@ -0,0 +1,180 @@
|
||||
.. _development:
|
||||
|
||||
Bash-it Development
|
||||
===================
|
||||
|
||||
This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
Make sure to read the :ref:`testing docs<test>`.
|
||||
|
||||
Debugging and Logging
|
||||
---------------------
|
||||
|
||||
General Logging
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
While developing feature or making changes in general, you can log error/warning/debug
|
||||
using ``_log_error`` ``_log_warning`` and ``_log_debug``. This will help you solve problems quicker
|
||||
and also propagate important notes to other users of Bash-it.
|
||||
You can see the logs by using ``bash-it doctor`` command to reload and see the logs.
|
||||
Alternatively, you can set ``BASH_IT_LOG_LEVEL`` to ``BASH_IT_LOG_LEVEL_ERROR``\ , ``BASH_IT_LOG_LEVEL_WARNING`` or ``BASH_IT_LOG_LEVEL_ALL``.
|
||||
|
||||
Log Prefix/Context
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can define ``BASH_IT_LOG_PREFIX`` in your files in order to a have a constant prefix before your logs.
|
||||
Note that we prefer to uses "tags" based logging, i.e ``plugins: git: DEBUG: Loading git plugin``.
|
||||
|
||||
Load Order
|
||||
----------
|
||||
|
||||
General Load Order
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The main ``bash_it.sh`` script loads the frameworks individual components in the following order:
|
||||
|
||||
|
||||
|
||||
|
||||
* ``vendor/github.com/erichs/composure/composure.sh``
|
||||
* ``lib/log.bash``
|
||||
* ``vendor/init.d/*.bash``
|
||||
* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``log.bash`` is loaded again here (possible improvement?)
|
||||
* Enabled ``aliases``
|
||||
* Enabled ``plugins``
|
||||
* Enabled ``completions``
|
||||
* ``themes/colors.theme.bash``
|
||||
* ``themes/base.theme.bash``
|
||||
* ``lib/appearance.bash``\ , which loads the selected theme
|
||||
* Custom ``aliases``
|
||||
* Custom ``plugins``
|
||||
* Custom ``completions``
|
||||
* Additional custom files from either ``$BASH_IT/custom`` or ``$BASH_IT_CUSTOM``
|
||||
|
||||
This order is subject to change.
|
||||
|
||||
Individual Component Load Order
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are applied that influence the load order:
|
||||
|
||||
|
||||
* There is a global ``enabled`` directory, which the enabled components are linked into. Enabled plugins are symlinked from ``$BASH_IT/plugins/available`` to ``$BASH_IT/enabled`` for example. All component types are linked into the same common ``$BASH_IT/enabled`` directory.
|
||||
* Within the common ``enabled`` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item).
|
||||
* When enabling a component, a *load priority* is assigned to the file. The following default priorities are used:
|
||||
|
||||
* Aliases: 150
|
||||
* Plugins: 250
|
||||
* Completions: 350
|
||||
|
||||
* When symlinking a component into the ``enabled`` directory, the load priority is used as a prefix for the linked name, separated with three dashes from the name of the component. The ``node.plugin.bash`` would be symlinked to ``250---node.plugin.bash`` for example.
|
||||
*
|
||||
Each file can override the default load priority by specifying a new value. To do this, the file needs to include a comment in the following form. This example would cause the ``node.plugin.bash`` (if included in that file) to be linked to ``225---node.plugin.bash``\ :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# BASH_IT_LOAD_PRIORITY: 225
|
||||
|
||||
Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name.
|
||||
|
||||
These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well.
|
||||
|
||||
Working with vendored libs
|
||||
--------------------------
|
||||
|
||||
Vendored libs are external libraries, meaning source code not maintained by Bash-it
|
||||
developers.
|
||||
They are ``git subtrees`` curated in the ``vendor/`` folder. To ease the work with git
|
||||
vendored libs as subtrees we use the `git-vendor <https://github.com/Tyrben/git-vendor>`_ tool.
|
||||
The `original repo <https://github.com/brettlangdon/git-vendor>`_ for git vendor is
|
||||
unmaintained so for now we are recommending Tyrben's fork.
|
||||
|
||||
For more information on ``git vendor`` there are a short `usage description <https://github.com/Tyrben/git-vendor#usage>`_
|
||||
in the repositories ``README`` file and a website for the original repository has a `manual page <https://brettlangdon.github.io/git-vendor/>`_ which is also included in both
|
||||
repositories.
|
||||
|
||||
To support a flexible loading of external libraries, a file unique to the vendored
|
||||
library must be placed in ``vendor/init.d/`` with the ``.bash`` extension.
|
||||
|
||||
Rebasing a feature branch with an added/updated vendored library
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If your feature branch with a newly added/updated vendored lib has fallen behind master
|
||||
you might need to rebase it before creating a PR. However rebasing with dangling
|
||||
subtree commits can cause problems.
|
||||
The following rebase strategy will pause the rebase at the point where you added a
|
||||
subtree and let you add it again before continuing the rebasing.
|
||||
|
||||
::
|
||||
|
||||
[feature/branch] $ git rebase --rebase-merges --strategy subtree master
|
||||
fatal: refusing to merge unrelated histories
|
||||
Could not apply 0d6a56b... Add-preexec-from-https-github-com-rcaloras-bash-preexec-0-4-1- # Add "preexec" from "https://github.com/rcaloras/bash-preexec@0.4.1"
|
||||
[feature/branch] $ git vendor add preexec https://github.com/rcaloras/bash-preexec 0.4.1
|
||||
...
|
||||
[feature/branch] $ git rebase --continue
|
||||
|
||||
If rebasing makes you a little uneasy (as it probably should). You can always test in
|
||||
another branch.
|
||||
|
||||
::
|
||||
|
||||
[feater/branch] $ git checkout -b feature/branch-test-rebase
|
||||
[feater/branch-test-rebase] $ git rebase --rebase-merges --strategy subtree master
|
||||
...
|
||||
|
||||
Afterwards you can make sure the rebase was successful by running ``git vendor list``
|
||||
to see if your library is still recognized as a vendored lib
|
||||
|
||||
::
|
||||
|
||||
[feature/branch] $ git vendor list
|
||||
preexec@0.4.1:
|
||||
name: preexec
|
||||
dir: vendor/github.com/rcaloras/bash-preexec
|
||||
repo: https://github.com/rcaloras/bash-preexec
|
||||
ref: 0.4.1
|
||||
commit: 8fe585c5cf377a3830b895fe26e694b020d8db1a
|
||||
[feature/branch] $
|
||||
|
||||
|
||||
Plugin Disable Callbacks
|
||||
------------------------
|
||||
|
||||
Plugins can define a function that will be called when the plugin is being disabled.
|
||||
The callback name should be ``{PLUGIN_NAME}_on_disable``\ , you can see ``gitstatus`` for usage example.
|
||||
|
||||
Library Finalization Callback
|
||||
-----------------------------
|
||||
|
||||
Specifically for Bash-it library code, e.g. in the `lib` subdirectory, a hook is available to run some code at the very end of the main loader script after all other code has been loaded. For example, `lib/theme` uses `_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')` to add a function to be called after all plugins have been loaded.
|
||||
|
||||
Using the pre-commit hook
|
||||
-------------------------
|
||||
|
||||
Note the file .pre-commit-config.yaml at the top of the repo.
|
||||
This file configures the behavior of the a pre-commit hook based on `the Pre-Commit framework <https://pre-commit.com/>`_. Please see the site about
|
||||
installing it (with pip, brew or other tools) then run ``pre-commit install`` in the repo's root to activate the hook.
|
||||
For the full use of the tool, you may need to install also other third-party tools, such as
|
||||
`shellcheck <https://github.com/koalaman/shellcheck/>`_ and `shfmt <https://github.com/mvdan/sh>`_.
|
||||
|
||||
|
||||
.. _linting_your_changes:
|
||||
|
||||
Linting Your Changes
|
||||
--------------------
|
||||
|
||||
In order to properly lint your changes, you should use our linting script,
|
||||
by simply running ``./lint_clean_files.sh``. This script iterates over all marked-as-clean
|
||||
files, and runs the pre-commit hook on them.
|
||||
|
||||
Please note that most of the files in the project are currently not linted,
|
||||
as we want to make the linting process easier.
|
||||
In order to add your changed/added files to the linting process,
|
||||
please add your files to ``clean_files.txt``. This way ``lint_clean_files.sh``
|
||||
will know to pick them up and lint them.
|
||||
|
||||
Thank you for helping clean up Bash-it, and making it a nicer and better project |:heart:|
|
||||
13
dot_bash_it/docs/help_screens.rst
Normal file
13
dot_bash_it/docs/help_screens.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _help_screens:
|
||||
|
||||
Help Screens
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it show aliases # shows installed and available aliases
|
||||
bash-it show completions # shows installed and available completions
|
||||
bash-it show plugins # shows installed and available plugins
|
||||
bash-it help aliases # shows help for installed aliases
|
||||
bash-it help completions # shows help for installed completions
|
||||
bash-it help plugins # shows help for installed plugins
|
||||
44
dot_bash_it/docs/index.rst
Normal file
44
dot_bash_it/docs/index.rst
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
Welcome to Bash-it's documentation!
|
||||
===================================
|
||||
|
||||
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
|
||||
(And a shameless ripoff of `oh-my-zsh <https://github.com/robbyrussell/oh-my-zsh>`_)
|
||||
|
||||
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
|
||||
|
||||
Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work.
|
||||
If you're using the *Bourne Again Shell* (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you!
|
||||
Stop polluting your ``~/bin`` directory and your ``.bashrc`` file, fork/clone Bash-it and start hacking away.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
contributing
|
||||
development
|
||||
test
|
||||
installation
|
||||
commands/index
|
||||
custom
|
||||
themes
|
||||
themes-list/index
|
||||
vcs_user
|
||||
misc
|
||||
troubleshooting
|
||||
uninstalling
|
||||
|
||||
|
||||
Help out
|
||||
--------
|
||||
|
||||
We think everyone has their own custom scripts accumulated over time.
|
||||
And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell.
|
||||
Everyone's got a custom toolbox, so let's start making them even better, **as a community!**
|
||||
|
||||
Send us a pull request and we'll merge it as long as it looks good.
|
||||
If you change an existing command, please give an explanation why.
|
||||
That will help a lot when we merge your changes in.
|
||||
|
||||
Please take a look at the :ref:`Contribution Guidelines <contributing>` before reporting a bug or providing a new feature.
|
||||
|
||||
Thanks, and happing bashing!
|
||||
58
dot_bash_it/docs/installation.rst
Normal file
58
dot_bash_it/docs/installation.rst
Normal file
@@ -0,0 +1,58 @@
|
||||
.. _installation:
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
|
||||
#. Check out a clone of this repo to a location of your choice, such as
|
||||
``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it``
|
||||
#. Run ``~/.bash_it/install.sh`` (it automatically backs up your ``~/.bash_profile`` or ``~/.bashrc``\ , depending on your OS)
|
||||
#. Edit your modified config (\ ``~/.bash_profile`` or ``~/.bashrc``\ ) file in order to customize Bash-it.
|
||||
#. Check out available aliases, completions, and plugins and enable the ones you want to use (see the next section for more details).
|
||||
|
||||
Install Options
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The install script can take the following options:
|
||||
|
||||
|
||||
* ``--interactive``\ : Asks the user which aliases, completions and plugins to enable.
|
||||
* ``--silent``\ : Ask nothing and install using default settings.
|
||||
* ``--no-modify-config``\ : Do not modify the existing config file (\ ``~/.bash_profile`` or ``~/.bashrc``\ ).
|
||||
* ``--append-to-config``\ : Back up existing config file and append bash-it templates at the end.
|
||||
|
||||
When run without the ``--interactive`` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies.
|
||||
Feel free to enable the tools you want to use after the installation.
|
||||
|
||||
When you run without the ``--no-modify-config`` switch, the Bash-it installer automatically modifies/replaces your existing config file.
|
||||
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 loads its configuration files,
|
||||
``.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.
|
||||
To achieve this, you can add this snippet in your ``.bash_profile``\ :
|
||||
|
||||
.. code-block::
|
||||
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
|
||||
Refer to the official `Bash documentation <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 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``
|
||||
|
||||
Have a look at our `bash-it-docker repository <https://github.com/Bash-it/bash-it-docker>`_ for further information.
|
||||
|
||||
Updating
|
||||
^^^^^^^^
|
||||
|
||||
See :ref:`update command <update>`.
|
||||
35
dot_bash_it/docs/make.bat
Normal file
35
dot_bash_it/docs/make.bat
Normal file
@@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
||||
10
dot_bash_it/docs/misc.rst
Normal file
10
dot_bash_it/docs/misc.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _misc:
|
||||
|
||||
Misc
|
||||
----
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
help_screens
|
||||
proxy_support
|
||||
43
dot_bash_it/docs/proxy_support.rst
Normal file
43
dot_bash_it/docs/proxy_support.rst
Normal file
@@ -0,0 +1,43 @@
|
||||
.. _proxy_support:
|
||||
|
||||
Proxy Support
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
If you are working in a corporate environment where you have to go through a proxy server for internet access,
|
||||
then you know how painful it is to configure the OS proxy variables in the shell,
|
||||
especially if you are switching between environments, e.g. office (with proxy) and home (without proxy).
|
||||
|
||||
The Bash shell (and many shell tools) use the following variables to define the proxy to use:
|
||||
|
||||
|
||||
* ``HTTP_PROXY`` (and ``http_proxy``\ ): Defines the proxy server for HTTP requests
|
||||
* ``HTTPS_PROXY`` (and ``https_proxy``\ ): Defines the proxy server for HTTPS requests
|
||||
* ``ALL_PROXY`` (and ``all_proxy``\ ): Used by some tools for the same purpose as above
|
||||
* ``NO_PROXY`` (and ``no_proxy``\ ): Comma-separated list of hostnames that don't have to go through the proxy
|
||||
|
||||
Bash-it's ``proxy`` plugin allows to enable and disable these variables with a simple command.
|
||||
To start using the ``proxy`` plugin, run the following:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
bash-it enable plugin proxy
|
||||
|
||||
Bash-it also provides support for enabling/disabling proxy settings for various shell tools.
|
||||
The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh.
|
||||
The ``proxy`` plugin changes the configuration files of these tools to enable or disable the proxy settings.
|
||||
|
||||
Bash-it uses the following variables to set the shell's proxy settings when you call ``enable-proxy``.
|
||||
These variables are best defined in a custom script in Bash-it's custom script folder (\ ``$BASH_IT/custom``\ ), e.g. ``$BASH_IT/custom/proxy.env.bash``
|
||||
|
||||
|
||||
* ``BASH_IT_HTTP_PROXY`` and `BASH_IT_HTTPS_PROXY`: Define the proxy URL to be used, e.g. 'http://localhost:1234'
|
||||
* ``BASH_IT_NO_PROXY``\ : A comma-separated list of proxy exclusions, e.g. ``127.0.0.1,localhost``
|
||||
|
||||
Once you have defined these variables (and have run ``reload`` to load the changes), you can use the following commands to enable or disable the proxy settings in your current shell:
|
||||
|
||||
|
||||
* ``enable-proxy``\ : This sets the shell's proxy environment variables and configures proxy support in your SVN, npm, and SSH configuration files.
|
||||
* ``disable-proxy``\ : This unsets the shell's proxy environment variables and disables proxy support in your SVN, npm, and SSH configuration files.
|
||||
|
||||
There are many more proxy commands, e.g. for changing the local Git project's proxy settings.
|
||||
Run ``glossary proxy`` to show the available proxy functions with a short description.
|
||||
4
dot_bash_it/docs/requirements.txt
Normal file
4
dot_bash_it/docs/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
sphinx==3.2.1
|
||||
sphinx-rtd-theme==0.5.0
|
||||
sphinxemoji==0.1.8
|
||||
docutils==0.17.1
|
||||
46
dot_bash_it/docs/test.rst
Normal file
46
dot_bash_it/docs/test.rst
Normal file
@@ -0,0 +1,46 @@
|
||||
.. _test:
|
||||
|
||||
Testing Bash-it
|
||||
===============
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The Bash-it unit tests leverage the `Bats unit test framework for Bash <https://github.com/bats-core/bats-core>`_.
|
||||
There is no need to install Bats explicitly, the test run script will automatically download and install Bats and its dependencies.
|
||||
|
||||
When making changes to Bash-it, the tests are automatically executed in a test build environment on `Travis CI <https://travis-ci.com>`_.
|
||||
|
||||
Test Execution
|
||||
--------------
|
||||
|
||||
To execute the unit tests, please run the ``run`` script:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# If you are in the `test` directory:
|
||||
./run
|
||||
|
||||
# If you are in the root `.bash_it` directory:
|
||||
test/run
|
||||
|
||||
The ``run`` script will automatically install if it is not already present, and will then run all tests found under the ``test`` directory, including subdirectories.
|
||||
|
||||
To run only a subset of the tests, you can provide the name of the test subdirectory that you want to run, e.g. like this for the tests in the ``test/themes`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# If you are in the root `.bash_it` directory:
|
||||
test/run test/themes
|
||||
|
||||
By default, the tests run in single-threaded mode.
|
||||
If you want to speed up the test execution, you can install the `GNU ``parallel`` tool <https://www.gnu.org/software/parallel/>`_\ , which is supported by Bats.
|
||||
When using ``parallel``\ , the ``test/run`` script will use a number of threads in parallel, depending on the available CPU cores of your system.
|
||||
This can speed up test execution significantly.
|
||||
|
||||
Writing Tests
|
||||
-------------
|
||||
|
||||
When adding or modifying tests, please stick to the format and conventions of the existing test cases.
|
||||
The ``test_helper.bash`` script provides a couple of reusable helper functions that you should use when writing a test case,
|
||||
for example for setting up an isolated test environment.
|
||||
200
dot_bash_it/docs/themes-list/atomic.rst
Normal file
200
dot_bash_it/docs/themes-list/atomic.rst
Normal file
@@ -0,0 +1,200 @@
|
||||
.. _atomic:
|
||||
|
||||
Atomic theme
|
||||
============
|
||||
|
||||
The Best ColorFull terminal prompt theme inspired by a number of themes and based on the theme of @MunifTanjim :ref:`brainy <brainy>`.
|
||||
|
||||
Supported on all operating systems.
|
||||
|
||||
In constant maintenance and improvement
|
||||
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif
|
||||
:target: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif
|
||||
:alt: Atomic-Theme
|
||||
|
||||
|
||||
Install Theme
|
||||
-------------
|
||||
|
||||
Manually
|
||||
^^^^^^^^
|
||||
|
||||
You can install the theme manually by following these steps:
|
||||
Edit your modified config ``~/.bashrc`` file in order to customize Bash-it, set ``BASH_IT_THEME`` to the theme name ``atomic``.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Use the "atomic" theme
|
||||
export BASH_IT_THEME="atomic"
|
||||
|
||||
Automatically via terminal
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
#. You can install the theme automatically using the ``sed`` command from your Linux or OSX Terminal.
|
||||
#. On macOS, the ~/.bash_profile is used, not the ~/.bashrc.
|
||||
#. For installation on windows you should use `\ ``Git-Bash`` <https://git-for-windows.github.io/>`_ or make sure the terminal emulator you use (ej: cygwin, mintty, etc) has the ``sed`` command installed.
|
||||
|
||||
Command to execute For Windows and Linux:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Set the "atomic" theme replacing the theme you are using of bash-it
|
||||
sed -i 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bashrc
|
||||
|
||||
Command to execute for macOS:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Set the "atomic" theme replacing the theme you are using of bash-it
|
||||
sed -i '' 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bash_profile
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Prompt Segments
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
* Username & Hostname
|
||||
* Current Directory
|
||||
* SCM Information
|
||||
* Battery Charge
|
||||
* Clock
|
||||
* `Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status
|
||||
* Ruby Environment
|
||||
* Python Environment
|
||||
* Exit Code
|
||||
|
||||
Others
|
||||
^^^^^^
|
||||
|
||||
|
||||
* Indicator for cached ``sudo`` credential
|
||||
* Indicator for abort (ctrl + C) the current task and regain user control
|
||||
* ``atomic`` command for showing/hiding various prompt segments on-the-fly
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that:
|
||||
|
||||
|
||||
#. On-the-fly using ``atomic`` command
|
||||
#. Theme Environment Variables
|
||||
|
||||
On-the-fly using ``atomic`` command
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This theme provides a command for showing/hiding prompt segments.
|
||||
|
||||
``atomic show <segment>``
|
||||
|
||||
``atomic hide <segment>``
|
||||
|
||||
Tab-completion for this command is enabled by default.
|
||||
|
||||
Configuration specified by this command will only be applied to current and subsequent child shells.
|
||||
|
||||
Theme Environment Variables
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file.
|
||||
|
||||
The name of the variables are listed below along with their default values.
|
||||
|
||||
User Information
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information):
|
||||
|
||||
``THEME_SHOW_SUDO=true``
|
||||
|
||||
SCM Information
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Information about SCM repository status:
|
||||
|
||||
``THEME_SHOW_SCM=true``
|
||||
|
||||
Ruby Environment
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Ruby environment version information:
|
||||
|
||||
``THEME_SHOW_RUBY=false``
|
||||
|
||||
Python Environment
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Python environment version information:
|
||||
|
||||
``THEME_SHOW_PYTHON=false``
|
||||
|
||||
ToDo.txt status
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
`Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status:
|
||||
|
||||
``THEME_SHOW_TODO=false``
|
||||
|
||||
Clock
|
||||
~~~~~
|
||||
|
||||
``THEME_SHOW_CLOCK=true``
|
||||
|
||||
``THEME_CLOCK_COLOR=$bold_cyan``
|
||||
|
||||
Format of the clock (see ``date`` manpage for more information):
|
||||
|
||||
``THEME_CLOCK_FORMAT="%H:%M:%S"``
|
||||
|
||||
Battery Charge
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Battery charge percentage:
|
||||
|
||||
``THEME_SHOW_BATTERY=false``
|
||||
|
||||
Exit Code
|
||||
~~~~~~~~~
|
||||
|
||||
Exit code of the last command:
|
||||
|
||||
``THEME_SHOW_EXITCODE=true``
|
||||
|
||||
Prompt Segments Order
|
||||
---------------------
|
||||
|
||||
Currently available prompt segments are:
|
||||
|
||||
|
||||
* battery
|
||||
* char
|
||||
* clock
|
||||
* dir
|
||||
* exitcode
|
||||
* python
|
||||
* ruby
|
||||
* scm
|
||||
* todo
|
||||
* user_info
|
||||
|
||||
Three environment variables can be defined to rearrange the segments order. The default values are:
|
||||
|
||||
``___ATOMIC_TOP_LEFT="user_info dir scm"``
|
||||
|
||||
``___ATOMIC_TOP_RIGHT="exitcode python ruby todo clock battery"``
|
||||
|
||||
``___ATOMIC_BOTTOM="char"``
|
||||
|
||||
Development by
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Developer / Author: `Luis Felipe Sánchez <https://github.com/lfelipe1501>`_
|
||||
|
||||
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
||||
166
dot_bash_it/docs/themes-list/barbuk.rst
Normal file
166
dot_bash_it/docs/themes-list/barbuk.rst
Normal file
@@ -0,0 +1,166 @@
|
||||
.. _barbuk:
|
||||
|
||||
BarbUk theme
|
||||
============
|
||||
|
||||
A minimal theme with a clean git prompt
|
||||
|
||||
Provided Information
|
||||
--------------------
|
||||
|
||||
* Current git remote tool logo (support: github, gitlab, bitbucket)
|
||||
* Current path (red when user is root)
|
||||
* Current git info
|
||||
* Last command exit code (only shown when the exit code is greater than 0)
|
||||
* user@hostname for ssh connection
|
||||
|
||||
Default configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
BARBUK_PROMPT="git-uptream-remote-logo ssh path scm python_venv ruby node terraform cloud duration exit"
|
||||
|
||||
You can override BARBUK_PROMPT to display only the desired information.
|
||||
|
||||
available block:
|
||||
|
||||
* git-uptream-remote-logo
|
||||
* ssh
|
||||
* path
|
||||
* scm
|
||||
* python_venv
|
||||
* ruby
|
||||
* node
|
||||
* terraform
|
||||
* cloud
|
||||
* duration
|
||||
* exit
|
||||
|
||||
Fonts and glyphs
|
||||
----------------
|
||||
|
||||
A font with SCM glyphs is required to display the default tool/host logos.
|
||||
You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool
|
||||
provided by https://github.com/ryanoasis/nerd-fonts.
|
||||
|
||||
You can also override the default variables if you want to use different glyphs or standard ASCII characters.
|
||||
|
||||
Default theme glyphs
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
BARBUK_GITLAB_CHAR=' '
|
||||
BARBUK_BITBUCKET_CHAR=' '
|
||||
BARBUK_GITHUB_CHAR=' '
|
||||
BARBUK_GIT_DEFAULT_CHAR=' '
|
||||
BARBUK_GIT_BRANCH_ICON=''
|
||||
BARBUK_HG_CHAR='☿ '
|
||||
BARBUK_SVN_CHAR='⑆ '
|
||||
BARBUK_EXIT_CODE_ICON=' '
|
||||
BARBUK_PYTHON_VENV_CHAR=' '
|
||||
BARBUK_COMMAND_DURATION_ICON=' '
|
||||
BARBUK_RUBY_CHAR=' '
|
||||
BARBUK_NODE_CHAR=' '
|
||||
BARBUK_TERRAFORM_CHAR="❲t❳ "
|
||||
BARBUK_AWS_PROFILE_CHAR=" aws "
|
||||
BARBUK_SCALEWAY_PROFILE_CHAR=" scw "
|
||||
BARBUK_GCLOUD_CHAR=" gcp "
|
||||
|
||||
Customize glyphs
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Define your custom glyphs before sourcing bash-it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export BARBUK_GITHUB_CHAR='•'
|
||||
source "$BASH_IT"/bash_it.sh
|
||||
|
||||
SSH prompt
|
||||
----------
|
||||
|
||||
Usage
|
||||
^^^^^
|
||||
|
||||
When using a ssh session, the theme will display ``user@hostname``.
|
||||
You can disable this information with ``BARBUK_SSH_INFO``.
|
||||
|
||||
The hostname is displayed in the FQDN format by default. You
|
||||
can use the short hostname format with ``BARBUK_HOST_INFO``.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# short or long
|
||||
export BARBUK_HOST_INFO=short
|
||||
# true or false
|
||||
export BARBUK_SSH_INFO=false
|
||||
source "$BASH_IT"/bash_it.sh
|
||||
|
||||
Keep theme with sudoer
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you want the theme to persist using ``sudo -s`` in a ssh session, you need to configure sudo to keep the ``HOME`` and ``SSH_CONNECTION`` environment variables.
|
||||
|
||||
``HOME`` contains the path to the home directory of the current user. Keeping it will allow to use your user dotfiles when elevating privileges.
|
||||
|
||||
Keeping ``SSH_CONNECTION`` env is necessary for ssh detection in the theme.
|
||||
|
||||
Please refer to the following documentation for more information:
|
||||
|
||||
|
||||
* `sudo manual <https://www.sudo.ws/man/1.8.13/sudoers.man.html>`_ for ``env_keep`` configuration
|
||||
* `openssh manual <https://linux.die.net/man/1/ssh>`_ for information about ``SSH_CONNECTION`` environment
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cat << EOF > /etc/sudoers.d/keepenv
|
||||
Defaults env_keep += HOME
|
||||
Defaults env_keep += SSH_CONNECTION
|
||||
EOF
|
||||
chmod 400 /etc/sudoers.d/keepenv
|
||||
|
||||
Command duration
|
||||
----------------
|
||||
|
||||
See :ref:`Command duration <command_duration>`.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Clean
|
||||
^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
~ ❯
|
||||
|
||||
Git
|
||||
^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
~/.dotfiles on master ⤏ origin ↑2 •7 ✗ ❯
|
||||
|
||||
Ssh
|
||||
^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
user@hostname in ~/bash-it on master ✓ ❯
|
||||
|
||||
Python venv
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
flask ~/test on master ✓ ❯
|
||||
|
||||
Command duration
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# sleep 3s
|
||||
user@hostname in ~/bash-it on master ✓ 3.2s ❯
|
||||
12
dot_bash_it/docs/themes-list/bira.rst
Normal file
12
dot_bash_it/docs/themes-list/bira.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _bira:
|
||||
|
||||
Bira Theme
|
||||
==========
|
||||
|
||||
This is a port of Oh My Zsh's `'Bira' <https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/bira.zsh-theme>`_ theme. It looks the same as the original, except for the following changes:
|
||||
|
||||
|
||||
* Exit code of last command is not shown
|
||||
* More informative git prompt (if you want to keep it minimal, please read: :ref:`git_prompt`)
|
||||
* Position and colour of virtualenv prompt
|
||||
* No ruby version prompt
|
||||
145
dot_bash_it/docs/themes-list/brainy.rst
Normal file
145
dot_bash_it/docs/themes-list/brainy.rst
Normal file
@@ -0,0 +1,145 @@
|
||||
.. _brainy:
|
||||
|
||||
Brainy theme
|
||||
============
|
||||
|
||||
Simple colorful terminal prompt theme (inspired by a number of themes).
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Prompt Segments
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
* Username & Hostname
|
||||
* Current Directory
|
||||
* SCM Information
|
||||
* Battery Charge
|
||||
* Clock
|
||||
* `Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status
|
||||
* Ruby Environment
|
||||
* Python Environment
|
||||
* Exit Code
|
||||
|
||||
Others
|
||||
^^^^^^
|
||||
|
||||
|
||||
* Indicator for cached ``sudo`` credential
|
||||
* Indicator for ssh login
|
||||
* ``brainy`` command for showing/hiding various prompt segments on-the-fly
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that:
|
||||
|
||||
|
||||
#. On-the-fly using ``brainy`` command
|
||||
#. Theme Environment Variables
|
||||
|
||||
On-the-fly using ``brainy`` command
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This theme provides a command for showing/hiding prompt segments.
|
||||
|
||||
``brainy show <segment>``
|
||||
|
||||
``brainy hide <segment>``
|
||||
|
||||
Tab-completion for this command is enabled by default.
|
||||
|
||||
Configuration specified by this command will only be applied to current and subsequent child shells.
|
||||
|
||||
Theme Environment Variables
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file.
|
||||
|
||||
The name of the variables are listed below along with their default values.
|
||||
|
||||
User Information
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information):
|
||||
|
||||
``THEME_SHOW_SUDO=true``
|
||||
|
||||
SCM Information
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Information about SCM repository status:
|
||||
|
||||
``THEME_SHOW_SCM=true``
|
||||
|
||||
Ruby Environment
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Ruby environment version information:
|
||||
|
||||
``THEME_SHOW_RUBY=false``
|
||||
|
||||
Python Environment
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Python environment version information:
|
||||
|
||||
``THEME_SHOW_PYTHON=false``
|
||||
|
||||
ToDo.txt status
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
`Todo.txt <https://github.com/ginatrapani/todo.txt-cli>`_ status:
|
||||
|
||||
``THEME_SHOW_TODO=false``
|
||||
|
||||
Clock
|
||||
~~~~~
|
||||
|
||||
``THEME_SHOW_CLOCK=true``
|
||||
|
||||
``THEME_CLOCK_COLOR=$bold_cyan``
|
||||
|
||||
Format of the clock (see ``date`` manpage for more information):
|
||||
|
||||
``THEME_CLOCK_FORMAT="%H:%M:%S"``
|
||||
|
||||
Battery Charge
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Battery charge percentage:
|
||||
|
||||
``THEME_SHOW_BATTERY=false``
|
||||
|
||||
Exit Code
|
||||
~~~~~~~~~
|
||||
|
||||
Exit code of the last command:
|
||||
|
||||
``THEME_SHOW_EXITCODE=true``
|
||||
|
||||
Prompt Segments Order
|
||||
---------------------
|
||||
|
||||
Currently available prompt segments are:
|
||||
|
||||
|
||||
* battery
|
||||
* char
|
||||
* clock
|
||||
* dir
|
||||
* exitcode
|
||||
* python
|
||||
* ruby
|
||||
* scm
|
||||
* todo
|
||||
* user_info
|
||||
|
||||
Three environment variables can be defined to rearrange the segments order. The default values are:
|
||||
|
||||
``___BRAINY_TOP_LEFT="user_info dir scm"``
|
||||
|
||||
``___BRAINY_TOP_RIGHT="python ruby todo clock battery"``
|
||||
|
||||
``___BRAINY_BOTTOM="exitcode char"``
|
||||
28
dot_bash_it/docs/themes-list/codeword.rst
Normal file
28
dot_bash_it/docs/themes-list/codeword.rst
Normal file
@@ -0,0 +1,28 @@
|
||||
.. _codeword:
|
||||
|
||||
Codeword Theme
|
||||
==============
|
||||
|
||||
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
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: 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 ✗|] $
|
||||
14
dot_bash_it/docs/themes-list/easy.rst
Normal file
14
dot_bash_it/docs/themes-list/easy.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _easy:
|
||||
|
||||
Easy Theme
|
||||
==========
|
||||
|
||||
A simple theme
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
user@hostname ~/.bash_it
|
||||
[ master ✓ ] ❯
|
||||
599
dot_bash_it/docs/themes-list/index.rst
Normal file
599
dot_bash_it/docs/themes-list/index.rst
Normal file
@@ -0,0 +1,599 @@
|
||||
.. _list_of_themes:
|
||||
|
||||
List of Themes
|
||||
==============
|
||||
|
||||
Below is a list of most of the themes (with screenshots) and their documentation that `bash-it <https://github.com/Bash-it/bash-it/>`_ ships with.
|
||||
|
||||
.. note::
|
||||
Not all themes have documentation!
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:caption: Documentation of Themes
|
||||
:glob:
|
||||
|
||||
*
|
||||
|
||||
Alphabetical Screenshots List
|
||||
-----------------------------
|
||||
|
||||
Bakke
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg
|
||||
:alt: Bakke
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg
|
||||
:alt: Bakke
|
||||
|
||||
|
||||
----
|
||||
|
||||
BarbUk
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png
|
||||
:alt: BarbUk
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png
|
||||
:alt: BarbUk
|
||||
|
||||
|
||||
----
|
||||
|
||||
Bobby
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Brunton
|
||||
^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/brunton-black.png
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/brunton-black.png
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Candy
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Clean
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Demula
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
DOS
|
||||
^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
DoubleTime
|
||||
^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
DoubleTime Multiline
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Doubletime Multiline Python Only
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Easy
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Envy
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Iterate
|
||||
^^^^^^^
|
||||
|
||||
Responsively wraps prompt based on terminal width.
|
||||
|
||||
|
||||
.. image:: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png
|
||||
:target: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png
|
||||
:target: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Mr Briggs
|
||||
^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Minimal
|
||||
^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Modern
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Modern T
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Metal
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png
|
||||
:target: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
n0Qorg
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
.. _nwinkler_image:
|
||||
|
||||
NWinkler
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
.. _oh_my_posh_image:
|
||||
|
||||
Oh-My-Posh
|
||||
^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Pete
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Powerline
|
||||
^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Powerline Naked
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Powerline Plain
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Pure
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
RainbowBrite
|
||||
^^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
R Jorgenson
|
||||
^^^^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Sexy
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Simple
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
SirUp
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Standard
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Tonka
|
||||
^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Tylenol
|
||||
^^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Zitron
|
||||
^^^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
----
|
||||
|
||||
Zork
|
||||
^^^^
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg
|
||||
:alt:
|
||||
|
||||
|
||||
.. image:: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg
|
||||
:target: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg
|
||||
:alt:
|
||||
BIN
dot_bash_it/docs/themes-list/nwinkler_random_colors.png
Normal file
BIN
dot_bash_it/docs/themes-list/nwinkler_random_colors.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
39
dot_bash_it/docs/themes-list/nwinkler_random_colors.rst
Normal file
39
dot_bash_it/docs/themes-list/nwinkler_random_colors.rst
Normal file
@@ -0,0 +1,39 @@
|
||||
.. _nwinkler_random_color:
|
||||
|
||||
Nwinkler Random Color Theme
|
||||
===========================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The *Nwinkler Random Color* Theme is based on the :ref:`Nwinkler Theme <nwinkler_image>` , but it randomizes the colors for:
|
||||
|
||||
|
||||
* time
|
||||
* username
|
||||
* hostname
|
||||
* path
|
||||
|
||||
The random colors are chosen the first time this theme is used and saved to the ``~/.nwinkler_random_colors`` file. So, the next time you connect to the same machine, you will get the same colors.
|
||||
|
||||
To force new random colors to be selected, run the command:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
randomize_nwinkler
|
||||
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
Here it is in action:
|
||||
|
||||
|
||||
.. image:: nwinkler_random_colors.png
|
||||
:target: nwinkler_random_colors.png
|
||||
:alt: alt text
|
||||
|
||||
|
||||
Usage Scenario
|
||||
--------------
|
||||
|
||||
This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname.
|
||||
15
dot_bash_it/docs/themes-list/oh-my-posh.rst
Normal file
15
dot_bash_it/docs/themes-list/oh-my-posh.rst
Normal file
@@ -0,0 +1,15 @@
|
||||
.. _oh-my-posh:
|
||||
|
||||
Oh-My-Posh Theme
|
||||
================
|
||||
|
||||
The oh-my-posh ״theme״ is really a plug to a whole other system
|
||||
of managing your prompt. To use it please start here:
|
||||
`Oh-My-Posh homepage <https://ohmyposh.dev/>`_
|
||||
|
||||
It is beyond the scope of bash-it to install and manage oh-my-posh,
|
||||
this theme is here just to make sure your OMP setup doesn't clash
|
||||
with other bash-it themes. Once installed, OMP will load a default
|
||||
OMP theme (jandedobbeleer), which you can then customize or override.
|
||||
|
||||
Note: Nerd Fonts are highly recommended, as most of the themes are graphic candies.
|
||||
130
dot_bash_it/docs/themes-list/powerline-base.rst
Normal file
130
dot_bash_it/docs/themes-list/powerline-base.rst
Normal file
@@ -0,0 +1,130 @@
|
||||
.. _powerline_base:
|
||||
|
||||
Base Powerline Theme Information
|
||||
================================
|
||||
|
||||
This page explains base powerline theme information, shared between
|
||||
all powerline themes.
|
||||
|
||||
**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
|
||||
* Current username and hostname
|
||||
* Current time
|
||||
* Current shell level
|
||||
* Current dirstack level (\ ``pushd`` / ``popd``\ )
|
||||
* Current history number
|
||||
* Current command number
|
||||
* An indicator when connected by SSH
|
||||
* An indicator when ``sudo`` has the credentials cached (see the ``sudo`` manpage for more info about this)
|
||||
* An indicator when the current shell is inside the Vim editor
|
||||
* Battery charging status (depends on the 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)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
This theme is pretty configurable, all the configuration is done by setting environment variables.
|
||||
|
||||
User Information
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export POWERLINE_PROMPT_USER_INFO_MODE="sudo"
|
||||
|
||||
|
||||
For now, the only supported value is ``sudo``\ , which hides the username and hostname, and shows an indicator when ``sudo`` has the credentials cached. Other values have no effect at this time.
|
||||
|
||||
Clock Format
|
||||
^^^^^^^^^^^^
|
||||
|
||||
You can change the format using the following variable:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export THEME_CLOCK_FORMAT="%H:%M:%S"
|
||||
|
||||
|
||||
The time/date is printed by the ``date`` command, so refer to its man page to change the format.
|
||||
|
||||
Segment Order
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
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``\ )
|
||||
* ``duration`` - Duration of the last command. See :ref:`Command duration <command_duration>` for details.
|
||||
* ``gcloud`` - Current gcloud active account
|
||||
* ``hostname`` - Host name of machine
|
||||
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_
|
||||
* ``in_vim`` - Show identifier if running in ``:terminal`` from vim
|
||||
* ``k8s_context`` - Show current kubernetes context
|
||||
* ``k8s_namespace`` - Show current kubernetes namespace
|
||||
* ``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``
|
||||
* ``node`` - Current node version (only ``nvm`` is supported)
|
||||
* ``scm`` - Version control information, ``git``
|
||||
* ``terraform`` - Current terraform workspace
|
||||
* ``user_info`` - Current user
|
||||
* ``wd`` - Working directory, like ``cwd`` but doesn't show the full folder
|
||||
hierarchy, only the directory you're currently in.
|
||||
* ``shlvl`` - Show the current shell level (based on ``SHLVL`` environment variable), but only if you are not in root shell
|
||||
* ``dirstack`` - Show the current dirstack level (based on ``DIRSTACK`` environment variable), but only if the stack is not empty
|
||||
* ``history_number`` - Show current history number
|
||||
* ``command_number`` - Show current command number
|
||||
|
||||
A variable can be defined to set the order of the prompt segments:
|
||||
|
||||
.. code-block::
|
||||
|
||||
POWERLINE_PROMPT="user_info scm python_venv ruby cwd"
|
||||
|
||||
|
||||
The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable.
|
||||
|
||||
.. _powerline_compact_settings:
|
||||
|
||||
Compact Settings
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
You can configure various aspects of the prompt to use less whitespace. Supported variables are:
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Variable
|
||||
- Description
|
||||
* - POWERLINE_COMPACT_BEFORE_SEPARATOR
|
||||
- Removes the leading space before each separator
|
||||
* - POWERLINE_COMPACT_AFTER_SEPARATOR
|
||||
- Removes the trailing space after each separator
|
||||
* - POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT
|
||||
- Removes the leading space on the first segment
|
||||
* - POWERLINE_COMPACT_AFTER_LAST_SEGMENT
|
||||
- Removes the trailing space on the last segment
|
||||
* - POWERLINE_COMPACT_PROMPT
|
||||
- Removes the space after the prompt character
|
||||
* - POWERLINE_COMPACT
|
||||
- Enable all Compact settings (you can still override individual settings)
|
||||
|
||||
|
||||
The default value for all settings is ``0`` (disabled). Use ``1`` to enable.
|
||||
36
dot_bash_it/docs/themes-list/powerline-multiline.rst
Normal file
36
dot_bash_it/docs/themes-list/powerline-multiline.rst
Normal file
@@ -0,0 +1,36 @@
|
||||
.. _powerline_multiline:
|
||||
|
||||
Powerline Multiline Theme
|
||||
=========================
|
||||
|
||||
A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced.
|
||||
|
||||
See :ref:`powerline_base` for general information about the powerline theme.
|
||||
|
||||
Soft Separators
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.
|
||||
|
||||
Padding
|
||||
^^^^^^^
|
||||
|
||||
To get the length of the left and right segments right, a *padding* value is used.
|
||||
In most cases, the default value (\ *2*\ ) works fine, but on some operating systems, this needs to be adjusted.
|
||||
One example is *macOS High Sierra*\ , where the default padding causes the right segment to extend to the next line.
|
||||
On macOS High Sierra, the padding value needs to be changed to *3* to make the theme look right.
|
||||
This can be done by setting the ``POWERLINE_PADDING`` variable before Bash-it is loaded, e.g. in your ``~/.bash_profile`` or ``~/.bashrc`` file:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export POWERLINE_PADDING=3
|
||||
|
||||
|
||||
Multiline Mode Right Prompt
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For the purposes of the :ref:`Compact <powerline_compact_settings>` settings, the segments within the **Right Prompt** are considered to run "right-to-left", i.e.:
|
||||
|
||||
|
||||
* The **right-most** segment is considered to be the ``"first"`` segment, while the **left-most** segment is considered to be the ``"last"``
|
||||
* The space to the **right** of the separator character is considered to be ``"before"``\ , while the space to the **left** is considered to be ``"after"``
|
||||
9
dot_bash_it/docs/themes-list/powerline-naked.rst
Normal file
9
dot_bash_it/docs/themes-list/powerline-naked.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
.. _powerline_naked:
|
||||
|
||||
Powerline Naked Theme
|
||||
=====================
|
||||
|
||||
A colorful theme, where shows a lot information about your shell session.
|
||||
The naked powerline theme provides a cleaner shell with less background colors.
|
||||
|
||||
See :ref:`powerline_base` for general information about the powerline theme.
|
||||
14
dot_bash_it/docs/themes-list/powerline-plain.rst
Normal file
14
dot_bash_it/docs/themes-list/powerline-plain.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _powerline_plain:
|
||||
|
||||
Powerline Plain Theme
|
||||
=====================
|
||||
|
||||
A colorful theme, where shows a lot information about your shell session.
|
||||
The plain powerline theme provides a simpler shell with less information.
|
||||
|
||||
See :ref:`powerline_base` for general information about the powerline theme.
|
||||
|
||||
Soft Separators
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.
|
||||
13
dot_bash_it/docs/themes-list/powerline.rst
Normal file
13
dot_bash_it/docs/themes-list/powerline.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _powerline:
|
||||
|
||||
Powerline Theme
|
||||
===============
|
||||
|
||||
A colorful theme, where shows a lot information about your shell session.
|
||||
|
||||
See :ref:`powerline_base` for general information about the powerline theme.
|
||||
|
||||
Soft Separators
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them.
|
||||
25
dot_bash_it/docs/themes-list/radek.rst
Normal file
25
dot_bash_it/docs/themes-list/radek.rst
Normal file
@@ -0,0 +1,25 @@
|
||||
.. _radek:
|
||||
|
||||
Radek Theme
|
||||
===========
|
||||
|
||||
A colorful theme for Python developers.
|
||||
It does not have any requirements.
|
||||
|
||||
Provided Information
|
||||
--------------------
|
||||
|
||||
|
||||
* Current username and hostname
|
||||
* Current path
|
||||
* Git repository status
|
||||
* Current Python environment (venv, Conda )
|
||||
* Current Python version
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
[radek@photon][~/src/nokia2/cbis] ±[master → origin ↑1 {1}✓][venv-cbis][py-3.7.5]
|
||||
→
|
||||
BIN
dot_bash_it/docs/themes-list/redline.png
Normal file
BIN
dot_bash_it/docs/themes-list/redline.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 962 KiB |
56
dot_bash_it/docs/themes-list/redline.rst
Normal file
56
dot_bash_it/docs/themes-list/redline.rst
Normal file
@@ -0,0 +1,56 @@
|
||||
.. _redline:
|
||||
|
||||
Redline Theme
|
||||
=============
|
||||
|
||||
changed up the powerline base a little.
|
||||
|
||||
It plays nicest with this font: `DroidSansMonoForPowerline <https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono>`_
|
||||
|
||||
Read the :ref:`powerline theme documentation <powerline>`
|
||||
|
||||
added
|
||||
-----
|
||||
|
||||
|
||||
* hostname
|
||||
* distro logo
|
||||
|
||||
changed
|
||||
-------
|
||||
|
||||
|
||||
* sudo credential check
|
||||
* required font
|
||||
* some icons
|
||||
|
||||
Works real good like with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
## set the theme
|
||||
export BASH_IT_THEME='redline'
|
||||
|
||||
# Set this to false to turn off version control status checking within the prompt for all themes
|
||||
export SCM_CHECK=true
|
||||
|
||||
## Set Xterm/screen/Tmux title with only a short hostname.
|
||||
export SHORT_HOSTNAME=$(hostname -s)
|
||||
|
||||
## enable sudo prompt
|
||||
export POWERLINE_PROMPT_USER_INFO_MODE="sudo"
|
||||
|
||||
## prompt part string
|
||||
export POWERLINE_PROMPT="python_venv user_info hostname cwd scm"
|
||||
|
||||
enable your distro logo with
|
||||
----------------------------
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export POWERLINE_PROMPT_DISTRO_LOGO="yes"
|
||||
|
||||
|
||||
.. image:: redline.png
|
||||
:target: redline.png?raw=true
|
||||
:alt: screenshot
|
||||
93
dot_bash_it/docs/themes.rst
Normal file
93
dot_bash_it/docs/themes.rst
Normal file
@@ -0,0 +1,93 @@
|
||||
.. _themes:
|
||||
|
||||
Themes
|
||||
------
|
||||
|
||||
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:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Use the "powerline-multiline" theme
|
||||
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-it preview``.
|
||||
|
||||
If you've created your own custom prompts, we'd love it if you shared them 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 it isn't American English.
|
||||
|
||||
List of Themes
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
See :ref:`here <list_of_themes>`.
|
||||
|
||||
Theme Switches & Variables
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. _command_duration:
|
||||
|
||||
Command duration
|
||||
================
|
||||
|
||||
Prints last command duration
|
||||
|
||||
Usage
|
||||
#####
|
||||
|
||||
Command duration can be enabled by exporting ``BASH_IT_COMMAND_DURATION``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export BASH_IT_COMMAND_DURATION=true
|
||||
|
||||
The default configuration display last command duration for command lasting one second or more.
|
||||
You can customize the minimum time in seconds before command duration is displayed in your ``.bashrc``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export COMMAND_DURATION_MIN_SECONDS=5
|
||||
|
||||
Clock Related
|
||||
=============
|
||||
|
||||
function: ``clock_char``
|
||||
########################
|
||||
|
||||
Prints a character indicating clock.
|
||||
|
||||
|
||||
* ``THEME_SHOW_CLOCK_CHAR`` : **true**\ /false
|
||||
|
||||
* ``THEME_CLOCK_CHAR`` : "\ **⌚**\ "
|
||||
|
||||
* ``THEME_CLOCK_CHAR_COLOR`` : "\ **$normal**\ "
|
||||
|
||||
function: ``clock_prompt``
|
||||
##########################
|
||||
|
||||
Prints the clock prompt (date, time).
|
||||
|
||||
|
||||
* ``THEME_SHOW_CLOCK`` : **true**\ /false
|
||||
|
||||
* ``THEME_CLOCK_COLOR`` : "\ **$normal**\ "
|
||||
|
||||
* ``THEME_CLOCK_FORMAT`` : "\ **%H:%M:%S**\ "
|
||||
|
||||
Contributing a new theme
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
See the :ref:`instructions <contributing_theme>`.
|
||||
16
dot_bash_it/docs/troubleshooting.rst
Normal file
16
dot_bash_it/docs/troubleshooting.rst
Normal file
@@ -0,0 +1,16 @@
|
||||
.. _troubleshooting:
|
||||
|
||||
Troubleshooting Guide
|
||||
=====================
|
||||
|
||||
Table of Contents
|
||||
-----------------
|
||||
|
||||
* `I'm stuck in the LightDM login screen after setting up bash-it. <im-stuck-in-the-lightdm-login-screen-after-setting-up-bash-it>`_
|
||||
|
||||
I'm stuck in the LightDM login screen after setting up bash-it
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Possible issue**\ : `#672 <https://github.com/Bash-it/bash-it/issues/672>`_
|
||||
|
||||
**Solution**\ : Check `this comment <https://github.com/Bash-it/bash-it/issues/672#issuecomment-257870653>`_ for detailed information about the cause and solution for this issue.
|
||||
14
dot_bash_it/docs/uninstalling.rst
Normal file
14
dot_bash_it/docs/uninstalling.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _uninstalling:
|
||||
|
||||
Uninstalling
|
||||
------------
|
||||
|
||||
To uninstall Bash-it, run the ``uninstall.sh`` script found in the ``$BASH_IT`` directory:
|
||||
|
||||
.. code-block::
|
||||
|
||||
cd $BASH_IT
|
||||
./uninstall.sh
|
||||
|
||||
This will restore your previous Bash profile.
|
||||
After the uninstall script finishes, remove the Bash-it directory from your machine (\ ``rm -rf $BASH_IT``\ ) and start a new shell.
|
||||
200
dot_bash_it/docs/vcs_user.rst
Normal file
200
dot_bash_it/docs/vcs_user.rst
Normal file
@@ -0,0 +1,200 @@
|
||||
.. _vcs_user:
|
||||
|
||||
Prompt Version Control Information
|
||||
==================================
|
||||
|
||||
Bash-it provides prompt :ref:`themes` with the ability to check and display version control information for the current directory.
|
||||
The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders.
|
||||
Turn version control checking off to prevent slow directory navigation within large projects.
|
||||
|
||||
Controlling Flags
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Bash-it provides a flag (\ ``SCM_CHECK``\ ) within the ``~/.bash_profile`` file that turns off/on version control information checking and display within all themes.
|
||||
Version control checking is on by default unless explicitly turned off.
|
||||
|
||||
Set ``SCM_CHECK`` to 'false' to **turn off** version control checks for all themes:
|
||||
|
||||
|
||||
* ``export SCM_CHECK=false``
|
||||
|
||||
Set ``SCM_CHECK`` to 'true' (the default value) to **turn on** version control checks for all themes:
|
||||
|
||||
|
||||
* ``export SCM_CHECK=true``
|
||||
|
||||
**NOTE:**
|
||||
It is possible for themes to ignore the ``SCM_CHECK`` flag and query specific version control information directly.
|
||||
For example, themes that use functions like ``git_prompt_vars`` skip the ``SCM_CHECK`` flag to retrieve and display git prompt information.
|
||||
If you turned version control checking off and you still see version control information within your prompt, then functions like ``git_prompt_vars`` are most likely the reason why.
|
||||
|
||||
.. _git_prompt:
|
||||
|
||||
Git prompt
|
||||
^^^^^^^^^^
|
||||
|
||||
Bash-it has some nice features related to Git, continue reading to know more about these features.
|
||||
|
||||
Repository info in the prompt
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed.
|
||||
|
||||
Additionally, you can view the status of your working copy and get the count of *staged*\ , *unstaged* and *untracked* files.
|
||||
This feature is controlled through the flag ``SCM_GIT_SHOW_DETAILS`` as follows:
|
||||
|
||||
Set ``SCM_GIT_SHOW_DETAILS`` to 'true' (the default value) to **show** the working copy details in your prompt:
|
||||
|
||||
|
||||
* ``export SCM_GIT_SHOW_DETAILS=true``
|
||||
|
||||
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.
|
||||
|
||||
You can control this feature with the flag ``SCM_GIT_SHOW_REMOTE_INFO`` as follows:
|
||||
|
||||
Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo:
|
||||
|
||||
|
||||
* ``export SCM_GIT_SHOW_REMOTE_INFO=auto``
|
||||
|
||||
Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'true' to always activate the feature:
|
||||
|
||||
|
||||
* ``export SCM_GIT_SHOW_REMOTE_INFO=true``
|
||||
|
||||
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, 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``\ :
|
||||
|
||||
Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'false' (the default value) to get information about *untracked* files:
|
||||
|
||||
|
||||
* ``export SCM_GIT_IGNORE_UNTRACKED=false``
|
||||
|
||||
Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'true' to **ignore** *untracked* files:
|
||||
|
||||
|
||||
* ``export SCM_GIT_IGNORE_UNTRACKED=true``
|
||||
|
||||
Also, with this flag to false, Bash-it will not show the repository as dirty when the repo has *untracked* files, and will not display the count of *untracked* files.
|
||||
|
||||
**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``
|
||||
|
||||
Ahead/Behind Count
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind.
|
||||
This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are.
|
||||
|
||||
Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'true' (the default value) to **show** the count of commits ahead/behind:
|
||||
|
||||
|
||||
* ``export SCM_GIT_SHOW_COMMIT_COUNT=true``
|
||||
|
||||
Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'false' to **don't show** it:
|
||||
|
||||
|
||||
* ``export SCM_GIT_SHOW_COMMIT_COUNT=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.
|
||||
For example, any organization that uses the practice of pair programming will typically author each commit with `combined names of the two authors <https://github.com/pivotal/git_scripts>`_.
|
||||
When another pair uses the same pairing station, the authors are changed at the beginning of the session.
|
||||
|
||||
To get up and running with this technique, run ``gem install pivotal_git_scripts``\ , and then edit your ``~/.pairs`` file, according to the specification on the `gem's homepage <https://github.com/pivotal/git_scripts>`_.
|
||||
After that, you should be able to run ``git pair kg as`` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the ``~/.pairs`` file.
|
||||
Please see gem's documentation for more information.
|
||||
|
||||
To enable the display of the current pair in the prompt, you must set ``SCM_GIT_SHOW_CURRENT_USER`` to ``true``.
|
||||
Once set, the ``SCM_CURRENT_USER`` variable will be automatically populated with the initials of the git author(s).
|
||||
It will also be included in the default git prompt.
|
||||
Even if you do not have ``git pair`` installed, as long as your ``user.name`` is set, your initials will be computed from your name and shown in the prompt.
|
||||
|
||||
You can control the prefix and the suffix of this component using the two variables:
|
||||
|
||||
|
||||
* ``export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '``
|
||||
|
||||
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:
|
||||
|
||||
.. code-block::
|
||||
|
||||
export SCM_GIT_SHOW_MINIMAL_INFO=true
|
||||
|
||||
Ignore repo status
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When working in repos with a large codebase, 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.
|
||||
|
||||
To disable checking the status in the current repo:
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ git config --add bash-it.hide-status 1
|
||||
|
||||
But if you would like to disable it globally, and stop checking the status for all of your repos:
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ git config --global --add bash-it.hide-status 1
|
||||
|
||||
Setting this flag globally has the same effect as ``SCM_CHECK=true``\ , but only for Git repos.
|
||||
|
||||
Speed up git status calculations
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
As an alternative to ignoring repo status entirely, you can try out the ``gitstatus`` plugin.
|
||||
This plugin speeds up all ``git status`` calculations by up to 10x times!
|
||||
|
||||
**NOTE**\ : You will need to clone ``gitstatus`` repo from `here <https://github.com/romkatv/gitstatus>`_.
|
||||
1
dot_bash_it/dot_ackrc
Normal file
1
dot_bash_it/dot_ackrc
Normal file
@@ -0,0 +1 @@
|
||||
--ignore-dir=enabled/
|
||||
36
dot_bash_it/dot_editorconfig
Normal file
36
dot_bash_it/dot_editorconfig
Normal file
@@ -0,0 +1,36 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.{md,rst}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[.git*]
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
|
||||
[{**.*sh,test/run,**.bats}]
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
|
||||
shell_variant = bash
|
||||
binary_next_line = true # like -bn
|
||||
switch_case_indent = true # like -ci
|
||||
space_redirects = true # like -sr
|
||||
keep_padding = false # like -kp
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.bats]
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
shell_variant = bats
|
||||
1
dot_bash_it/dot_git/HEAD
Normal file
1
dot_bash_it/dot_git/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
0
dot_bash_it/dot_git/branches/.keep
Normal file
0
dot_bash_it/dot_git/branches/.keep
Normal file
11
dot_bash_it/dot_git/config
Normal file
11
dot_bash_it/dot_git/config
Normal file
@@ -0,0 +1,11 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[remote "origin"]
|
||||
url = https://github.com/Bash-it/bash-it.git
|
||||
fetch = +refs/heads/master:refs/remotes/origin/master
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
||||
1
dot_bash_it/dot_git/description
Normal file
1
dot_bash_it/dot_git/description
Normal file
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
15
dot_bash_it/dot_git/hooks/executable_applypatch-msg.sample
Normal file
15
dot_bash_it/dot_git/hooks/executable_applypatch-msg.sample
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
||||
24
dot_bash_it/dot_git/hooks/executable_commit-msg.sample
Normal file
24
dot_bash_it/dot_git/hooks/executable_commit-msg.sample
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
173
dot_bash_it/dot_git/hooks/executable_fsmonitor-watchman.sample
Normal file
173
dot_bash_it/dot_git/hooks/executable_fsmonitor-watchman.sample
Normal file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IPC::Open2;
|
||||
|
||||
# An example hook script to integrate Watchman
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
||||
# new and modified files.
|
||||
#
|
||||
# The hook is passed a version (currently 2) and last update token
|
||||
# formatted as a string and outputs to stdout a new update token and
|
||||
# all files that have been modified since the update token. Paths must
|
||||
# be relative to the root of the working tree and separated by a single NUL.
|
||||
#
|
||||
# To enable this hook, rename this file to "query-watchman" and set
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
||||
#
|
||||
my ($version, $last_update_token) = @ARGV;
|
||||
|
||||
# Uncomment for debugging
|
||||
# print STDERR "$0 $version $last_update_token\n";
|
||||
|
||||
# Check the hook interface version
|
||||
if ($version ne 2) {
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
||||
"Falling back to scanning...\n";
|
||||
}
|
||||
|
||||
my $git_work_tree = get_working_dir();
|
||||
|
||||
my $retry = 1;
|
||||
|
||||
my $json_pkg;
|
||||
eval {
|
||||
require JSON::XS;
|
||||
$json_pkg = "JSON::XS";
|
||||
1;
|
||||
} or do {
|
||||
require JSON::PP;
|
||||
$json_pkg = "JSON::PP";
|
||||
};
|
||||
|
||||
launch_watchman();
|
||||
|
||||
sub launch_watchman {
|
||||
my $o = watchman_query();
|
||||
if (is_work_tree_watched($o)) {
|
||||
output_result($o->{clock}, @{$o->{files}});
|
||||
}
|
||||
}
|
||||
|
||||
sub output_result {
|
||||
my ($clockid, @files) = @_;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# binmode $fh, ":utf8";
|
||||
# print $fh "$clockid\n@files\n";
|
||||
# close $fh;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
print $clockid;
|
||||
print "\0";
|
||||
local $, = "\0";
|
||||
print @files;
|
||||
}
|
||||
|
||||
sub watchman_clock {
|
||||
my $response = qx/watchman clock "$git_work_tree"/;
|
||||
die "Failed to get clock id on '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub watchman_query {
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
||||
or die "open2() failed: $!\n" .
|
||||
"Falling back to scanning...\n";
|
||||
|
||||
# In the query expression below we're asking for names of files that
|
||||
# changed since $last_update_token but not from the .git folder.
|
||||
#
|
||||
# To accomplish this, we're using the "since" generator to use the
|
||||
# recency index to select candidate nodes and "fields" to limit the
|
||||
# output to file names only. Then we're using the "expression" term to
|
||||
# further constrain the results.
|
||||
if (substr($last_update_token, 0, 1) eq "c") {
|
||||
$last_update_token = "\"$last_update_token\"";
|
||||
}
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {
|
||||
"since": $last_update_token,
|
||||
"fields": ["name"],
|
||||
"expression": ["not", ["dirname", ".git"]]
|
||||
}]
|
||||
END
|
||||
|
||||
# Uncomment for debugging the watchman query
|
||||
# open (my $fh, ">", ".git/watchman-query.json");
|
||||
# print $fh $query;
|
||||
# close $fh;
|
||||
|
||||
print CHLD_IN $query;
|
||||
close CHLD_IN;
|
||||
my $response = do {local $/; <CHLD_OUT>};
|
||||
|
||||
# Uncomment for debugging the watch response
|
||||
# open ($fh, ">", ".git/watchman-response.json");
|
||||
# print $fh $response;
|
||||
# close $fh;
|
||||
|
||||
die "Watchman: command returned no output.\n" .
|
||||
"Falling back to scanning...\n" if $response eq "";
|
||||
die "Watchman: command returned invalid output: $response\n" .
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub is_work_tree_watched {
|
||||
my ($output) = @_;
|
||||
my $error = $output->{error};
|
||||
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
||||
$retry--;
|
||||
my $response = qx/watchman watch "$git_work_tree"/;
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
$output = $json_pkg->new->utf8->decode($response);
|
||||
$error = $output->{error};
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# close $fh;
|
||||
|
||||
# Watchman will always return all files on the first query so
|
||||
# return the fast "everything is dirty" flag to git and do the
|
||||
# Watchman query just to get it over with now so we won't pay
|
||||
# the cost in git to look up each individual file.
|
||||
my $o = watchman_clock();
|
||||
$error = $output->{error};
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
output_result($o->{clock}, ("/"));
|
||||
$last_update_token = $o->{clock};
|
||||
|
||||
eval { launch_watchman() };
|
||||
return 0;
|
||||
}
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_working_dir {
|
||||
my $working_dir;
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
||||
$working_dir = Win32::GetCwd();
|
||||
$working_dir =~ tr/\\/\//;
|
||||
} else {
|
||||
require Cwd;
|
||||
$working_dir = Cwd::cwd();
|
||||
}
|
||||
|
||||
return $working_dir;
|
||||
}
|
||||
8
dot_bash_it/dot_git/hooks/executable_post-update.sample
Normal file
8
dot_bash_it/dot_git/hooks/executable_post-update.sample
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
||||
14
dot_bash_it/dot_git/hooks/executable_pre-applypatch.sample
Normal file
14
dot_bash_it/dot_git/hooks/executable_pre-applypatch.sample
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
||||
49
dot_bash_it/dot_git/hooks/executable_pre-commit.sample
Normal file
49
dot_bash_it/dot_git/hooks/executable_pre-commit.sample
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
13
dot_bash_it/dot_git/hooks/executable_pre-merge-commit.sample
Normal file
13
dot_bash_it/dot_git/hooks/executable_pre-merge-commit.sample
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git merge" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message to
|
||||
# stderr if it wants to stop the merge commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-merge-commit".
|
||||
|
||||
. git-sh-setup
|
||||
test -x "$GIT_DIR/hooks/pre-commit" &&
|
||||
exec "$GIT_DIR/hooks/pre-commit"
|
||||
:
|
||||
53
dot_bash_it/dot_git/hooks/executable_pre-push.sample
Normal file
53
dot_bash_it/dot_git/hooks/executable_pre-push.sample
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local oid> <remote ref> <remote oid>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
|
||||
while read local_ref local_oid remote_ref remote_oid
|
||||
do
|
||||
if test "$local_oid" = "$zero"
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if test "$remote_oid" = "$zero"
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
|
||||
if test -n "$commit"
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
169
dot_bash_it/dot_git/hooks/executable_pre-rebase.sample
Normal file
169
dot_bash_it/dot_git/hooks/executable_pre-rebase.sample
Normal file
@@ -0,0 +1,169 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
||||
24
dot_bash_it/dot_git/hooks/executable_pre-receive.sample
Normal file
24
dot_bash_it/dot_git/hooks/executable_pre-receive.sample
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first one removes the
|
||||
# "# Please enter the commit message..." help message.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_SOURCE=$2
|
||||
SHA1=$3
|
||||
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||
|
||||
# case "$COMMIT_SOURCE,$SHA1" in
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||
# *) ;;
|
||||
# esac
|
||||
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||
# if test -z "$COMMIT_SOURCE"
|
||||
# then
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||
# fi
|
||||
78
dot_bash_it/dot_git/hooks/executable_push-to-checkout.sample
Normal file
78
dot_bash_it/dot_git/hooks/executable_push-to-checkout.sample
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to update a checked-out tree on a git push.
|
||||
#
|
||||
# This hook is invoked by git-receive-pack(1) when it reacts to git
|
||||
# push and updates reference(s) in its repository, and when the push
|
||||
# tries to update the branch that is currently checked out and the
|
||||
# receive.denyCurrentBranch configuration variable is set to
|
||||
# updateInstead.
|
||||
#
|
||||
# By default, such a push is refused if the working tree and the index
|
||||
# of the remote repository has any difference from the currently
|
||||
# checked out commit; when both the working tree and the index match
|
||||
# the current commit, they are updated to match the newly pushed tip
|
||||
# of the branch. This hook is to be used to override the default
|
||||
# behaviour; however the code below reimplements the default behaviour
|
||||
# as a starting point for convenient modification.
|
||||
#
|
||||
# The hook receives the commit with which the tip of the current
|
||||
# branch is going to be updated:
|
||||
commit=$1
|
||||
|
||||
# It can exit with a non-zero status to refuse the push (when it does
|
||||
# so, it must not modify the index or the working tree).
|
||||
die () {
|
||||
echo >&2 "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Or it can make any necessary changes to the working tree and to the
|
||||
# index to bring them to the desired state when the tip of the current
|
||||
# branch is updated to the new commit, and exit with a zero status.
|
||||
#
|
||||
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
|
||||
# in order to emulate git fetch that is run in the reverse direction
|
||||
# with git push, as the two-tree form of git read-tree -u -m is
|
||||
# essentially the same as git switch or git checkout that switches
|
||||
# branches while keeping the local changes in the working tree that do
|
||||
# not interfere with the difference between the branches.
|
||||
|
||||
# The below is a more-or-less exact translation to shell of the C code
|
||||
# for the default behaviour for git's push-to-checkout hook defined in
|
||||
# the push_to_deploy() function in builtin/receive-pack.c.
|
||||
#
|
||||
# Note that the hook will be executed from the repository directory,
|
||||
# not from the working tree, so if you want to perform operations on
|
||||
# the working tree, you will have to adapt your code accordingly, e.g.
|
||||
# by adding "cd .." or using relative paths.
|
||||
|
||||
if ! git update-index -q --ignore-submodules --refresh
|
||||
then
|
||||
die "Up-to-date check failed"
|
||||
fi
|
||||
|
||||
if ! git diff-files --quiet --ignore-submodules --
|
||||
then
|
||||
die "Working directory has unstaged changes"
|
||||
fi
|
||||
|
||||
# This is a rough translation of:
|
||||
#
|
||||
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
|
||||
if git cat-file -e HEAD 2>/dev/null
|
||||
then
|
||||
head=HEAD
|
||||
else
|
||||
head=$(git hash-object -t tree --stdin </dev/null)
|
||||
fi
|
||||
|
||||
if ! git diff-index --quiet --cached --ignore-submodules $head --
|
||||
then
|
||||
die "Working directory has staged changes"
|
||||
fi
|
||||
|
||||
if ! git read-tree -u -m "$commit"
|
||||
then
|
||||
die "Could not update working tree to new HEAD"
|
||||
fi
|
||||
128
dot_bash_it/dot_git/hooks/executable_update.sample
Normal file
128
dot_bash_it/dot_git/hooks/executable_update.sample
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --type=bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
||||
BIN
dot_bash_it/dot_git/index
Normal file
BIN
dot_bash_it/dot_git/index
Normal file
Binary file not shown.
6
dot_bash_it/dot_git/info/exclude
Normal file
6
dot_bash_it/dot_git/info/exclude
Normal file
@@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
1
dot_bash_it/dot_git/logs/HEAD
Normal file
1
dot_bash_it/dot_git/logs/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9 Kristjan Komlosi <kristjan@piskot.si> 1651780993 +0200 clone: from https://github.com/Bash-it/bash-it.git
|
||||
1
dot_bash_it/dot_git/logs/refs/heads/master
Normal file
1
dot_bash_it/dot_git/logs/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9 Kristjan Komlosi <kristjan@piskot.si> 1651780993 +0200 clone: from https://github.com/Bash-it/bash-it.git
|
||||
1
dot_bash_it/dot_git/logs/refs/remotes/origin/HEAD
Normal file
1
dot_bash_it/dot_git/logs/refs/remotes/origin/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9 Kristjan Komlosi <kristjan@piskot.si> 1651780993 +0200 clone: from https://github.com/Bash-it/bash-it.git
|
||||
0
dot_bash_it/dot_git/objects/info/.keep
Normal file
0
dot_bash_it/dot_git/objects/info/.keep
Normal file
Binary file not shown.
Binary file not shown.
2
dot_bash_it/dot_git/packed-refs
Normal file
2
dot_bash_it/dot_git/packed-refs
Normal file
@@ -0,0 +1,2 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9 refs/remotes/origin/master
|
||||
1
dot_bash_it/dot_git/refs/heads/master
Normal file
1
dot_bash_it/dot_git/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9
|
||||
1
dot_bash_it/dot_git/refs/remotes/origin/HEAD
Normal file
1
dot_bash_it/dot_git/refs/remotes/origin/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/remotes/origin/master
|
||||
0
dot_bash_it/dot_git/refs/tags/.keep
Normal file
0
dot_bash_it/dot_git/refs/tags/.keep
Normal file
1
dot_bash_it/dot_git/shallow
Normal file
1
dot_bash_it/dot_git/shallow
Normal file
@@ -0,0 +1 @@
|
||||
35334cdcb0a0db7bdba9b8146e8d6dcaac3f36d9
|
||||
9
dot_bash_it/dot_gitattributes
Normal file
9
dot_bash_it/dot_gitattributes
Normal file
@@ -0,0 +1,9 @@
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
|
||||
# Docs allow trailing whitespaces
|
||||
*.md whitespace=-blank-at-eol
|
||||
*.rst whitespace=-blank-at-eol
|
||||
|
||||
# Windows files
|
||||
*.bat text eol=crlf
|
||||
85
dot_bash_it/dot_github/ISSUE_TEMPLATE/bug_report.yml
Normal file
85
dot_bash_it/dot_github/ISSUE_TEMPLATE/bug_report.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
name: 🐛 Bug report
|
||||
title: "[Bug]: "
|
||||
description: Create a bug report to help us improve
|
||||
labels: "bug:general"
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: Tell us what should happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Current behavior
|
||||
description: Tell us what happens instead of the expected behavior.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Possible solution
|
||||
description: Tell us how it could be fixed at your glance.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Context
|
||||
description: >
|
||||
How has this issue affected you? What are you trying to accomplish?
|
||||
Providing context helps us come up with a solution that is most useful in the real world.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: >
|
||||
Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Bash-it version
|
||||
placeholder: "How to get: bash-it version"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: List of enabled plugins, themes and aliases
|
||||
placeholder: "How to get: bash-it show plugins|themes|aliases (it is not a pipe)"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Bash version
|
||||
placeholder: "How to get: bash --version"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Operating system and version
|
||||
placeholder: "How to get: neofetch (or another command)"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "bash-it doctor output"
|
||||
value: |
|
||||
```
|
||||
# How to get: bash-it doctor
|
||||
```
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Your ~/.bashrc
|
||||
value: |
|
||||
```bash
|
||||
# How to get: cat ~/.bashrc
|
||||
```
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Notes
|
||||
description: >
|
||||
Provide any extra details here.
|
||||
5
dot_bash_it/dot_github/ISSUE_TEMPLATE/config.yml
Normal file
5
dot_bash_it/dot_github/ISSUE_TEMPLATE/config.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Libera chat
|
||||
url: https://web.libera.chat/?channel=#bash-it
|
||||
about: You can ask and answer questions here
|
||||
34
dot_bash_it/dot_github/ISSUE_TEMPLATE/feature_request.yml
Normal file
34
dot_bash_it/dot_github/ISSUE_TEMPLATE/feature_request.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: 💡 Feature request
|
||||
title: "[Feature]: "
|
||||
description: Suggest an idea for this project
|
||||
labels: "feature request"
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: Tell us how your feature should work.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Current behavior
|
||||
description: Explain the difference your feature will have from current behavior.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Possible solution
|
||||
description: Tell us how it could be fixed at your glance.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Context
|
||||
description: >
|
||||
How has this issue affected you? What are you trying to accomplish?
|
||||
Providing context helps us come up with a solution that is most useful in the real world.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Notes
|
||||
description: >
|
||||
Provide any extra details here.
|
||||
30
dot_bash_it/dot_github/PULL_REQUEST_TEMPLATE.md
Normal file
30
dot_bash_it/dot_github/PULL_REQUEST_TEMPLATE.md
Normal file
@@ -0,0 +1,30 @@
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Screenshots (if appropriate):
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] If my change requires a change to the documentation, I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document.
|
||||
- [ ] If I have added a new file, I also added it to ``clean_files.txt`` and formatted it using ``lint_clean_files.sh``.
|
||||
- [ ] I have added tests to cover my changes, and all the new and existing tests pass.
|
||||
11
dot_bash_it/dot_github/no-response.yml
Normal file
11
dot_bash_it/dot_github/no-response.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
# Configuration for probot-no-response - https://github.com/probot/no-response
|
||||
|
||||
# Number of days of inactivity before an Issue is closed for lack of response
|
||||
daysUntilClose: 14
|
||||
# Label requiring a response
|
||||
responseRequiredLabel: waiting-for-response
|
||||
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
|
||||
closeComment: >
|
||||
This issue has been automatically closed because there has been no response
|
||||
to our request for more information from the original author.
|
||||
You can always reopen the issue if needed.
|
||||
59
dot_bash_it/dot_github/workflows/ci.yml
Normal file
59
dot_bash_it/dot_github/workflows/ci.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: CI
|
||||
|
||||
# Triggers the workflow on push or pull request events
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
bats-test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install greadlink
|
||||
if: startsWith(runner.os, 'macOS')
|
||||
run: brew install coreutils
|
||||
- name: Install parallel
|
||||
if: startsWith(runner.os, 'macOS')
|
||||
run: brew install parallel
|
||||
- name: Test code
|
||||
run: test/run
|
||||
|
||||
build-docs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install docs dependencies
|
||||
run: python3 -m pip install -r docs/requirements.txt
|
||||
- name: Build the docs
|
||||
run: sphinx-build -W -b html docs docs/_build/html
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install shfmt
|
||||
run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt
|
||||
- name: Install shellcheck
|
||||
run: brew install shellcheck
|
||||
- name: Install pre-commit
|
||||
run: python3 -m pip install -r test/lint-requirements.txt
|
||||
- name: Run lint
|
||||
run: ./lint_clean_files.sh
|
||||
24
dot_bash_it/dot_gitignore
Normal file
24
dot_bash_it/dot_gitignore
Normal file
@@ -0,0 +1,24 @@
|
||||
.atom-build.json
|
||||
*/enabled/*
|
||||
.DS_Store
|
||||
custom/*
|
||||
!custom/example.bash
|
||||
.rvmrc
|
||||
aliases/custom.aliases.bash
|
||||
completion/custom.completion.bash
|
||||
lib/custom.bash
|
||||
plugins/custom.plugins.bash
|
||||
*.swp
|
||||
.*.un~
|
||||
bats
|
||||
.idea
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
enabled/*
|
||||
/enabled
|
||||
tmp/
|
||||
|
||||
# Do not save profiles
|
||||
profiles/*
|
||||
# apart from the default one
|
||||
!profiles/default.bash_it
|
||||
16
dot_bash_it/dot_gitmodules
Normal file
16
dot_bash_it/dot_gitmodules
Normal file
@@ -0,0 +1,16 @@
|
||||
[submodule "test_lib/bats-core"]
|
||||
path = test_lib/bats-core
|
||||
url = https://github.com/bats-core/bats-core
|
||||
branch = tags/v1.2.0
|
||||
[submodule "test_lib/bats-support"]
|
||||
path = test_lib/bats-support
|
||||
url = https://github.com/bats-core/bats-support
|
||||
branch = tags/v0.3.0
|
||||
[submodule "test_lib/bats-assert"]
|
||||
path = test_lib/bats-assert
|
||||
url = https://github.com/bats-core/bats-assert
|
||||
branch = tags/v2.0.0
|
||||
[submodule "test_lib/bats-file"]
|
||||
path = test_lib/bats-file
|
||||
url = https://github.com/bats-core/bats-file
|
||||
branch = tags/v0.3.0
|
||||
50
dot_bash_it/dot_pre-commit-config.yaml
Normal file
50
dot_bash_it/dot_pre-commit-config.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
---
|
||||
# fail_fast: true
|
||||
minimum_pre_commit_version: 1.18.1
|
||||
exclude: "docs/_build/"
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
exclude: ".(md|rst)$"
|
||||
- id: end-of-file-fixer
|
||||
- id: check-merge-conflict
|
||||
- id: mixed-line-ending
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 2.1.5
|
||||
hooks:
|
||||
- id: git-check # Configure in .gitattributes
|
||||
- id: shellcheck
|
||||
exclude: ".bats$"
|
||||
- id: shfmt
|
||||
exclude: ".bats$"
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.1.7
|
||||
hooks:
|
||||
# - id: forbid-crlf
|
||||
- id: remove-crlf
|
||||
exclude: ".bat$"
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: dot-sh
|
||||
name: Check .sh files against bash-it requirements
|
||||
entry: ./hooks/dot-sh.sh
|
||||
language: system
|
||||
files: "\\.sh$"
|
||||
types: [file]
|
||||
- id: dot-bash
|
||||
name: Check .bash files against bash-it requirements
|
||||
exclude: "test/test_helper.bash"
|
||||
entry: ./hooks/dot-bash.sh
|
||||
language: system
|
||||
files: "\\.bash$"
|
||||
types: [file]
|
||||
- id: clean-files-txt
|
||||
name: Check that clean_files.txt is sorted alphabetically.
|
||||
entry: ./hooks/check-clean-files-txt.sh
|
||||
language: system
|
||||
files: clean_files.txt
|
||||
10
dot_bash_it/dot_readthedocs.yml
Normal file
10
dot_bash_it/dot_readthedocs.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
|
||||
sphinx:
|
||||
builder: htmldir
|
||||
configuration: docs/conf.py
|
||||
|
||||
python:
|
||||
version: 3.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
1
dot_bash_it/enabled/symlink_150---general.aliases.bash
Normal file
1
dot_bash_it/enabled/symlink_150---general.aliases.bash
Normal file
@@ -0,0 +1 @@
|
||||
../aliases/available/general.aliases.bash
|
||||
1
dot_bash_it/enabled/symlink_250---base.plugin.bash
Normal file
1
dot_bash_it/enabled/symlink_250---base.plugin.bash
Normal file
@@ -0,0 +1 @@
|
||||
../plugins/available/base.plugin.bash
|
||||
1
dot_bash_it/enabled/symlink_325---system.completion.bash
Normal file
1
dot_bash_it/enabled/symlink_325---system.completion.bash
Normal file
@@ -0,0 +1 @@
|
||||
../completion/available/system.completion.bash
|
||||
@@ -0,0 +1 @@
|
||||
../completion/available/bash-it.completion.bash
|
||||
@@ -0,0 +1 @@
|
||||
../completion/available/aliases.completion.bash
|
||||
110
dot_bash_it/executable_bash_it.sh
Normal file
110
dot_bash_it/executable_bash_it.sh
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck source-path=SCRIPTDIR/lib source-path=SCRIPTDIR/scripts
|
||||
# shellcheck disable=SC2034
|
||||
#
|
||||
# Initialize Bash It
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
: "${BASH_IT:=${BASH_SOURCE%/*}}"
|
||||
: "${BASH_IT_CUSTOM:=${BASH_IT}/custom}"
|
||||
: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM}/themes"}"
|
||||
: "${BASH_IT_BASHRC:=${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}}"
|
||||
|
||||
# Load composure first, so we support function metadata
|
||||
# shellcheck source-path=SCRIPTDIR/vendor/github.com/erichs/composure
|
||||
source "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
# support 'plumbing' metadata
|
||||
cite _about _param _example _group _author _version
|
||||
cite about-alias about-plugin about-completion
|
||||
|
||||
# Declare our end-of-main finishing hook, but don't use `declare`/`typeset`
|
||||
_bash_it_library_finalize_hook=()
|
||||
|
||||
# We need to load logging module early in order to be able to log
|
||||
source "${BASH_IT}/lib/log.bash"
|
||||
|
||||
# libraries, but skip appearance (themes) for now
|
||||
_log_debug "Loading libraries(except appearance)..."
|
||||
APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash"
|
||||
for _bash_it_main_file_lib in "${BASH_IT}/lib"/*.bash; do
|
||||
[[ "$_bash_it_main_file_lib" == "$APPEARANCE_LIB" ]] && continue
|
||||
_bash-it-log-prefix-by-path "${_bash_it_main_file_lib}"
|
||||
_log_debug "Loading library file..."
|
||||
# shellcheck disable=SC1090
|
||||
source "$_bash_it_main_file_lib"
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
done
|
||||
|
||||
# Load the global "enabled" directory, then enabled aliases, completion, plugins
|
||||
# "_bash_it_main_file_type" param is empty so that files get sourced in glob order
|
||||
for _bash_it_main_file_type in "" "aliases" "plugins" "completion"; do
|
||||
BASH_IT_LOG_PREFIX="core: reloader: "
|
||||
# shellcheck disable=SC2140
|
||||
source "${BASH_IT}/scripts/reloader.bash" ${_bash_it_main_file_type:+"skip" "$_bash_it_main_file_type"}
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
done
|
||||
|
||||
# Load theme, if a theme was set
|
||||
# shellcheck source-path=SCRIPTDIR/themes
|
||||
if [[ -n "${BASH_IT_THEME:-}" ]]; then
|
||||
_log_debug "Loading theme '${BASH_IT_THEME}'."
|
||||
BASH_IT_LOG_PREFIX="themes: githelpers: "
|
||||
source "${BASH_IT}/themes/githelpers.theme.bash"
|
||||
BASH_IT_LOG_PREFIX="themes: p4helpers: "
|
||||
source "${BASH_IT}/themes/p4helpers.theme.bash"
|
||||
BASH_IT_LOG_PREFIX="themes: base: "
|
||||
source "${BASH_IT}/themes/base.theme.bash"
|
||||
|
||||
BASH_IT_LOG_PREFIX="lib: appearance: "
|
||||
# appearance (themes) now, after all dependencies
|
||||
# shellcheck source=SCRIPTDIR/lib/appearance.bash
|
||||
source "$APPEARANCE_LIB"
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
fi
|
||||
|
||||
_log_debug "Loading custom aliases, completion, plugins..."
|
||||
for _bash_it_main_file_type in "aliases" "completion" "plugins"; do
|
||||
_bash_it_main_file_custom="${BASH_IT}/${_bash_it_main_file_type}/custom.${_bash_it_main_file_type}.bash"
|
||||
if [[ -s "${_bash_it_main_file_custom}" ]]; then
|
||||
_bash-it-log-prefix-by-path "${_bash_it_main_file_custom}"
|
||||
_log_debug "Loading component..."
|
||||
# shellcheck disable=SC1090
|
||||
source "${_bash_it_main_file_custom}"
|
||||
fi
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
done
|
||||
|
||||
# Custom
|
||||
_log_debug "Loading general custom files..."
|
||||
for _bash_it_main_file_custom in "${BASH_IT_CUSTOM}"/*.bash "${BASH_IT_CUSTOM}"/*/*.bash; do
|
||||
if [[ -s "${_bash_it_main_file_custom}" ]]; then
|
||||
_bash-it-log-prefix-by-path "${_bash_it_main_file_custom}"
|
||||
_log_debug "Loading custom file..."
|
||||
# shellcheck disable=SC1090
|
||||
source "$_bash_it_main_file_custom"
|
||||
fi
|
||||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
done
|
||||
|
||||
if [[ -n "${PROMPT:-}" ]]; then
|
||||
PS1="${PROMPT}"
|
||||
fi
|
||||
|
||||
# Adding Support for other OSes
|
||||
if _command_exists gloobus-preview; then
|
||||
PREVIEW="gloobus-preview"
|
||||
elif [[ -d /Applications/Preview.app ]]; then
|
||||
PREVIEW="/Applications/Preview.app"
|
||||
else
|
||||
PREVIEW="less"
|
||||
fi
|
||||
|
||||
# BASH_IT_RELOAD_LEGACY is set.
|
||||
if [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]] && ! _command_exists reload; then
|
||||
# shellcheck disable=SC2139
|
||||
alias reload="builtin source '${BASH_IT_BASHRC?}'"
|
||||
fi
|
||||
|
||||
for _bash_it_library_finalize_f in "${_bash_it_library_finalize_hook[@]:-}"; do
|
||||
eval "${_bash_it_library_finalize_f?}" # Use `eval` to achieve the same behavior as `$PROMPT_COMMAND`.
|
||||
done
|
||||
unset "${!_bash_it_library_finalize_@}" "${!_bash_it_main_file_@}"
|
||||
238
dot_bash_it/executable_install.sh
Normal file
238
dot_bash_it/executable_install.sh
Normal file
@@ -0,0 +1,238 @@
|
||||
#!/usr/bin/env bash
|
||||
# bash-it installer
|
||||
|
||||
# Show how to use this installer
|
||||
function _bash-it_show_usage() {
|
||||
echo -e "\n$0 : Install bash-it"
|
||||
echo -e "Usage:\n$0 [arguments] \n"
|
||||
echo "Arguments:"
|
||||
echo "--help (-h): Display this help message"
|
||||
echo "--silent (-s): Install default settings without prompting for input"
|
||||
echo "--interactive (-i): Interactively choose plugins"
|
||||
echo "--no-modify-config (-n): Do not modify existing config file"
|
||||
echo "--append-to-config (-a): Keep existing config file and append bash-it templates at the end"
|
||||
echo "--overwrite-backup (-f): Overwrite existing backup"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# enable a thing
|
||||
function _bash-it_load_one() {
|
||||
file_type=$1
|
||||
file_to_enable=$2
|
||||
mkdir -p "$BASH_IT/${file_type}/enabled"
|
||||
|
||||
dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}"
|
||||
if [ ! -e "${dest}" ]; then
|
||||
ln -sf "../available/${file_to_enable}" "${dest}"
|
||||
else
|
||||
echo "File ${dest} exists, skipping"
|
||||
fi
|
||||
}
|
||||
|
||||
# Interactively enable several things
|
||||
function _bash-it_load_some() {
|
||||
file_type=$1
|
||||
single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g")
|
||||
enable_func="_enable-$single_type"
|
||||
[ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled"
|
||||
for path in "$BASH_IT/${file_type}/available/"[^_]*; do
|
||||
file_name=$(basename "$path")
|
||||
while true; do
|
||||
just_the_name="${file_name%%.*}"
|
||||
read -r -e -n 1 -p "Would you like to enable the $just_the_name $file_type? [y/N] " RESP
|
||||
case $RESP in
|
||||
[yY])
|
||||
$enable_func "$just_the_name"
|
||||
break
|
||||
;;
|
||||
[nN] | "")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[91mPlease choose y or n.\033[m"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Back up existing profile
|
||||
function _bash-it_backup() {
|
||||
test -w "$HOME/$CONFIG_FILE" \
|
||||
&& cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" \
|
||||
&& echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
|
||||
}
|
||||
|
||||
# Back up existing profile and create new one for bash-it
|
||||
function _bash-it_backup_new() {
|
||||
_bash-it_backup
|
||||
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
|
||||
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"
|
||||
}
|
||||
|
||||
# Back up existing profile and append bash-it templates at the end
|
||||
function _bash-it_backup_append() {
|
||||
_bash-it_backup
|
||||
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE"
|
||||
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
|
||||
}
|
||||
|
||||
function _bash-it_check_for_backup() {
|
||||
if ! [[ -e "$HOME/$BACKUP_FILE" ]]; then
|
||||
return
|
||||
fi
|
||||
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
|
||||
|
||||
if [[ -z "${overwrite_backup}" ]]; then
|
||||
while [[ -z "${silent}" ]]; do
|
||||
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
|
||||
case $RESP in
|
||||
[yY])
|
||||
overwrite_backup=true
|
||||
break
|
||||
;;
|
||||
[nN] | "")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[91mPlease choose y or n.\033[m"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
if [[ -z "${overwrite_backup}" ]]; then
|
||||
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
|
||||
if [[ -n "${silent}" ]]; then
|
||||
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
|
||||
fi
|
||||
exit 1
|
||||
else
|
||||
echo -e "\033[0;32mOverwriting backup...\033[m"
|
||||
fi
|
||||
}
|
||||
|
||||
function _bash-it_modify_config_files() {
|
||||
_bash-it_check_for_backup
|
||||
|
||||
if [[ -z "${silent}" ]]; then
|
||||
while [[ -z "${append_to_config}" ]]; do
|
||||
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
|
||||
case $choice in
|
||||
[yY])
|
||||
append_to_config=true
|
||||
break
|
||||
;;
|
||||
[nN] | "")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[91mPlease choose y or n.\033[m"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
if [[ -n "${append_to_config}" ]]; then
|
||||
# backup/append
|
||||
_bash-it_backup_append
|
||||
else
|
||||
# backup/new by default
|
||||
_bash-it_backup_new
|
||||
fi
|
||||
}
|
||||
|
||||
for param in "$@"; do
|
||||
shift
|
||||
case "$param" in
|
||||
"--help") set -- "$@" "-h" ;;
|
||||
"--silent") set -- "$@" "-s" ;;
|
||||
"--interactive") set -- "$@" "-i" ;;
|
||||
"--no-modify-config") set -- "$@" "-n" ;;
|
||||
"--append-to-config") set -- "$@" "-a" ;;
|
||||
"--overwrite-backup") set -- "$@" "-f" ;;
|
||||
*) set -- "$@" "$param" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
OPTIND=1
|
||||
while getopts "hsinaf" opt; do
|
||||
case "$opt" in
|
||||
"h")
|
||||
_bash-it_show_usage
|
||||
exit 0
|
||||
;;
|
||||
"s") silent=true ;;
|
||||
"i") interactive=true ;;
|
||||
"n") no_modify_config=true ;;
|
||||
"a") append_to_config=true ;;
|
||||
"f") overwrite_backup=true ;;
|
||||
"?")
|
||||
_bash-it_show_usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
if [[ -n "${silent}" && -n "${interactive}" ]]; then
|
||||
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
|
||||
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASH_IT="$(cd "${BASH_SOURCE%/*}" && pwd)"
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
CONFIG_FILE=.bash_profile
|
||||
;;
|
||||
*)
|
||||
CONFIG_FILE=.bashrc
|
||||
;;
|
||||
esac
|
||||
|
||||
BACKUP_FILE=$CONFIG_FILE.bak
|
||||
echo "Installing bash-it"
|
||||
if [[ -z "${no_modify_config}" ]]; then
|
||||
_bash-it_modify_config_files
|
||||
fi
|
||||
|
||||
# Disable auto-reload in case its enabled
|
||||
export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=''
|
||||
# Load dependencies for enabling components
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
|
||||
# shellcheck source=./lib/utilities.bash
|
||||
source "$BASH_IT/lib/utilities.bash"
|
||||
# shellcheck source=./lib/log.bash
|
||||
source "${BASH_IT}/lib/log.bash"
|
||||
cite _about _param _example _group _author _version
|
||||
# shellcheck source=./lib/helpers.bash
|
||||
source "$BASH_IT/lib/helpers.bash"
|
||||
|
||||
if [[ -n $interactive && -z "${silent}" ]]; then
|
||||
for type in "aliases" "plugins" "completion"; do
|
||||
echo -e "\033[0;32mEnabling ${type}\033[0m"
|
||||
_bash-it_load_some "$type"
|
||||
done
|
||||
else
|
||||
echo ""
|
||||
_bash-it-profile-load "default"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
|
||||
# shellcheck disable=SC2086
|
||||
echo -e "\033[0;32mTo start using it, open a new tab or 'source "~/$CONFIG_FILE"'.\033[0m"
|
||||
echo ""
|
||||
echo "To show the available aliases/completions/plugins, type one of the following:"
|
||||
echo " bash-it show aliases"
|
||||
echo " bash-it show completions"
|
||||
echo " bash-it show plugins"
|
||||
echo ""
|
||||
echo "To avoid issues and to keep your shell lean, please enable only features you really want to use."
|
||||
echo "Enabling everything can lead to issues."
|
||||
23
dot_bash_it/executable_lint_clean_files.sh
Normal file
23
dot_bash_it/executable_lint_clean_files.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Pull list of checkable files from clean_files.txt
|
||||
# - Folder references are allowed
|
||||
# - Empty lines are ignored
|
||||
# - Comment lines (#) are ignored
|
||||
#
|
||||
# shellcheck disable=SC2002 # Prefer 'cat' for cleaner script
|
||||
mapfile -t FILES < <(
|
||||
cat clean_files.txt \
|
||||
| grep -v -E '^\s*$' \
|
||||
| grep -v -E '^\s*#' \
|
||||
| xargs -n1 -I{} find "{}" -type f
|
||||
)
|
||||
|
||||
# We clear the BASH_IT variable to help the shellcheck checker
|
||||
# identify source includes within our scripts that require a
|
||||
# 'source' directive. For more information, see:
|
||||
#
|
||||
# "Shellcheck SC1090 - Can't follow non-constant source"
|
||||
# https://www.shellcheck.net/wiki/SC1090
|
||||
#
|
||||
BASH_IT='' pre-commit run --files "${FILES[@]}"
|
||||
36
dot_bash_it/executable_uninstall.sh
Normal file
36
dot_bash_it/executable_uninstall.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -z "$BASH_IT" ];
|
||||
then
|
||||
BASH_IT="$HOME/.bash_it"
|
||||
fi
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
CONFIG_FILE=.bash_profile
|
||||
;;
|
||||
*)
|
||||
CONFIG_FILE=.bashrc
|
||||
;;
|
||||
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
|
||||
|
||||
test -w "$HOME/$CONFIG_FILE" &&
|
||||
mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" &&
|
||||
echo -e "\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m"
|
||||
else
|
||||
test -w "$HOME/$BACKUP_FILE" &&
|
||||
cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE" &&
|
||||
rm "$HOME/$BACKUP_FILE" &&
|
||||
echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "\033[0;32mUninstallation finished successfully! Sorry to see you go!\033[0m"
|
||||
echo ""
|
||||
echo "Final steps to complete the uninstallation:"
|
||||
echo " -> Remove the $BASH_IT folder"
|
||||
echo " -> Open a new shell/tab/terminal"
|
||||
39
dot_bash_it/hooks/executable_check-clean-files-txt.sh
Normal file
39
dot_bash_it/hooks/executable_check-clean-files-txt.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
file=$1
|
||||
# Should only be run on clean_files.txt
|
||||
if [ "$file" != "clean_files.txt" ]; then
|
||||
echo "Please run this script on clean_files.txt only!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function compare_lines() {
|
||||
prev=""
|
||||
while read -r line; do
|
||||
# Skip unimportant lines
|
||||
[[ $line =~ "#" ]] && continue
|
||||
[[ $line == "" ]] && continue
|
||||
# Actual check
|
||||
if [[ $prev > $line ]]; then
|
||||
echo "$line should be before $prev"
|
||||
exit 1
|
||||
fi
|
||||
prev=$line
|
||||
done <<< "$1"
|
||||
}
|
||||
|
||||
# We compare using the legacy way
|
||||
shopt -s compat31
|
||||
|
||||
# Test root files
|
||||
compare_lines "$(grep -v "/" "$file")"
|
||||
|
||||
# Test root directory
|
||||
compare_lines "$(grep "/$" "$file")"
|
||||
|
||||
# Test non root directories
|
||||
compare_lines "$(grep "/." "$file")"
|
||||
|
||||
shopt -u compat31
|
||||
# Yay, all good!
|
||||
exit 0
|
||||
21
dot_bash_it/hooks/executable_dot-bash.sh
Normal file
21
dot_bash_it/hooks/executable_dot-bash.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
exit_code=0
|
||||
for file in "$@"; do
|
||||
# Confirm file is not executable
|
||||
#
|
||||
if [[ -x "${file}" ]]; then
|
||||
echo "Bash include file \`${file}\` should not be executable"
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
# Confirm expected schellcheck header
|
||||
#
|
||||
LINE1="$(head -n 1 "${file}")"
|
||||
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then
|
||||
echo "Bash include file \`${file}\` has bad/missing shellcheck header"
|
||||
exit_code=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "${exit_code:-0}"
|
||||
21
dot_bash_it/hooks/executable_dot-sh.sh
Normal file
21
dot_bash_it/hooks/executable_dot-sh.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
exit_code=0
|
||||
for file in "$@"; do
|
||||
# Confirm file is executable
|
||||
#
|
||||
if [[ ! -x "${file}" ]]; then
|
||||
echo "Bash file \`${file}\` is not executable"
|
||||
exit_code=1
|
||||
fi
|
||||
|
||||
# Confirm expected #! header
|
||||
#
|
||||
LINE1="$(head -n 1 "${file}")"
|
||||
if [[ "${LINE1}" != "#!/usr/bin/env bash" ]]; then
|
||||
echo "Bash file \`${file}\` has bad/missing #! header"
|
||||
exit_code=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "${exit_code:-0}"
|
||||
18
dot_bash_it/lib/appearance.bash
Normal file
18
dot_bash_it/lib/appearance.bash
Normal file
@@ -0,0 +1,18 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
: "${CLICOLOR:=$(tput colors)}"
|
||||
export CLICOLOR
|
||||
|
||||
: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/themes"}"
|
||||
|
||||
# Load the theme
|
||||
# shellcheck disable=SC1090
|
||||
if [[ -n "${BASH_IT_THEME:-}" ]]; 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"
|
||||
fi
|
||||
fi
|
||||
91
dot_bash_it/lib/colors.bash
Normal file
91
dot_bash_it/lib/colors.bash
Normal file
@@ -0,0 +1,91 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034
|
||||
#
|
||||
# A set of pre-defined color escape codes for use in prompts and with `echo`.
|
||||
|
||||
black="\[\e[0;30m\]"
|
||||
red="\[\e[0;31m\]"
|
||||
green="\[\e[0;32m\]"
|
||||
yellow="\[\e[0;33m\]"
|
||||
blue="\[\e[0;34m\]"
|
||||
purple="\[\e[0;35m\]"
|
||||
cyan="\[\e[0;36m\]"
|
||||
white="\[\e[0;37m\]"
|
||||
orange="\[\e[0;91m\]"
|
||||
|
||||
bold_black="\[\e[30;1m\]"
|
||||
bold_red="\[\e[31;1m\]"
|
||||
bold_green="\[\e[32;1m\]"
|
||||
bold_yellow="\[\e[33;1m\]"
|
||||
bold_blue="\[\e[34;1m\]"
|
||||
bold_purple="\[\e[35;1m\]"
|
||||
bold_cyan="\[\e[36;1m\]"
|
||||
bold_white="\[\e[37;1m\]"
|
||||
bold_orange="\[\e[91;1m\]"
|
||||
|
||||
underline_black="\[\e[30;4m\]"
|
||||
underline_red="\[\e[31;4m\]"
|
||||
underline_green="\[\e[32;4m\]"
|
||||
underline_yellow="\[\e[33;4m\]"
|
||||
underline_blue="\[\e[34;4m\]"
|
||||
underline_purple="\[\e[35;4m\]"
|
||||
underline_cyan="\[\e[36;4m\]"
|
||||
underline_white="\[\e[37;4m\]"
|
||||
underline_orange="\[\e[91;4m\]"
|
||||
|
||||
background_black="\[\e[40m\]"
|
||||
background_red="\[\e[41m\]"
|
||||
background_green="\[\e[42m\]"
|
||||
background_yellow="\[\e[43m\]"
|
||||
background_blue="\[\e[44m\]"
|
||||
background_purple="\[\e[45m\]"
|
||||
background_cyan="\[\e[46m\]"
|
||||
background_white="\[\e[47;1m\]"
|
||||
background_orange="\[\e[101m\]"
|
||||
|
||||
normal="\[\e[0m\]"
|
||||
reset_color="\[\e[39m\]"
|
||||
|
||||
# These colors are meant to be used with `echo -e`
|
||||
echo_black="\033[0;30m"
|
||||
echo_red="\033[0;31m"
|
||||
echo_green="\033[0;32m"
|
||||
echo_yellow="\033[0;33m"
|
||||
echo_blue="\033[0;34m"
|
||||
echo_purple="\033[0;35m"
|
||||
echo_cyan="\033[0;36m"
|
||||
echo_white="\033[0;37;1m"
|
||||
echo_orange="\033[0;91m"
|
||||
|
||||
echo_bold_black="\033[30;1m"
|
||||
echo_bold_red="\033[31;1m"
|
||||
echo_bold_green="\033[32;1m"
|
||||
echo_bold_yellow="\033[33;1m"
|
||||
echo_bold_blue="\033[34;1m"
|
||||
echo_bold_purple="\033[35;1m"
|
||||
echo_bold_cyan="\033[36;1m"
|
||||
echo_bold_white="\033[37;1m"
|
||||
echo_bold_orange="\033[91;1m"
|
||||
|
||||
echo_underline_black="\033[30;4m"
|
||||
echo_underline_red="\033[31;4m"
|
||||
echo_underline_green="\033[32;4m"
|
||||
echo_underline_yellow="\033[33;4m"
|
||||
echo_underline_blue="\033[34;4m"
|
||||
echo_underline_purple="\033[35;4m"
|
||||
echo_underline_cyan="\033[36;4m"
|
||||
echo_underline_white="\033[37;4m"
|
||||
echo_underline_orange="\033[91;4m"
|
||||
|
||||
echo_background_black="\033[40m"
|
||||
echo_background_red="\033[41m"
|
||||
echo_background_green="\033[42m"
|
||||
echo_background_yellow="\033[43m"
|
||||
echo_background_blue="\033[44m"
|
||||
echo_background_purple="\033[45m"
|
||||
echo_background_cyan="\033[46m"
|
||||
echo_background_white="\033[47;1m"
|
||||
echo_background_orange="\033[101m"
|
||||
|
||||
echo_normal="\033[0m"
|
||||
echo_reset_color="\033[39m"
|
||||
61
dot_bash_it/lib/command_duration.bash
Normal file
61
dot_bash_it/lib/command_duration.bash
Normal file
@@ -0,0 +1,61 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Functions for measuring and reporting how long a command takes to run.
|
||||
|
||||
: "${COMMAND_DURATION_START_SECONDS:=${EPOCHREALTIME:-$SECONDS}}"
|
||||
: "${COMMAND_DURATION_ICON:=🕘}"
|
||||
: "${COMMAND_DURATION_MIN_SECONDS:=1}"
|
||||
|
||||
function _command_duration_pre_exec() {
|
||||
COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}"
|
||||
}
|
||||
|
||||
function _dynamic_clock_icon {
|
||||
local clock_hand
|
||||
# clock hand value is between 90 and 9b in hexadecimal.
|
||||
# so between 144 and 155 in base 10.
|
||||
printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144))
|
||||
printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand"
|
||||
}
|
||||
|
||||
function _command_duration() {
|
||||
[[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return
|
||||
|
||||
local command_duration=0 command_start="${COMMAND_DURATION_START_SECONDS:-0}"
|
||||
local -i minutes=0 seconds=0 deciseconds=0
|
||||
local -i command_start_seconds="${command_start%.*}"
|
||||
local -i command_start_deciseconds=$((10#${command_start##*.}))
|
||||
command_start_deciseconds="${command_start_deciseconds:0:1}"
|
||||
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
||||
local -i current_time_seconds="${current_time%.*}"
|
||||
local -i current_time_deciseconds="$((10#${current_time##*.}))"
|
||||
current_time_deciseconds="${current_time_deciseconds:0:1}"
|
||||
|
||||
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
|
||||
# seconds
|
||||
command_duration="$((current_time_seconds - command_start_seconds))"
|
||||
|
||||
if ((current_time_deciseconds >= command_start_deciseconds)); then
|
||||
deciseconds="$((current_time_deciseconds - command_start_deciseconds))"
|
||||
else
|
||||
((command_duration -= 1))
|
||||
deciseconds="$((10 - (command_start_deciseconds - current_time_deciseconds)))"
|
||||
fi
|
||||
else
|
||||
command_duration=0
|
||||
fi
|
||||
|
||||
if ((command_duration > 0)); then
|
||||
minutes=$((command_duration / 60))
|
||||
seconds=$((command_duration % 60))
|
||||
fi
|
||||
|
||||
_dynamic_clock_icon "${command_duration}"
|
||||
if ((minutes > 0)); then
|
||||
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
|
||||
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
|
||||
printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
|
||||
fi
|
||||
}
|
||||
|
||||
_bash_it_library_finalize_hook+=("safe_append_preexec '_command_duration_pre_exec'")
|
||||
1040
dot_bash_it/lib/helpers.bash
Normal file
1040
dot_bash_it/lib/helpers.bash
Normal file
File diff suppressed because it is too large
Load Diff
49
dot_bash_it/lib/history.bash
Normal file
49
dot_bash_it/lib/history.bash
Normal file
@@ -0,0 +1,49 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Functions for working with Bash's command history.
|
||||
|
||||
function _bash-it-history-init() {
|
||||
safe_append_preexec '_bash-it-history-auto-save'
|
||||
safe_append_prompt_command '_bash-it-history-auto-load'
|
||||
}
|
||||
|
||||
function _bash-it-history-auto-save() {
|
||||
case $HISTCONTROL in
|
||||
*'noauto'* | *'autoload'*)
|
||||
: # Do nothing, as configured.
|
||||
;;
|
||||
*'auto'*)
|
||||
# Append new history from this session to the $HISTFILE
|
||||
history -a
|
||||
;;
|
||||
*)
|
||||
# Append *only* if shell option `histappend` has been enabled.
|
||||
shopt -q histappend && history -a && return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function _bash-it-history-auto-load() {
|
||||
case $HISTCONTROL in
|
||||
*'noauto'*)
|
||||
: # Do nothing, as configured.
|
||||
;;
|
||||
*'autosave'*)
|
||||
# Append new history from this session to the $HISTFILE
|
||||
history -a
|
||||
;;
|
||||
*'autoloadnew'*)
|
||||
# Read new entries from $HISTFILE
|
||||
history -n
|
||||
;;
|
||||
*'auto'*)
|
||||
# Blank in-memory history, then read entire $HISTFILE fresh from disk.
|
||||
history -a && history -c && history -r
|
||||
;;
|
||||
*)
|
||||
: # Do nothing, default.
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_bash_it_library_finalize_hook+=('_bash-it-history-init')
|
||||
100
dot_bash_it/lib/log.bash
Normal file
100
dot_bash_it/lib/log.bash
Normal file
@@ -0,0 +1,100 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# A collection of logging functions.
|
||||
|
||||
# Declare log severity levels, matching syslog numbering
|
||||
: "${BASH_IT_LOG_LEVEL_FATAL:=1}"
|
||||
: "${BASH_IT_LOG_LEVEL_ERROR:=3}"
|
||||
: "${BASH_IT_LOG_LEVEL_WARNING:=4}"
|
||||
: "${BASH_IT_LOG_LEVEL_ALL:=6}"
|
||||
: "${BASH_IT_LOG_LEVEL_INFO:=6}"
|
||||
: "${BASH_IT_LOG_LEVEL_TRACE:=7}"
|
||||
readonly "${!BASH_IT_LOG_LEVEL_@}"
|
||||
|
||||
function _bash-it-log-prefix-by-path() {
|
||||
local component_path="${1?${FUNCNAME[0]}: path specification required}"
|
||||
local without_extension component_directory
|
||||
local component_filename component_type component_name
|
||||
|
||||
# get the directory, if any
|
||||
component_directory="${component_path%/*}"
|
||||
# drop the directory, if any
|
||||
component_filename="${component_path##*/}"
|
||||
# strip the file extension
|
||||
without_extension="${component_filename%.bash}"
|
||||
# strip before the last dot
|
||||
component_type="${without_extension##*.}"
|
||||
# strip component type, but try not to strip other words
|
||||
# - aliases, completions, plugins, themes
|
||||
component_name="${without_extension%.[acpt][hlo][eimu]*[ens]}"
|
||||
# Finally, strip load priority prefix
|
||||
component_name="${component_name##[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR:----}"}"
|
||||
|
||||
# best-guess for files without a type
|
||||
if [[ "${component_type:-${component_name}}" == "${component_name}" ]]; then
|
||||
if [[ "${component_directory}" == *'vendor'* ]]; then
|
||||
component_type='vendor'
|
||||
else
|
||||
component_type="${component_directory##*/}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
BASH_IT_LOG_PREFIX="${component_type:-lib}: $component_name"
|
||||
}
|
||||
|
||||
function _has_colors() {
|
||||
# Check that stdout is a terminal, and that it has at least 8 colors.
|
||||
[[ -t 1 && "${CLICOLOR:=$(tput colors 2> /dev/null)}" -ge 8 ]]
|
||||
}
|
||||
|
||||
function _bash-it-log-message() {
|
||||
: _about 'Internal function used for logging, uses BASH_IT_LOG_PREFIX as a prefix'
|
||||
: _param '1: color of the message'
|
||||
: _param '2: log level to print before the prefix'
|
||||
: _param '3: message to log'
|
||||
: _group 'log'
|
||||
|
||||
local prefix="${BASH_IT_LOG_PREFIX:-default}"
|
||||
local color="${1-${echo_cyan:-}}"
|
||||
local level="${2:-TRACE}"
|
||||
local message="${level%: }: ${prefix%: }: ${3?}"
|
||||
if _has_colors; then
|
||||
printf '%b%s%b\n' "${color}" "${message}" "${echo_normal:-}"
|
||||
else
|
||||
printf '%s\n' "${message}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _log_debug() {
|
||||
: _about 'log a debug message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_INFO'
|
||||
: _param '1: message to log'
|
||||
: _example '$ _log_debug "Loading plugin git..."'
|
||||
: _group 'log'
|
||||
|
||||
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_INFO?}" ]]; then
|
||||
_bash-it-log-message "${echo_green:-}" "DEBUG: " "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function _log_warning() {
|
||||
: _about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_WARNING'
|
||||
: _param '1: message to log'
|
||||
: _example '$ _log_warning "git binary not found, disabling git plugin..."'
|
||||
: _group 'log'
|
||||
|
||||
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_WARNING?}" ]]; then
|
||||
_bash-it-log-message "${echo_yellow:-}" " WARN: " "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function _log_error() {
|
||||
: _about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_ERROR'
|
||||
: _param '1: message to log'
|
||||
: _example '$ _log_error "Failed to load git plugin..."'
|
||||
: _group 'log'
|
||||
|
||||
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_ERROR?}" ]]; then
|
||||
_bash-it-log-message "${echo_red:-}" "ERROR: " "$1"
|
||||
fi
|
||||
}
|
||||
75
dot_bash_it/lib/preexec.bash
Normal file
75
dot_bash_it/lib/preexec.bash
Normal file
@@ -0,0 +1,75 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034
|
||||
#
|
||||
# Load the `bash-preexec.sh` library, and define helper functions
|
||||
|
||||
## Prepare, load, fix, and install `bash-preexec.sh`
|
||||
|
||||
# Disable `$PROMPT_COMMAND` modification for now.
|
||||
__bp_delay_install="delayed"
|
||||
|
||||
# shellcheck source-path=SCRIPTDIR/../vendor/github.com/rcaloras/bash-preexec
|
||||
source "${BASH_IT?}/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh"
|
||||
|
||||
# Block damanaging user's `$HISTCONTROL`
|
||||
function __bp_adjust_histcontrol() { :; }
|
||||
|
||||
# Don't fail on readonly variables
|
||||
function __bp_require_not_readonly() { :; }
|
||||
|
||||
# For performance, testing, and to avoid unexpected behavior: disable DEBUG traps in subshells.
|
||||
# See bash-it/bash-it#1040 and rcaloras/bash-preexec#26
|
||||
: "${__bp_enable_subshells:=}" # blank
|
||||
|
||||
# Modify `$PROMPT_COMMAND` in finalize hook
|
||||
_bash_it_library_finalize_hook+=('__bp_install_after_session_init')
|
||||
|
||||
## Helper functions
|
||||
function __check_precmd_conflict() {
|
||||
local f
|
||||
__bp_trim_whitespace f "${1?}"
|
||||
_bash-it-array-contains-element "${f}" "${precmd_functions[@]}"
|
||||
}
|
||||
|
||||
function __check_preexec_conflict() {
|
||||
local f
|
||||
__bp_trim_whitespace f "${1?}"
|
||||
_bash-it-array-contains-element "${f}" "${preexec_functions[@]}"
|
||||
}
|
||||
|
||||
function safe_append_prompt_command() {
|
||||
local prompt_re prompt_er f
|
||||
|
||||
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then
|
||||
# We are using bash-preexec
|
||||
__bp_trim_whitespace f "${1?}"
|
||||
if ! __check_precmd_conflict "${f}"; then
|
||||
precmd_functions+=("${f}")
|
||||
fi
|
||||
else
|
||||
# Match on word-boundaries
|
||||
prompt_re='(^|[^[:alnum:]_])'
|
||||
prompt_er='([^[:alnum:]_]|$)'
|
||||
if [[ ${PROMPT_COMMAND} =~ ${prompt_re}"${1}"${prompt_er} ]]; then
|
||||
return
|
||||
elif [[ -z ${PROMPT_COMMAND} ]]; then
|
||||
PROMPT_COMMAND="${1}"
|
||||
else
|
||||
PROMPT_COMMAND="${1};${PROMPT_COMMAND}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function safe_append_preexec() {
|
||||
local prompt_re f
|
||||
|
||||
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then
|
||||
# We are using bash-preexec
|
||||
__bp_trim_whitespace f "${1?}"
|
||||
if ! __check_preexec_conflict "${f}"; then
|
||||
preexec_functions+=("${f}")
|
||||
fi
|
||||
else
|
||||
_log_error "${FUNCNAME[0]}: can't append to preexec hook because _bash-preexec.sh_ hasn't been loaded"
|
||||
fi
|
||||
}
|
||||
34
dot_bash_it/lib/preview.bash
Normal file
34
dot_bash_it/lib/preview.bash
Normal file
@@ -0,0 +1,34 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Displays the prompt from each _Bash It_ theme.
|
||||
|
||||
function _bash-it-preview() {
|
||||
local BASH_IT_THEME BASH_IT_LOG_LEVEL
|
||||
local themes IFS=$'\n' cur
|
||||
|
||||
if [[ $# -gt '0' ]]; then
|
||||
themes=("$@")
|
||||
else
|
||||
themes=("${BASH_IT?}/themes"/*/*.theme.bash)
|
||||
themes=("${themes[@]##*/}")
|
||||
themes=("${themes[@]%.theme.bash}")
|
||||
fi
|
||||
|
||||
if [[ ${COMP_CWORD:-} -gt '0' ]]; then
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "all${IFS}${themes[*]}" -- "${cur}")
|
||||
return
|
||||
fi
|
||||
printf '\n\n\t%s\n\n' "Previewing Bash-it Themes"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
for BASH_IT_THEME in "${themes[@]}"; do
|
||||
BASH_IT_LOG_LEVEL=0
|
||||
bash --init-file "${BASH_IT?}/bash_it.sh" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"'
|
||||
done
|
||||
}
|
||||
|
||||
if [[ -n "${BASH_PREVIEW:-}" ]]; then
|
||||
_bash-it-preview "${BASH_PREVIEW}" "$@"
|
||||
unset BASH_PREVIEW #Prevent infinite looping
|
||||
fi
|
||||
373
dot_bash_it/lib/search.bash
Normal file
373
dot_bash_it/lib/search.bash
Normal file
@@ -0,0 +1,373 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Search by Konstantin Gredeskoul «github.com/kigster»
|
||||
#———————————————————————————————————————————————————————————————————————————————
|
||||
# This function returns list of aliases, plugins and completions in bash-it,
|
||||
# whose name or description matches one of the search terms provided as arguments.
|
||||
#
|
||||
# Usage:
|
||||
# ❯ bash-it search [-|@]term1 [-|@]term2 ... \
|
||||
# [ --enable | -e ] \
|
||||
# [ --disable | -d ] \
|
||||
# [ --no-color | -c ] \
|
||||
# [ --refresh | -r ] \
|
||||
# [ --help | -h ]
|
||||
#
|
||||
# Single dash, as in "-chruby", indicates a negative search term.
|
||||
# Double dash indicates a command that is to be applied to the search result.
|
||||
# At the moment only --help, --enable and --disable are supported.
|
||||
# An '@' sign indicates an exact (not partial) match.
|
||||
#
|
||||
# Examples:
|
||||
# ❯ bash-it search ruby rbenv rvm gem rake
|
||||
# aliases: bundler
|
||||
# plugins: chruby chruby-auto ruby rbenv rvm ruby
|
||||
# completions: rvm gem rake
|
||||
#
|
||||
# ❯ bash-it search ruby rbenv rvm gem rake -chruby
|
||||
# aliases: bundler
|
||||
# plugins: ruby rbenv rvm ruby
|
||||
# completions: rvm gem rake
|
||||
#
|
||||
# Examples of enabling or disabling results of the search:
|
||||
#
|
||||
# ❯ bash-it search ruby
|
||||
# aliases: bundler
|
||||
# plugins: chruby chruby-auto ruby
|
||||
#
|
||||
# ❯ bash-it search ruby -chruby --enable
|
||||
# aliases: bundler
|
||||
# plugins: ruby
|
||||
#
|
||||
# Examples of using exact match:
|
||||
|
||||
# ❯ bash-it search @git @ruby
|
||||
# aliases: git
|
||||
# plugins: git ruby
|
||||
# completions: git
|
||||
#
|
||||
|
||||
function _bash-it-search() {
|
||||
_about 'searches for given terms amongst bash-it plugins, aliases and completions'
|
||||
_param '1: term1'
|
||||
_param '2: [ term2 ]...'
|
||||
_example '$ _bash-it-search @git ruby -rvm rake bundler'
|
||||
|
||||
local component
|
||||
local BASH_IT_SEARCH_USE_COLOR="${BASH_IT_SEARCH_USE_COLOR:=true}"
|
||||
local -a BASH_IT_COMPONENTS=('aliases' 'plugins' 'completions')
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
_bash-it-search-help
|
||||
return 0
|
||||
fi
|
||||
|
||||
local -a args=()
|
||||
for word in "$@"; do
|
||||
case "${word}" in
|
||||
'-h' | '--help')
|
||||
_bash-it-search-help
|
||||
return 0
|
||||
;;
|
||||
'-r' | '--refresh')
|
||||
_bash-it-component-cache-clean
|
||||
;;
|
||||
'-c' | '--no-color')
|
||||
BASH_IT_SEARCH_USE_COLOR=false
|
||||
;;
|
||||
*)
|
||||
args+=("${word}")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ${#args} -gt 0 ]]; then
|
||||
for component in "${BASH_IT_COMPONENTS[@]}"; do
|
||||
_bash-it-search-component "${component}" "${args[@]}"
|
||||
done
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function _bash-it-search-help() {
|
||||
printf '%b' "${echo_normal-}
|
||||
${echo_underline_yellow-}USAGE${echo_normal-}
|
||||
|
||||
bash-it search [-|@]term1 [-|@]term2 ... \\
|
||||
[ --enable | -e ] \\
|
||||
[ --disable | -d ] \\
|
||||
[ --no-color | -c ] \\
|
||||
[ --refresh | -r ] \\
|
||||
[ --help | -h ]
|
||||
|
||||
${echo_underline_yellow-}DESCRIPTION${echo_normal-}
|
||||
|
||||
Use ${echo_bold_green-}search${echo_normal-} bash-it command to search for a list of terms or term negations
|
||||
across all components: aliases, completions and plugins. Components that are
|
||||
enabled are shown in green (or with a check box if --no-color option is used).
|
||||
|
||||
In addition to simply finding the right component, you can use the results
|
||||
of the search to enable or disable all components that the search returns.
|
||||
|
||||
When search is used to enable/disable components it becomes clear that
|
||||
you must be able to perform not just a partial match, but an exact match,
|
||||
as well as be able to exclude some components.
|
||||
|
||||
* To exclude a component (or all components matching a substring) use
|
||||
a search term with minus as a prefix, eg '-flow'
|
||||
|
||||
* To perform an exact match, use character '@' in front of the term,
|
||||
eg. '@git' would only match aliases, plugins and completions named 'git'.
|
||||
|
||||
${echo_underline_yellow-}FLAGS${echo_normal-}
|
||||
--enable | -e ${echo_purple-}Enable all matching componenents.${echo_normal-}
|
||||
--disable | -d ${echo_purple-}Disable all matching componenents.${echo_normal-}
|
||||
--help | -h ${echo_purple-}Print this help.${echo_normal-}
|
||||
--refresh | -r ${echo_purple-}Force a refresh of the search cache.${echo_normal-}
|
||||
--no-color | -c ${echo_purple-}Disable color output and use monochrome text.${echo_normal-}
|
||||
|
||||
${echo_underline_yellow-}EXAMPLES${echo_normal-}
|
||||
|
||||
For example, ${echo_bold_green-}bash-it search git${echo_normal-} would match any alias, completion
|
||||
or plugin that has the word 'git' in either the module name or
|
||||
it's description. You should see something like this when you run this
|
||||
command:
|
||||
|
||||
${echo_bold_green-}❯ bash-it search git${echo_bold_blue-}
|
||||
${echo_bold_yellow-}aliases: ${echo_bold_green-}git ${echo_normal-}gitsvn
|
||||
${echo_bold_yellow-}plugins: ${echo_normal-}autojump ${echo_bold_green-}git ${echo_normal-}git-subrepo jgitflow jump
|
||||
${echo_bold_yellow-}completions: ${echo_bold_green-}git ${echo_normal-}git_flow git_flow_avh${echo_normal-}
|
||||
|
||||
You can exclude some terms by prefixing a term with a minus, eg:
|
||||
|
||||
${echo_bold_green-}❯ bash-it search git -flow -svn${echo_bold_blue-}
|
||||
${echo_bold_yellow-}aliases: ${echo_normal-}git
|
||||
${echo_bold_yellow-}plugins: ${echo_normal-}autojump git git-subrepo jump
|
||||
${echo_bold_yellow-}completions: ${echo_normal-}git${echo_normal-}
|
||||
|
||||
Finally, if you prefix a term with '@' symbol, that indicates an exact
|
||||
match. Note, that we also pass the '--enable' flag, which would ensure
|
||||
that all matches are automatically enabled. The example is below:
|
||||
|
||||
${echo_bold_green-}❯ bash-it search @git --enable${echo_bold_blue-}
|
||||
${echo_bold_yellow-}aliases: ${echo_normal-}git
|
||||
${echo_bold_yellow-}plugins: ${echo_normal-}git
|
||||
${echo_bold_yellow-}completions: ${echo_normal-}git${echo_normal-}
|
||||
|
||||
${echo_underline_yellow-}SUMMARY${echo_normal-}
|
||||
|
||||
Take advantage of the search functionality to discover what Bash-It can do
|
||||
for you. Try searching for partial term matches, mix and match with the
|
||||
negative terms, or specify an exact matches of any number of terms. Once
|
||||
you created the search command that returns ONLY the modules you need,
|
||||
simply append '--enable' or '--disable' at the end to activate/deactivate
|
||||
each module.
|
||||
|
||||
"
|
||||
}
|
||||
|
||||
function _bash-it-is-partial-match() {
|
||||
local component="${1?${FUNCNAME[0]}: component type must be specified}"
|
||||
local term="${2:-}"
|
||||
_bash-it-component-help "${component}" | _bash-it-egrep -i -q -- "${term}"
|
||||
}
|
||||
|
||||
function _bash-it-component-term-matches-negation() {
|
||||
local match="$1"
|
||||
shift
|
||||
local negative
|
||||
for negative in "$@"; do
|
||||
[[ "${match}" =~ ${negative} ]] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
function _bash-it-search-component() {
|
||||
_about 'searches for given terms amongst a given component'
|
||||
_param '1: component type, one of: [ aliases | plugins | completions ]'
|
||||
_param '2: term1 term2 @term3'
|
||||
_param '3: [-]term4 [-]term5 ...'
|
||||
_example '$ _bash-it-search-component aliases @git rake bundler -chruby'
|
||||
|
||||
local component="${1?${FUNCNAME[0]}: component type must be specified}"
|
||||
shift
|
||||
|
||||
# if one of the search terms is --enable or --disable, we will apply
|
||||
# this action to the matches further ` down.
|
||||
local component_singular action action_func
|
||||
local -a search_commands=('enable' 'disable')
|
||||
for search_command in "${search_commands[@]}"; do
|
||||
if _bash-it-array-contains-element "--${search_command}" "$@"; then
|
||||
component_singular="${component/es/}" # aliases -> alias
|
||||
component_singular="${component_singular/ns/n}" # plugins -> plugin
|
||||
|
||||
action="${search_command}"
|
||||
action_func="_${action}-${component_singular}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
local -a terms=("$@") # passed on the command line
|
||||
|
||||
local -a exact_terms=() # terms that should be included only if they match exactly
|
||||
local -a partial_terms=() # terms that should be included if they match partially
|
||||
local -a negative_terms=() # negated partial terms that should be excluded
|
||||
|
||||
local term line
|
||||
|
||||
local -a component_list=()
|
||||
while IFS='' read -r line; do
|
||||
component_list+=("$line")
|
||||
done < <(_bash-it-component-list "${component}")
|
||||
|
||||
for term in "${terms[@]}"; do
|
||||
local search_term="${term:1}"
|
||||
if [[ "${term:0:2}" == "--" ]]; then
|
||||
continue
|
||||
elif [[ "${term:0:1}" == "-" ]]; then
|
||||
negative_terms+=("${search_term}")
|
||||
elif [[ "${term:0:1}" == "@" ]]; then
|
||||
if _bash-it-array-contains-element "${search_term}" "${component_list[@]:-}"; then
|
||||
exact_terms+=("${search_term}")
|
||||
fi
|
||||
else
|
||||
while IFS='' read -r line; do
|
||||
partial_terms+=("$line")
|
||||
done < <(_bash-it-component-list-matching "${component}" "${term}")
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
local -a total_matches=()
|
||||
while IFS='' read -r line; do
|
||||
total_matches+=("$line")
|
||||
done < <(_bash-it-array-dedup "${exact_terms[@]:-}" "${partial_terms[@]:-}")
|
||||
|
||||
local -a matches=()
|
||||
for match in "${total_matches[@]}"; do
|
||||
local -i include_match=1
|
||||
if [[ ${#negative_terms[@]} -gt 0 ]]; then
|
||||
_bash-it-component-term-matches-negation "${match}" "${negative_terms[@]:-}" && include_match=0
|
||||
fi
|
||||
((include_match)) && matches+=("${match}")
|
||||
done
|
||||
|
||||
_bash-it-search-result "${component}" "${action:-}" "${action_func:-}" "${matches[@]:-}"
|
||||
}
|
||||
|
||||
function _bash-it-search-result() {
|
||||
local component="${1?${FUNCNAME[0]}: component type must be specified}"
|
||||
shift
|
||||
local action="${1:-}"
|
||||
shift
|
||||
local action_func="${1:-}"
|
||||
shift
|
||||
|
||||
local color_component color_enable color_disable color_off
|
||||
local match_color compatible_action suffix opposite_suffix
|
||||
local color_sep=':' line match matched temp
|
||||
local -i modified=0 enabled=0 len
|
||||
local -a matches=()
|
||||
|
||||
# Discard any empty arguments
|
||||
while IFS='' read -r line; do
|
||||
[[ -n "${line}" ]] && matches+=("$line")
|
||||
done < <(_bash-it-array-dedup "${@}")
|
||||
|
||||
if [[ "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then
|
||||
color_component='\e[1;34m'
|
||||
color_enable='\e[1;32m'
|
||||
suffix_enable=''
|
||||
suffix_disable=''
|
||||
color_disable='\e[0;0m'
|
||||
color_off='\e[0;0m'
|
||||
else
|
||||
color_component=''
|
||||
suffix_enable=' ✓ ︎'
|
||||
suffix_disable=' '
|
||||
color_enable=''
|
||||
color_disable=''
|
||||
color_off=''
|
||||
fi
|
||||
|
||||
if [[ "${#matches[@]}" -gt 0 ]]; then
|
||||
printf "${color_component}%13s${color_sep}${color_off} " "${component}"
|
||||
|
||||
for match in "${matches[@]}"; do
|
||||
enabled=0
|
||||
_bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1
|
||||
|
||||
if ((enabled)); then
|
||||
match_color="${color_enable}"
|
||||
suffix="${suffix_enable}"
|
||||
opposite_suffix="${suffix_disable}"
|
||||
compatible_action="disable"
|
||||
else
|
||||
match_color="${color_disable}"
|
||||
suffix="${suffix_disable}"
|
||||
opposite_suffix="${suffix_enable}"
|
||||
compatible_action="enable"
|
||||
fi
|
||||
|
||||
matched="${match}${suffix}"
|
||||
len="${#matched}"
|
||||
|
||||
printf '%b' "${match_color}${matched}" # print current state
|
||||
if [[ "${action}" == "${compatible_action}" ]]; then
|
||||
if [[ "${action}" == "enable" && "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then
|
||||
_bash-it-flash-term "${len}" "${matched}"
|
||||
else
|
||||
_bash-it-erase-term "${len}" "${matched}"
|
||||
fi
|
||||
modified=1
|
||||
# shellcheck disable=SC2034 # no idea if `$result` is ever used
|
||||
result=$("${action_func}" "${match}")
|
||||
temp="color_${compatible_action}"
|
||||
match_color="${!temp}"
|
||||
_bash-it-rewind "${len}"
|
||||
printf '%b' "${match_color}${match}${opposite_suffix}"
|
||||
fi
|
||||
|
||||
printf '%b' "${color_off} "
|
||||
done
|
||||
|
||||
((modified)) && _bash-it-component-cache-clean "${component}"
|
||||
printf "\n"
|
||||
fi
|
||||
}
|
||||
|
||||
function _bash-it-rewind() {
|
||||
local -i len="${1:-0}"
|
||||
printf '%b' "\033[${len}D"
|
||||
}
|
||||
|
||||
function _bash-it-flash-term() {
|
||||
local -i len="${1:-0}" # redundant
|
||||
local term="${2:-}"
|
||||
# as currently implemented, `$match` has already been printed to screen the first time
|
||||
local delay=0.2
|
||||
local color
|
||||
[[ "${#term}" -gt 0 ]] && len="${#term}"
|
||||
|
||||
for color in "${echo_black-}" "${echo_bold_blue-}" "${echo_bold_yellow-}" "${echo_bold_red-}" "${echo_bold_green-}" "${echo_normal-}"; do
|
||||
sleep "${delay}"
|
||||
_bash-it-rewind "${len}"
|
||||
printf '%b' "${color}${term}"
|
||||
done
|
||||
}
|
||||
|
||||
function _bash-it-erase-term() {
|
||||
local -i len="${1:-0}" i
|
||||
local delay=0.05
|
||||
local term="${2:-}" # calculate length ourselves
|
||||
[[ "${#term}" -gt 0 ]] && len="${#term}"
|
||||
|
||||
_bash-it-rewind "${len}"
|
||||
# white-out the already-printed term by printing blanks
|
||||
for ((i = 0; i <= len; i++)); do
|
||||
printf "%.*s" "$i" " "
|
||||
sleep "${delay}"
|
||||
done
|
||||
}
|
||||
198
dot_bash_it/lib/utilities.bash
Normal file
198
dot_bash_it/lib/utilities.bash
Normal file
@@ -0,0 +1,198 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# A collection of reusable functions.
|
||||
|
||||
###########################################################################
|
||||
# Generic utilies
|
||||
###########################################################################
|
||||
|
||||
function _bash-it-get-component-name-from-path() {
|
||||
local filename
|
||||
# filename without path
|
||||
filename="${1##*/}"
|
||||
# filename without path or priority
|
||||
filename="${filename##*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}"}"
|
||||
# filename without path, priority or extension
|
||||
echo "${filename%.*.bash}"
|
||||
}
|
||||
|
||||
function _bash-it-get-component-type-from-path() {
|
||||
local filename
|
||||
# filename without path
|
||||
filename="${1##*/}"
|
||||
# filename without extension
|
||||
filename="${filename%.bash}"
|
||||
# extension without priority or name
|
||||
filename="${filename##*.}"
|
||||
echo "${filename}"
|
||||
}
|
||||
|
||||
# This function searches an array for an exact match against the term passed
|
||||
# as the first argument to the function. This function exits as soon as
|
||||
# a match is found.
|
||||
#
|
||||
# Returns:
|
||||
# 0 when a match is found, otherwise 1.
|
||||
#
|
||||
# Examples:
|
||||
# $ declare -a fruits=(apple orange pear mandarin)
|
||||
#
|
||||
# $ _bash-it-array-contains-element apple "@{fruits[@]}" && echo 'contains apple'
|
||||
# contains apple
|
||||
#
|
||||
# $ if _bash-it-array-contains-element pear "${fruits[@]}"; then
|
||||
# echo "contains pear!"
|
||||
# fi
|
||||
# contains pear!
|
||||
#
|
||||
#
|
||||
function _bash-it-array-contains-element() {
|
||||
local e element="${1?}"
|
||||
shift
|
||||
for e in "$@"; do
|
||||
[[ "$e" == "${element}" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Dedupe an array (without embedded newlines).
|
||||
function _bash-it-array-dedup() {
|
||||
printf '%s\n' "$@" | sort -u
|
||||
}
|
||||
|
||||
# Outputs a full path of the grep found on the filesystem
|
||||
function _bash-it-grep() {
|
||||
: "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}"
|
||||
printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}"
|
||||
}
|
||||
|
||||
# Runs `grep` with extended regular expressions
|
||||
function _bash-it-egrep() {
|
||||
: "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}"
|
||||
"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
# Component-specific functions (component is either an alias, a plugin, or a
|
||||
# completion).
|
||||
###########################################################################
|
||||
|
||||
function _bash-it-component-help() {
|
||||
local component file func
|
||||
_bash-it-component-pluralize "${1}" component
|
||||
_bash-it-component-cache-file "${component}" file
|
||||
if [[ ! -s "${file?}" || -z "$(find "${file}" -mmin -300)" ]]; then
|
||||
func="_bash-it-${component?}"
|
||||
"${func}" | _bash-it-egrep '\[[x ]\]' >| "${file}"
|
||||
fi
|
||||
cat "${file}"
|
||||
}
|
||||
|
||||
function _bash-it-component-cache-file() {
|
||||
local _component_to_cache _file_path _result="${2:-${FUNCNAME[0]//-/_}}"
|
||||
_bash-it-component-pluralize "${1?${FUNCNAME[0]}: component name required}" _component_to_cache
|
||||
_file_path="${XDG_CACHE_HOME:-${HOME?}/.cache}/bash/${_component_to_cache?}"
|
||||
[[ -f "${_file_path}" ]] || mkdir -p "${_file_path%/*}"
|
||||
printf -v "${_result?}" '%s' "${_file_path}"
|
||||
}
|
||||
|
||||
function _bash-it-component-singularize() {
|
||||
local _result="${2:-${FUNCNAME[0]//-/_}}"
|
||||
local _component_to_single="${1?${FUNCNAME[0]}: component name required}"
|
||||
local -i len="$((${#_component_to_single} - 2))"
|
||||
if [[ "${_component_to_single:${len}:2}" == 'ns' ]]; then
|
||||
_component_to_single="${_component_to_single%s}"
|
||||
elif [[ "${_component_to_single}" == "aliases" ]]; then
|
||||
_component_to_single="${_component_to_single%es}"
|
||||
fi
|
||||
printf -v "${_result?}" '%s' "${_component_to_single}"
|
||||
}
|
||||
|
||||
function _bash-it-component-pluralize() {
|
||||
local _result="${2:-${FUNCNAME[0]//-/_}}"
|
||||
local _component_to_plural="${1?${FUNCNAME[0]}: component name required}"
|
||||
local -i len="$((${#_component_to_plural} - 1))"
|
||||
# pluralize component name for consistency
|
||||
if [[ "${_component_to_plural:${len}:1}" != 's' ]]; then
|
||||
_component_to_plural="${_component_to_plural}s"
|
||||
elif [[ "${_component_to_plural}" == "alias" ]]; then
|
||||
_component_to_plural="${_component_to_plural}es"
|
||||
fi
|
||||
printf -v "${_result?}" '%s' "${_component_to_plural}"
|
||||
}
|
||||
|
||||
function _bash-it-component-cache-clean() {
|
||||
local component="${1:-}"
|
||||
local cache
|
||||
local -a components=('aliases' 'plugins' 'completions')
|
||||
if [[ -z "${component}" ]]; then
|
||||
for component in "${components[@]}"; do
|
||||
_bash-it-component-cache-clean "${component}"
|
||||
done
|
||||
else
|
||||
_bash-it-component-cache-file "${component}" cache
|
||||
: >| "${cache:?}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns an array of items within each compoenent.
|
||||
function _bash-it-component-list() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
function _bash-it-component-list-matching() {
|
||||
local component="$1"
|
||||
shift
|
||||
local term="$1"
|
||||
_bash-it-component-help "${component}" | _bash-it-egrep -- "${term}" | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
function _bash-it-component-list-enabled() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
function _bash-it-component-list-disabled() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
# Checks if a given item is enabled for a particular component/file-type.
|
||||
#
|
||||
# Returns:
|
||||
# 0 if an item of the component is enabled, 1 otherwise.
|
||||
#
|
||||
# Examples:
|
||||
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
|
||||
function _bash-it-component-item-is-enabled() {
|
||||
local component_type item_name each_file
|
||||
|
||||
if [[ -f "${1?}" ]]; then
|
||||
item_name="$(_bash-it-get-component-name-from-path "${1}")"
|
||||
component_type="$(_bash-it-get-component-type-from-path "${1}")"
|
||||
else
|
||||
component_type="${1}" item_name="${2?}"
|
||||
fi
|
||||
|
||||
for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \
|
||||
"${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \
|
||||
"${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do
|
||||
if [[ -f "${each_file}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Checks if a given item is disabled for a particular component/file-type.
|
||||
#
|
||||
# Returns:
|
||||
# 0 if an item of the component is enabled, 1 otherwise.
|
||||
#
|
||||
# Examples:
|
||||
# _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled"
|
||||
function _bash-it-component-item-is-disabled() {
|
||||
! _bash-it-component-item-is-enabled "$@"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
# stub for renamed file
|
||||
|
||||
_enable-completion aliases && _disable-plugin alias-completion
|
||||
source "${BASH_IT?}/completion/available/aliases.completion.bash"
|
||||
14
dot_bash_it/plugins/available/autojump.plugin.bash
Normal file
14
dot_bash_it/plugins/available/autojump.plugin.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details'
|
||||
|
||||
# Only supports the Homebrew variant, Debian and Arch at the moment.
|
||||
# Feel free to provide a PR to support other install locations
|
||||
# shellcheck disable=SC1090
|
||||
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then
|
||||
source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
|
||||
elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then
|
||||
source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
|
||||
elif _command_exists pacman && pacman -Q autojump &> /dev/null; then
|
||||
source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
|
||||
fi
|
||||
113
dot_bash_it/plugins/available/aws.plugin.bash
Normal file
113
dot_bash_it/plugins/available/aws.plugin.bash
Normal file
@@ -0,0 +1,113 @@
|
||||
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_SHARED_CREDENTIALS_FILE}" ]]; then
|
||||
echo "AWS credentials file not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then
|
||||
__awskeys_list "$2"
|
||||
elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then
|
||||
__awskeys_unset "$2"
|
||||
elif [[ $# -eq 2 ]] && [[ "$1" = "show" ]]; then
|
||||
__awskeys_show "$2"
|
||||
elif [[ $# -eq 2 ]] && [[ "$1" = "export" ]]; then
|
||||
__awskeys_export "$2"
|
||||
else
|
||||
__awskeys_help
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_help {
|
||||
echo -e "Usage: awskeys [COMMAND] [profile]\n"
|
||||
echo -e "Helper to AWS credentials file.\n"
|
||||
echo -e "Commands:\n"
|
||||
echo " help Show this help message"
|
||||
echo " list List available AWS credentials profiles"
|
||||
echo " show Show the AWS keys associated to a credentials profile"
|
||||
echo " export Export an AWS credentials profile keys as environment variables"
|
||||
echo " unset Unset the AWS keys variables from the environment"
|
||||
}
|
||||
|
||||
function __awskeys_get {
|
||||
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
|
||||
if [[ -n "${ln}" ]]; then
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 2 "aws_access_key_id|aws_secret_access_key"
|
||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 1 "aws_session_token"
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_list {
|
||||
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
|
||||
echo " $(echo ${profile} | tr -d "[]")"
|
||||
done
|
||||
echo
|
||||
else
|
||||
echo "No profiles found in credentials file"
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_show {
|
||||
local p_keys="$(__awskeys_get $1)"
|
||||
if [[ -n "${p_keys}" ]]; then
|
||||
echo "${p_keys}"
|
||||
else
|
||||
echo "Profile $1 not found in credentials file"
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_export {
|
||||
if [[ $(__awskeys_list) == *"$1"* ]]; then
|
||||
local p_keys=( $(__awskeys_get $1 | tr -d " ") )
|
||||
if [[ -n "${p_keys}" ]]; then
|
||||
for p_key in ${p_keys[@]}; do
|
||||
local key="${p_key%=*}"
|
||||
export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}"
|
||||
done
|
||||
fi
|
||||
export AWS_PROFILE="$1"
|
||||
else
|
||||
echo "Profile $1 not found in credentials file"
|
||||
fi
|
||||
}
|
||||
|
||||
function __awskeys_unset {
|
||||
unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
|
||||
}
|
||||
|
||||
function __awskeys_comp {
|
||||
local cur prev opts prevprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
opts="help list show export unset"
|
||||
|
||||
case "${prev}" in
|
||||
help|list|unset)
|
||||
return 0
|
||||
;;
|
||||
show|export)
|
||||
local profile_list="$(__awskeys_list | grep " ")"
|
||||
COMPREPLY=( $(compgen -W "${profile_list}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F __awskeys_comp awskeys
|
||||
185
dot_bash_it/plugins/available/base.plugin.bash
Normal file
185
dot_bash_it/plugins/available/base.plugin.bash
Normal file
@@ -0,0 +1,185 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'miscellaneous tools'
|
||||
|
||||
function ips() {
|
||||
about 'display all ip addresses for this host'
|
||||
group 'base'
|
||||
if _command_exists ifconfig; then
|
||||
ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }'
|
||||
elif _command_exists ip; then
|
||||
ip addr | grep -oP 'inet \K[\d.]+'
|
||||
else
|
||||
echo "You don't have ifconfig or ip command installed!"
|
||||
fi
|
||||
}
|
||||
|
||||
function down4me() {
|
||||
about 'checks whether a website is down for you, or everybody'
|
||||
param '1: website url'
|
||||
example '$ down4me http://www.google.com'
|
||||
group 'base'
|
||||
curl -Ls "http://downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
|
||||
}
|
||||
|
||||
function myip() {
|
||||
about 'displays your ip address, as seen by the Internet'
|
||||
group 'base'
|
||||
list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/")
|
||||
for url in "${list[@]}"; do
|
||||
if res="$(curl -fs "${url}")"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
res="$(echo "$res" | grep -Eo '[0-9\.]+')"
|
||||
echo -e "Your public IP is: ${echo_bold_green-} $res ${echo_normal-}"
|
||||
}
|
||||
|
||||
function pickfrom() {
|
||||
about 'picks random line from file'
|
||||
param '1: filename'
|
||||
example '$ pickfrom /usr/share/dict/words'
|
||||
group 'base'
|
||||
local file=${1:-}
|
||||
local -i n=0 length
|
||||
if [[ ! -r "$file" ]]; then
|
||||
reference "${FUNCNAME[0]}" && return
|
||||
fi
|
||||
length="$(wc -l < "$file")"
|
||||
n=$((RANDOM * length / 32768 + 1))
|
||||
head -n "$n" "$file" | tail -1
|
||||
}
|
||||
|
||||
function passgen() {
|
||||
about 'generates random password from dictionary words'
|
||||
param 'optional integer length'
|
||||
param 'if unset, defaults to 4'
|
||||
example '$ passgen'
|
||||
example '$ passgen 6'
|
||||
group 'base'
|
||||
local -i i length=${1:-4}
|
||||
local pass
|
||||
# shellcheck disable=SC2034
|
||||
pass="$(for i in $(eval "echo {1..$length}"); do pickfrom /usr/share/dict/words; done)"
|
||||
echo "With spaces (easier to memorize): ${pass//$'\n'/ }"
|
||||
echo "Without spaces (easier to brute force): ${pass//$'\n'/}"
|
||||
}
|
||||
|
||||
# Create alias pass to passgen when pass isn't installed or
|
||||
# BASH_IT_LEGACY_PASS is true.
|
||||
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]]; then
|
||||
alias pass=passgen
|
||||
fi
|
||||
|
||||
if _command_exists markdown && _command_exists browser; then
|
||||
function pmdown() {
|
||||
about 'preview markdown file in a browser'
|
||||
param '1: markdown file'
|
||||
example '$ pmdown README.md'
|
||||
group 'base'
|
||||
|
||||
markdown "${1?}" | browser
|
||||
}
|
||||
fi
|
||||
|
||||
function mkcd() {
|
||||
about 'make one or more directories and cd into the last one'
|
||||
param 'one or more directories to create'
|
||||
example '$ mkcd foo'
|
||||
example '$ mkcd /tmp/img/photos/large'
|
||||
example '$ mkcd foo foo1 foo2 fooN'
|
||||
example '$ mkcd /tmp/img/photos/large /tmp/img/photos/self /tmp/img/photos/Beijing'
|
||||
group 'base'
|
||||
mkdir -p -- "$@" && cd -- "${!#}" || return
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2010
|
||||
function lsgrep() {
|
||||
about 'search through directory contents with grep'
|
||||
group 'base'
|
||||
ls | grep "$@"
|
||||
}
|
||||
|
||||
function quiet() {
|
||||
about 'what *does* this do?'
|
||||
group 'base'
|
||||
nohup "$@" &> /dev/null < /dev/null &
|
||||
}
|
||||
|
||||
function usage() {
|
||||
about 'disk usage per directory, in Mac OS X and Linux'
|
||||
param '1: directory name'
|
||||
group 'base'
|
||||
case $OSTYPE in
|
||||
*'darwin'*)
|
||||
du -hd 1 "$@"
|
||||
;;
|
||||
*'linux'*)
|
||||
du -h --max-depth=1 "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function t() {
|
||||
about 'todo.sh if available, otherwise one thing todo'
|
||||
param 'if not set, display todo item'
|
||||
param '1: todo text'
|
||||
|
||||
local todotxt="${XDG_STATE_HOME:-~/.local/state}/bash_it/todo.txt"
|
||||
|
||||
if _bash-it-component-item-is-enabled plugin todo; then
|
||||
todo.sh "$@"
|
||||
return
|
||||
elif [[ ! -f "${todotxt}" && -f ~/.t ]]; then
|
||||
mv -vn ~/.t "${todotxt}" # Verbose, so the user knows. Don't overwrite, just in case.
|
||||
fi
|
||||
|
||||
if [[ "$#" -eq 0 ]]; then
|
||||
cat "${todotxt}"
|
||||
else
|
||||
echo "$@" >| "${todotxt}"
|
||||
fi
|
||||
}
|
||||
|
||||
if _command_exists mkisofs; then
|
||||
function mkiso() {
|
||||
about 'creates iso from current dir in the parent dir (unless defined)'
|
||||
param '1: ISO name'
|
||||
param '2: dest/path'
|
||||
param '3: src/path'
|
||||
example 'mkiso'
|
||||
example 'mkiso ISO-Name dest/path src/path'
|
||||
group 'base'
|
||||
|
||||
local isoname="${1:-${PWD##*/}}"
|
||||
local destpath="${2:-../}"
|
||||
local srcpath="${3:-${PWD}}"
|
||||
|
||||
if [[ ! -f "${destpath%/}/${isoname}.iso" ]]; then
|
||||
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
|
||||
mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath%/}/${isoname}.iso" "${srcpath}"
|
||||
else
|
||||
echo "${destpath%/}/${isoname}.iso already exists"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
# useful for administrators and configs
|
||||
function buf() {
|
||||
about 'back up file with timestamp'
|
||||
param 'filename'
|
||||
group 'base'
|
||||
local filename="${1?}" filetime
|
||||
filetime=$(date +%Y%m%d_%H%M%S)
|
||||
cp -a "${filename}" "${filename}_${filetime}"
|
||||
}
|
||||
|
||||
if ! _command_exists del; then
|
||||
function del() {
|
||||
about 'move files to hidden folder in tmp, that gets cleared on each reboot'
|
||||
param 'file or folder to be deleted'
|
||||
example 'del ./file.txt'
|
||||
group 'base'
|
||||
mkdir -p /tmp/.trash && mv "$@" /tmp/.trash
|
||||
}
|
||||
fi
|
||||
16
dot_bash_it/plugins/available/basher.plugin.bash
Normal file
16
dot_bash_it/plugins/available/basher.plugin.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'initializes basher, the shell package manager'
|
||||
|
||||
# https://github.com/basherpm/basher
|
||||
|
||||
if ! _command_exists basher; then
|
||||
if [[ -x "$HOME/.basher/bin/basher" ]]; then
|
||||
pathmunge "$HOME/.basher/bin"
|
||||
else
|
||||
_log_warning 'basher not found'
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
eval "$(basher init - bash)"
|
||||
130
dot_bash_it/plugins/available/battery.plugin.bash
Normal file
130
dot_bash_it/plugins/available/battery.plugin.bash
Normal file
@@ -0,0 +1,130 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'display info about your battery charge level'
|
||||
|
||||
function ac_adapter_connected() {
|
||||
local batteries
|
||||
if _command_exists upower; then
|
||||
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'charging\|fully-charged'
|
||||
elif _command_exists acpi; then
|
||||
acpi -a | grep -q "on-line"
|
||||
elif _command_exists pmset; then
|
||||
pmset -g batt | grep -q 'AC Power'
|
||||
elif _command_exists ioreg; then
|
||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||
elif _command_exists WMIC; then
|
||||
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2'
|
||||
fi
|
||||
}
|
||||
|
||||
function ac_adapter_disconnected() {
|
||||
local batteries
|
||||
if _command_exists upower; then
|
||||
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'discharging'
|
||||
elif _command_exists acpi; then
|
||||
acpi -a | grep -q "off-line"
|
||||
elif _command_exists pmset; then
|
||||
pmset -g batt | grep -q 'Battery Power'
|
||||
elif _command_exists ioreg; then
|
||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
||||
elif _command_exists WMIC; then
|
||||
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1'
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_percentage() {
|
||||
about 'displays battery charge as a percentage of full (100%)'
|
||||
group 'battery'
|
||||
|
||||
local command_output batteries
|
||||
|
||||
if _command_exists upower; then
|
||||
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
|
||||
command_output="$(upower --show-info "${batteries[0]:-}" | grep percentage | grep -o '[0-9]\+' | head -1)"
|
||||
elif _command_exists acpi; then
|
||||
command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}')
|
||||
elif _command_exists pmset; then
|
||||
command_output=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p' | grep -o '[0-9]\+' | head -1)
|
||||
elif _command_exists ioreg; then
|
||||
command_output=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}' | grep -o '[0-9]\+' | head -1)
|
||||
elif _command_exists WMIC; then
|
||||
command_output=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List | grep -o '[0-9]\+' | head -1)
|
||||
else
|
||||
command_output="no"
|
||||
fi
|
||||
|
||||
if [[ "${command_output}" != "no" ]]; then
|
||||
printf "%02d" "${command_output:--1}"
|
||||
else
|
||||
echo "${command_output}"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_charge() {
|
||||
about 'graphical display of your battery charge'
|
||||
group 'battery'
|
||||
|
||||
# Full char
|
||||
local f_c='▸'
|
||||
# Depleted char
|
||||
local d_c='▹'
|
||||
local depleted_color="${normal?}"
|
||||
local full_color="${green?}"
|
||||
local half_color="${yellow?}"
|
||||
local danger_color="${red?}"
|
||||
#local battery_output="${depleted_color}${d_c}${d_c}${d_c}${d_c}${d_c}"
|
||||
local battery_percentage
|
||||
battery_percentage=$(battery_percentage)
|
||||
|
||||
case $battery_percentage in
|
||||
no)
|
||||
echo ""
|
||||
;;
|
||||
9*)
|
||||
echo "${full_color}${f_c}${f_c}${f_c}${f_c}${f_c}${normal?}"
|
||||
;;
|
||||
8*)
|
||||
echo "${full_color}${f_c}${f_c}${f_c}${f_c}${half_color}${f_c}${normal?}"
|
||||
;;
|
||||
7*)
|
||||
echo "${full_color}${f_c}${f_c}${f_c}${f_c}${depleted_color}${d_c}${normal?}"
|
||||
;;
|
||||
6*)
|
||||
echo "${full_color}${f_c}${f_c}${f_c}${half_color}${f_c}${depleted_color}${d_c}${normal?}"
|
||||
;;
|
||||
5*)
|
||||
echo "${full_color}${f_c}${f_c}${f_c}${depleted_color}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
4*)
|
||||
echo "${full_color}${f_c}${f_c}${half_color}${f_c}${depleted_color}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
3*)
|
||||
echo "${full_color}${f_c}${f_c}${depleted_color}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
2*)
|
||||
echo "${full_color}${f_c}${half_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
1*)
|
||||
echo "${full_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
05)
|
||||
echo "${danger_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
04)
|
||||
echo "${danger_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
03)
|
||||
echo "${danger_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
02)
|
||||
echo "${danger_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
0*)
|
||||
echo "${half_color}${f_c}${depleted_color}${d_c}${d_c}${d_c}${d_c}${normal?}"
|
||||
;;
|
||||
*)
|
||||
echo "${danger_color}UNPLG${normal?}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
19
dot_bash_it/plugins/available/blesh.plugin.bash
Normal file
19
dot_bash_it/plugins/available/blesh.plugin.bash
Normal file
@@ -0,0 +1,19 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load ble.sh, the Bash line editor!'
|
||||
|
||||
if [[ ${BLE_VERSION-} ]]; then
|
||||
_log_warning "ble.sh is already loaded!"
|
||||
return
|
||||
fi
|
||||
|
||||
_bash_it_ble_path=${XDG_DATA_HOME:-$HOME/.local/share}/blesh/ble.sh
|
||||
if [[ -f $_bash_it_ble_path ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$_bash_it_ble_path" --attach=prompt
|
||||
else
|
||||
_log_error "Could not find ble.sh in $_bash_it_ble_path"
|
||||
_log_error "Please install using the following command:"
|
||||
_log_error "git clone https://github.com/akinomyoga/ble.sh && make -C ble.sh install"
|
||||
fi
|
||||
unset _bash_it_ble_path
|
||||
10
dot_bash_it/plugins/available/boot2docker.plugin.bash
Normal file
10
dot_bash_it/plugins/available/boot2docker.plugin.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
cite about-plugin
|
||||
about-plugin 'Helpers to get Docker setup correctly for boot2docker'
|
||||
|
||||
# Note, this might need to be different if you have an older version
|
||||
# of boot2docker, or its configured for a different IP
|
||||
if [[ "$OSTYPE" == 'darwin'* ]]; then
|
||||
export DOCKER_HOST="tcp://192.168.59.103:2376"
|
||||
export DOCKER_CERT_PATH="~/.boot2docker/certs/boot2docker-vm"
|
||||
export DOCKER_TLS_VERIFY=1
|
||||
fi
|
||||
76
dot_bash_it/plugins/available/browser.plugin.bash
Normal file
76
dot_bash_it/plugins/available/browser.plugin.bash
Normal file
@@ -0,0 +1,76 @@
|
||||
# based on https://gist.github.com/318247
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'render commandline output in your browser'
|
||||
|
||||
function browser() {
|
||||
about 'pipe html to a browser'
|
||||
example '$ echo "<h1>hi mom!</h1>" | browser'
|
||||
example '$ ron -5 man/rip.5.ron | browser'
|
||||
group 'browser'
|
||||
|
||||
if [ -t 0 ]; then
|
||||
if [ -n "$1" ]; then
|
||||
open $1
|
||||
else
|
||||
reference browser
|
||||
fi
|
||||
|
||||
else
|
||||
f="/tmp/browser.$RANDOM.html"
|
||||
cat /dev/stdin > $f
|
||||
open $f
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function wmate() {
|
||||
about 'pipe hot spicy interwebs into textmate and cleanup!'
|
||||
example '$ wmate google.com'
|
||||
group 'browser'
|
||||
|
||||
if [ -t 0 ]; then
|
||||
if [ -n "$1" ]; then
|
||||
wget -qO- $1 | /usr/bin/mate
|
||||
|
||||
TIDY=`/usr/bin/osascript << EOT
|
||||
tell application "TextMate"
|
||||
activate
|
||||
end tell
|
||||
|
||||
tell application "System Events"
|
||||
tell process "TextMate"
|
||||
tell menu bar 1
|
||||
tell menu bar item "Bundles"
|
||||
tell menu "Bundles"
|
||||
tell menu item "HTML"
|
||||
tell menu "HTML"
|
||||
click menu item "Tidy"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOT`
|
||||
|
||||
else
|
||||
reference wmate
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function raw() {
|
||||
about 'write wget into a temp file and pump it into your browser'
|
||||
example '$ raw google.com'
|
||||
group 'browser'
|
||||
|
||||
if [ -t 0 ]; then
|
||||
if [ -n "$1" ]; then
|
||||
wget -qO- $1 | browser
|
||||
else
|
||||
reference raw
|
||||
fi
|
||||
fi
|
||||
}
|
||||
5
dot_bash_it/plugins/available/chruby-auto.plugin.bash
Normal file
5
dot_bash_it/plugins/available/chruby-auto.plugin.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load chruby + auto-switching (from /usr/local/share/chruby)'
|
||||
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
source /usr/local/share/chruby/auto.sh
|
||||
4
dot_bash_it/plugins/available/chruby.plugin.bash
Normal file
4
dot_bash_it/plugins/available/chruby.plugin.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load chruby (from /usr/local/share/chruby)'
|
||||
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
21
dot_bash_it/plugins/available/cht-sh.plugin.bash
Normal file
21
dot_bash_it/plugins/available/cht-sh.plugin.bash
Normal file
@@ -0,0 +1,21 @@
|
||||
cite about-plugin
|
||||
about-plugin 'Simplify `curl cht.sh/<query>` to `cht.sh <query>`'
|
||||
|
||||
# Play nicely if user already installed cht.sh cli tool
|
||||
if ! _command_exists cht.sh ; then
|
||||
function cht.sh () {
|
||||
about 'Executes a cht.sh curl query using the provided arguments'
|
||||
param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]'
|
||||
example '$ cht.sh :help'
|
||||
example '$ cht.sh :list'
|
||||
example '$ cht.sh tar'
|
||||
example '$ cht.sh js "parse json"'
|
||||
example '$ cht.sh python :learn'
|
||||
example '$ cht.sh rust :list'
|
||||
group 'cht-sh'
|
||||
|
||||
# Separate arguments with '/', preserving spaces within them
|
||||
local query=$(IFS=/ ; echo "$*")
|
||||
curl "cht.sh/${query}"
|
||||
}
|
||||
fi
|
||||
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
|
||||
|
||||
function precmd_return_notification() {
|
||||
local command_start="${COMMAND_DURATION_START_SECONDS:=0}"
|
||||
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
||||
local -i command_duration="$((${current_time%.*} - ${command_start%.*}))"
|
||||
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then
|
||||
printf '\a'
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
safe_append_prompt_command 'precmd_return_notification'
|
||||
safe_append_preexec '_command_duration_pre_exec'
|
||||
197
dot_bash_it/plugins/available/colors.plugin.bash
Normal file
197
dot_bash_it/plugins/available/colors.plugin.bash
Normal file
@@ -0,0 +1,197 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2005
|
||||
|
||||
function __() {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
function __make_ansi() {
|
||||
next=$1
|
||||
shift
|
||||
echo "\[\e[$("__$next" "$@")m\]"
|
||||
}
|
||||
|
||||
function __make_echo() {
|
||||
next=$1
|
||||
shift
|
||||
echo "\033[$("__$next" "$@")m"
|
||||
}
|
||||
|
||||
function __reset() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "0${out:+;${out}}"
|
||||
}
|
||||
|
||||
function __bold() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}1"
|
||||
}
|
||||
|
||||
function __faint() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}2"
|
||||
}
|
||||
|
||||
function __italic() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}3"
|
||||
}
|
||||
|
||||
function __underline() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}4"
|
||||
}
|
||||
|
||||
function __negative() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}7"
|
||||
}
|
||||
|
||||
function __crossed() {
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "${out:+${out};}8"
|
||||
}
|
||||
|
||||
function __color_normal_fg() {
|
||||
echo "3$1"
|
||||
}
|
||||
|
||||
function __color_normal_bg() {
|
||||
echo "4$1"
|
||||
}
|
||||
|
||||
function __color_bright_fg() {
|
||||
echo "9$1"
|
||||
}
|
||||
|
||||
function __color_bright_bg() {
|
||||
echo "10$1"
|
||||
}
|
||||
|
||||
function __color_black() {
|
||||
echo "0"
|
||||
}
|
||||
|
||||
function __color_red() {
|
||||
echo "1"
|
||||
}
|
||||
|
||||
function __color_green() {
|
||||
echo "2"
|
||||
}
|
||||
|
||||
function __color_yellow() {
|
||||
echo "3"
|
||||
}
|
||||
|
||||
function __color_blue() {
|
||||
echo "4"
|
||||
}
|
||||
|
||||
function __color_magenta() {
|
||||
echo "5"
|
||||
}
|
||||
|
||||
function __color_cyan() {
|
||||
echo "6"
|
||||
}
|
||||
|
||||
function __color_white() {
|
||||
echo "7"
|
||||
}
|
||||
|
||||
function __color_rgb() {
|
||||
r=$1 && g=$2 && b=$3
|
||||
[[ $r == "$g" && $g == "$b" ]] && echo $((r / 11 + 232)) && return # gray range above 232
|
||||
echo "8;5;$(((r * 36 + b * 6 + g) / 51 + 16))"
|
||||
}
|
||||
|
||||
function __color() {
|
||||
color="$1"
|
||||
shift
|
||||
case "$1" in
|
||||
fg | bg)
|
||||
side="$1"
|
||||
shift
|
||||
;;
|
||||
*) side="fg" ;;
|
||||
esac
|
||||
case "$1" in
|
||||
normal | bright)
|
||||
mode="$1"
|
||||
shift
|
||||
;;
|
||||
*) mode=normal ;;
|
||||
esac
|
||||
[[ $color == "rgb" ]] && rgb="$1 $2 $3"
|
||||
shift 3
|
||||
|
||||
next=$1
|
||||
shift
|
||||
out="$("__$next" "$@")"
|
||||
echo "$("__color_${mode}_${side}" "$("__color_${color}" "$rgb")")${out:+;${out}}"
|
||||
}
|
||||
|
||||
function __black() {
|
||||
echo "$(__color black "$@")"
|
||||
}
|
||||
|
||||
function __red() {
|
||||
echo "$(__color red "$@")"
|
||||
}
|
||||
|
||||
function __green() {
|
||||
echo "$(__color green "$@")"
|
||||
}
|
||||
|
||||
function __yellow() {
|
||||
echo "$(__color yellow "$@")"
|
||||
}
|
||||
|
||||
function __blue() {
|
||||
echo "$(__color blue "$@")"
|
||||
}
|
||||
|
||||
function __magenta() {
|
||||
echo "$(__color magenta "$@")"
|
||||
}
|
||||
|
||||
function __cyan() {
|
||||
echo "$(__color cyan "$@")"
|
||||
}
|
||||
|
||||
function __white() {
|
||||
echo "$(__color white "$@")"
|
||||
}
|
||||
|
||||
function __rgb() {
|
||||
echo "$(__color rgb "$@")"
|
||||
}
|
||||
|
||||
function __color_parse() {
|
||||
next=$1
|
||||
shift
|
||||
echo "$("__$next" "$@")"
|
||||
}
|
||||
|
||||
function color() {
|
||||
echo "$(__color_parse make_ansi "$@")"
|
||||
}
|
||||
|
||||
function echo_color() {
|
||||
echo "$(__color_parse make_echo "$@")"
|
||||
}
|
||||
7
dot_bash_it/plugins/available/direnv.plugin.bash
Normal file
7
dot_bash_it/plugins/available/direnv.plugin.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load direnv, if you are using it: https://direnv.net/'
|
||||
|
||||
if _command_exists direnv; then
|
||||
eval "$(direnv hook bash)"
|
||||
fi
|
||||
119
dot_bash_it/plugins/available/dirs.plugin.bash
Normal file
119
dot_bash_it/plugins/available/dirs.plugin.bash
Normal file
@@ -0,0 +1,119 @@
|
||||
# shellcheck shell=bash
|
||||
# Directory stack navigation:
|
||||
#
|
||||
# Add to stack with: pu /path/to/directory
|
||||
# Delete current dir from stack with: po
|
||||
# Show stack with: d
|
||||
# Jump to location by number.
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'directory stack navigation'
|
||||
|
||||
# Show directory stack
|
||||
alias d="dirs -v -l"
|
||||
|
||||
# Change to location in stack by number
|
||||
alias 1="pushd"
|
||||
alias 2="pushd +2"
|
||||
alias 3="pushd +3"
|
||||
alias 4="pushd +4"
|
||||
alias 5="pushd +5"
|
||||
alias 6="pushd +6"
|
||||
alias 7="pushd +7"
|
||||
alias 8="pushd +8"
|
||||
alias 9="pushd +9"
|
||||
|
||||
# Clone this location
|
||||
alias pc='pushd "${PWD}"'
|
||||
|
||||
# Push new location
|
||||
alias pu="pushd"
|
||||
|
||||
# Pop current location
|
||||
alias po="popd"
|
||||
|
||||
function dirs-help() {
|
||||
about 'directory navigation alias usage'
|
||||
group 'dirs'
|
||||
|
||||
echo "Directory Navigation Alias Usage"
|
||||
echo
|
||||
echo "Use the power of directory stacking to move"
|
||||
echo "between several locations with ease."
|
||||
echo
|
||||
echo "d : Show directory stack."
|
||||
echo "po : Remove current location from stack."
|
||||
echo "pc : Adds current location to stack."
|
||||
echo "pu <dir>: Adds given location to stack."
|
||||
echo "1 : Change to stack location 1."
|
||||
echo "2 : Change to stack location 2."
|
||||
echo "3 : Change to stack location 3."
|
||||
echo "4 : Change to stack location 4."
|
||||
echo "5 : Change to stack location 5."
|
||||
echo "6 : Change to stack location 6."
|
||||
echo "7 : Change to stack location 7."
|
||||
echo "8 : Change to stack location 8."
|
||||
echo "9 : Change to stack location 9."
|
||||
}
|
||||
|
||||
# Add bookmarking functionality
|
||||
# Usage:
|
||||
|
||||
: "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-${HOME}/.local/state}/bash_it/dirs}"
|
||||
if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT_DIRS_BKS?}"
|
||||
elif [[ -f ~/.dirs ]]; then
|
||||
mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT_DIRS_BKS?}"
|
||||
else
|
||||
touch "${BASH_IT_DIRS_BKS?}"
|
||||
fi
|
||||
|
||||
alias L='cat "${BASH_IT_DIRS_BKS?}"'
|
||||
|
||||
# Goes to destination dir, otherwise stay in the dir
|
||||
function G() {
|
||||
about 'goes to destination dir'
|
||||
param '1: directory'
|
||||
example '$ G ..'
|
||||
group 'dirs'
|
||||
|
||||
cd "${1:-${PWD}}" || return
|
||||
}
|
||||
|
||||
function S() {
|
||||
about 'save a bookmark'
|
||||
param '1: bookmark name'
|
||||
example '$ S mybkmrk'
|
||||
group 'dirs'
|
||||
|
||||
[[ $# -eq 1 ]] || {
|
||||
echo "${FUNCNAME[0]} function requires 1 argument"
|
||||
return 1
|
||||
}
|
||||
|
||||
sed "/$1/d" "${BASH_IT_DIRS_BKS?}" > "${BASH_IT_DIRS_BKS?}.new"
|
||||
command mv "${BASH_IT_DIRS_BKS?}.new" "${BASH_IT_DIRS_BKS?}"
|
||||
echo "$1"=\""${PWD}"\" >> "${BASH_IT_DIRS_BKS?}"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT_DIRS_BKS?}"
|
||||
}
|
||||
|
||||
function R() {
|
||||
about 'remove a bookmark'
|
||||
param '1: bookmark name'
|
||||
example '$ R mybkmrk'
|
||||
group 'dirs'
|
||||
|
||||
[[ $# -eq 1 ]] || {
|
||||
echo "${FUNCNAME[0]} function requires 1 argument"
|
||||
return 1
|
||||
}
|
||||
|
||||
sed "/$1/d" "${BASH_IT_DIRS_BKS?}" > "${BASH_IT_DIRS_BKS?}.new"
|
||||
command mv "${BASH_IT_DIRS_BKS?}.new" "${BASH_IT_DIRS_BKS?}"
|
||||
}
|
||||
|
||||
alias U='source "${BASH_IT_DIRS_BKS?}"' # Update bookmark stack
|
||||
20
dot_bash_it/plugins/available/docker-compose.plugin.bash
Normal file
20
dot_bash_it/plugins/available/docker-compose.plugin.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
cite about-plugin
|
||||
about-plugin 'Helper functions for using docker-compose'
|
||||
|
||||
function docker-compose-fresh() {
|
||||
about 'Shut down, remove and start again the docker-compose setup, then tail the logs'
|
||||
group 'docker-compose'
|
||||
param '1: name of the docker-compose.yaml file to use (optional). Default: docker-compose.yaml'
|
||||
example 'docker-compose-fresh docker-compose-foo.yaml'
|
||||
|
||||
local DCO_FILE_PARAM=""
|
||||
if [ -n "$1" ]; then
|
||||
echo "Using docker-compose file: $1"
|
||||
DCO_FILE_PARAM="--file $1"
|
||||
fi
|
||||
|
||||
docker-compose $DCO_FILE_PARAM stop
|
||||
docker-compose $DCO_FILE_PARAM rm -f
|
||||
docker-compose $DCO_FILE_PARAM up -d
|
||||
docker-compose $DCO_FILE_PARAM logs -f --tail 100
|
||||
}
|
||||
5
dot_bash_it/plugins/available/docker-machine.plugin.bash
Normal file
5
dot_bash_it/plugins/available/docker-machine.plugin.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Helpers to get Docker setup correctly for docker-machine'
|
||||
_log_warning '"docker-machine" is now deprecated, and as such the plugin for it is also deprecated.
|
||||
Please disable this plugin.'
|
||||
81
dot_bash_it/plugins/available/docker.plugin.bash
Normal file
81
dot_bash_it/plugins/available/docker.plugin.bash
Normal file
@@ -0,0 +1,81 @@
|
||||
cite about-plugin
|
||||
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 -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 -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() {
|
||||
about 'enter the specified docker container using bash'
|
||||
group 'docker'
|
||||
param '1: Name of the container to enter'
|
||||
example 'docker-enter oracle-xe'
|
||||
|
||||
docker exec -it "$@" /bin/bash;
|
||||
}
|
||||
|
||||
function docker-remove-images() {
|
||||
about 'attempt to remove images with supplied tags or all if no tags are supplied'
|
||||
group 'docker'
|
||||
if [ -z "$1" ]; then
|
||||
docker rmi $(docker images -q)
|
||||
else
|
||||
DOCKER_IMAGES=""
|
||||
for IMAGE_ID in $@; do DOCKER_IMAGES="$DOCKER_IMAGES\|$IMAGE_ID"; done
|
||||
# Find the image IDs for the supplied tags
|
||||
ID_ARRAY=($(docker images | grep "${DOCKER_IMAGES:2}" | awk {'print $3'}))
|
||||
# Strip out duplicate IDs before attempting to remove the image(s)
|
||||
docker rmi $(echo ${ID_ARRAY[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
|
||||
fi
|
||||
}
|
||||
|
||||
function docker-image-dependencies() {
|
||||
about 'attempt to create a Graphiz image of the supplied image ID dependencies'
|
||||
group 'docker'
|
||||
if hash dot 2>/dev/null; then
|
||||
OUT=$(mktemp -t docker-viz-XXXX.png)
|
||||
docker images -viz | dot -Tpng > $OUT
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
xdg-open $OUT
|
||||
;;
|
||||
darwin*)
|
||||
open $OUT
|
||||
;;
|
||||
esac
|
||||
else
|
||||
>&2 echo "Can't show dependencies; Graphiz is not installed"
|
||||
fi
|
||||
}
|
||||
|
||||
function docker-runtime-environment() {
|
||||
about 'attempt to list the environmental variables of the supplied image ID'
|
||||
group 'docker'
|
||||
docker run "$@" env
|
||||
}
|
||||
|
||||
function docker-archive-content() {
|
||||
about 'show the content of the provided Docker image archive'
|
||||
group 'docker'
|
||||
param '1: image archive name'
|
||||
example 'docker-archive-content images.tar.gz'
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
tar -xzOf $1 manifest.json | jq '[.[] | .RepoTags] | add'
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
cite about-plugin
|
||||
about-plugin 'Enable emacs editing mode'
|
||||
|
||||
set -o emacs
|
||||
4
dot_bash_it/plugins/available/edit-mode-vi.plugin.bash
Normal file
4
dot_bash_it/plugins/available/edit-mode-vi.plugin.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
cite about-plugin
|
||||
about-plugin 'Enable vi editing mode'
|
||||
|
||||
set -o vi
|
||||
23
dot_bash_it/plugins/available/explain.plugin.bash
Normal file
23
dot_bash_it/plugins/available/explain.plugin.bash
Normal file
@@ -0,0 +1,23 @@
|
||||
cite about-plugin
|
||||
about-plugin 'mankier.com explain function to explain other commands'
|
||||
|
||||
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.'
|
||||
group 'explain'
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
while read -p "Command: " cmd; do
|
||||
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
|
||||
done
|
||||
echo "Bye!"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
|
||||
else
|
||||
echo "Usage"
|
||||
echo "explain interactive mode."
|
||||
echo "explain 'cmd -o | ...' one quoted command to explain it."
|
||||
fi
|
||||
}
|
||||
73
dot_bash_it/plugins/available/extract.plugin.bash
Normal file
73
dot_bash_it/plugins/available/extract.plugin.bash
Normal file
@@ -0,0 +1,73 @@
|
||||
cite about-plugin
|
||||
about-plugin 'one command to extract them all...'
|
||||
|
||||
# extract file(s) from compressed status
|
||||
extract() {
|
||||
local opt
|
||||
local OPTIND=1
|
||||
while getopts "hv" opt; do
|
||||
case "$opt" in
|
||||
h)
|
||||
cat <<End-Of-Usage
|
||||
Usage: ${FUNCNAME[0]} [option] <archives>
|
||||
options:
|
||||
-h show this message and exit
|
||||
-v verbosely list files processed
|
||||
End-Of-Usage
|
||||
return
|
||||
;;
|
||||
v)
|
||||
local -r verbose='v'
|
||||
;;
|
||||
?)
|
||||
extract -h >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
[ $# -eq 0 ] && extract -h && return 1
|
||||
while [ $# -gt 0 ]; do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
local -r filename=$(basename -- $1)
|
||||
local -r filedirname=$(dirname -- $1)
|
||||
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
|
||||
if [ "$filename" = "$targetdirname" ]; then
|
||||
# archive type either not supported or it doesn't need dir creation
|
||||
targetdirname=""
|
||||
else
|
||||
mkdir -v "$filedirname/$targetdirname"
|
||||
fi
|
||||
|
||||
if [ -f "$1" ]; then
|
||||
case "$1" in
|
||||
*.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||
*.tar.gz|*.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||
*.tar.xz|*.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||
*.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||
*.bz2) bunzip2 "$1" ;;
|
||||
*.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;;
|
||||
*.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;;
|
||||
*.gz) gunzip "$1" ;;
|
||||
*.pax) pax -r -f "$1" ;;
|
||||
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
|
||||
*.rar) unrar x "$1" ;;
|
||||
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
|
||||
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
|
||||
*.xz) xz --decompress "$1" ;;
|
||||
*.zip|*.war|*.jar|*.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
|
||||
*.Z) uncompress "$1" ;;
|
||||
*.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;;
|
||||
*) echo "'$1' cannot be extracted via extract" >&2;;
|
||||
esac
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
}
|
||||
6
dot_bash_it/plugins/available/fasd.plugin.bash
Normal file
6
dot_bash_it/plugins/available/fasd.plugin.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load fasd, if you are using it'
|
||||
|
||||
_command_exists fasd || return
|
||||
|
||||
eval "$(fasd --init auto)"
|
||||
42
dot_bash_it/plugins/available/fzf.plugin.bash
Normal file
42
dot_bash_it/plugins/available/fzf.plugin.bash
Normal file
@@ -0,0 +1,42 @@
|
||||
# Load after the system completion to make sure that the fzf completions are working
|
||||
# BASH_IT_LOAD_PRIORITY: 375
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'load fzf, if you are using it'
|
||||
|
||||
if [ -r ~/.fzf.bash ] ; then
|
||||
source ~/.fzf.bash
|
||||
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] ; then
|
||||
source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
|
||||
fi
|
||||
|
||||
# No need to continue if the command is not present
|
||||
_command_exists fzf || return
|
||||
|
||||
if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd ; then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f'
|
||||
fi
|
||||
|
||||
fe() {
|
||||
about "Open the selected file in the default editor"
|
||||
group "fzf"
|
||||
param "1: Search term"
|
||||
example "fe foo"
|
||||
|
||||
local IFS=$'\n'
|
||||
local files
|
||||
files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
|
||||
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
|
||||
}
|
||||
|
||||
fcd() {
|
||||
about "cd to the selected directory"
|
||||
group "fzf"
|
||||
param "1: Directory to browse, or . if omitted"
|
||||
example "fcd aliases"
|
||||
|
||||
local dir
|
||||
dir=$(find ${1:-.} -path '*/\.*' -prune \
|
||||
-o -type d -print 2> /dev/null | fzf +m) &&
|
||||
cd "$dir"
|
||||
}
|
||||
321
dot_bash_it/plugins/available/gif.plugin.bash
Normal file
321
dot_bash_it/plugins/available/gif.plugin.bash
Normal file
@@ -0,0 +1,321 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'video to gif, gif to WebM helper functions'
|
||||
|
||||
# Based loosely on:
|
||||
# https://gist.github.com/SlexAxton/4989674#comment-1199058
|
||||
# https://linustechtips.com/main/topic/343253-tutorial-convert-videogifs-to-webm/
|
||||
# and other sources
|
||||
# Renamed gifify to v2gif to go avoid clobbering https://github.com/jclem/gifify
|
||||
# Requirements (Mac OS X using Homebrew): brew install ffmpeg giflossy imagemagick
|
||||
# Requirements on Ubuntu: sudo apt install ffmpeg imagemagick ; plus install https://github.com/pornel/giflossy
|
||||
# Optional: install mediainfo for autodetection of original video FPS.
|
||||
# Optional: if lossy is not important, Ubuntu has gifsicle packaged for apt-get, instead of giflossy
|
||||
# Optional: gifski (from `brew install gifski` or github.com/ImageOptim/gifski)
|
||||
# for high quality huge files.
|
||||
function v2gif() {
|
||||
about 'Converts a .mov/.avi/.mp4 file into an into an animated GIF.'
|
||||
group 'gif'
|
||||
param '1: MOV/AVI/MP4 file name(s)'
|
||||
param '2: -w <num> ; Optional: max width in pixels'
|
||||
param '3: -l <num> ; Optional: extra lossy level for smaller files (80-200 make sense, needs giflossy instead of gifsicle)'
|
||||
param '4: -h ; Optional: high quality using gifski (installed seperately) - overrides "--lossy" above!'
|
||||
param '5: -d ; Optional: delete the original video file if succeeded'
|
||||
param '6: -t ; Optional: Tag the result with quality stamp for comparison use'
|
||||
param '7: -f <num> ; Optional: Change number of frames per second (default 10 or original FPS if mediainfo installed)'
|
||||
param '8: -a <num> ; Optional: Alert if resulting file is over <num> kilobytes (default is 5000, 0 turns off)'
|
||||
param '9: -m ; Optional: Also create a WebM file (will one day replace GIF, Smaller and higher quality than mp4)'
|
||||
example '$ v2gif foo.mov'
|
||||
example '$ v2gif foo.mov -w 600'
|
||||
example '$ v2gif -l 100 -d *.mp4'
|
||||
example '$ v2gif -dh *.avi'
|
||||
example '$ v2gif -thw 600 *.avi *.mov'
|
||||
|
||||
local convert ffmpeg mediainfo gifsicle getopt args gifski out_size
|
||||
|
||||
convert="$(type -p convert)"
|
||||
[[ -x "$convert" ]] || {
|
||||
echo "No convert found!"
|
||||
return 2
|
||||
}
|
||||
ffmpeg="$(type -p ffmpeg)"
|
||||
[[ -x "$ffmpeg" ]] || {
|
||||
echo "No ffmpeg found!"
|
||||
return 2
|
||||
}
|
||||
mediainfo="$(type -p mediainfo)"
|
||||
[[ -x "$mediainfo" ]] || {
|
||||
echo "No mediainfo found!"
|
||||
return 2
|
||||
}
|
||||
gifsicle="$(type -p gifsicle)"
|
||||
[[ -x "$gifsicle" ]] || {
|
||||
echo "No gifsicle found!"
|
||||
return 2
|
||||
}
|
||||
getopt="$(type -p getopt)"
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# Getopt on BSD is incompatible with GNU
|
||||
getopt=/usr/local/opt/gnu-getopt/bin/getopt
|
||||
[[ -x "$getopt" ]] || {
|
||||
echo "No GNU-getopt found!"
|
||||
return 2
|
||||
}
|
||||
fi
|
||||
|
||||
# Parse the options
|
||||
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" -- "$@") || {
|
||||
echo 'Terminating...' >&2
|
||||
return 2
|
||||
}
|
||||
|
||||
eval set -- "$args"
|
||||
local use_gifski=""
|
||||
local opt_del_after=""
|
||||
local maxsize=""
|
||||
local lossiness=""
|
||||
local maxwidthski=""
|
||||
local giftagopt=""
|
||||
local giftag=""
|
||||
local defaultfps=10
|
||||
local infps=""
|
||||
local fps=""
|
||||
local make_webm=""
|
||||
local alert=5000
|
||||
while [[ $# -ge 1 ]]; do
|
||||
case "$1" in
|
||||
--)
|
||||
# No more options left.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-d | --del | --delete)
|
||||
# Delete after
|
||||
opt_del_after="true"
|
||||
shift
|
||||
;;
|
||||
-h | --high)
|
||||
#High Quality, use gifski
|
||||
gifski="$(type -p gifski)"
|
||||
[[ -x "$gifski" ]] || {
|
||||
echo "No gifski found!"
|
||||
return 2
|
||||
}
|
||||
use_gifski=true
|
||||
giftag="${giftag}-h"
|
||||
shift
|
||||
;;
|
||||
-w | --width)
|
||||
maxsize="-vf scale=$2:-1"
|
||||
maxwidthski="-W $2"
|
||||
giftag="${giftag}-w$2"
|
||||
shift 2
|
||||
;;
|
||||
-t | --tag)
|
||||
# mark with a quality tag
|
||||
giftagopt="true"
|
||||
shift
|
||||
;;
|
||||
-l | --lossy)
|
||||
# Use giflossy parameter
|
||||
lossiness="--lossy=$2"
|
||||
giftag="${giftag}-l$2"
|
||||
shift 2
|
||||
;;
|
||||
-f | --fps)
|
||||
# select fps
|
||||
infps="$2"
|
||||
giftag="${giftag}-f$2"
|
||||
shift 2
|
||||
;;
|
||||
-a | --alert)
|
||||
# set size alert
|
||||
alert="$2"
|
||||
shift 2
|
||||
;;
|
||||
-m | --webm)
|
||||
# set size alert
|
||||
make_webm="true"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
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)"
|
||||
echo "-d/--del/--delete Delete original vid if done suceessfully (and file not over the size limit)"
|
||||
echo "-h/--high High Quality - use Gifski instead of gifsicle"
|
||||
echo "-w/--width N Lock maximum gif width to N pixels, resize if necessary"
|
||||
echo "-t/--tag Add a tag to the output gif describing the options used (useful for comparing several options)"
|
||||
echo "-l/--lossy N Use the Giflossy parameter for gifsicle (If your version supports it)"
|
||||
echo "-f/--fps N Override autodetection of incoming vid FPS (useful for downsampling)"
|
||||
echo "-a/--alert N Alert if over N kilobytes (Defaults to 5000)"
|
||||
echo "-m/--webm Also create a webm file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Prepare the quality tag if requested.
|
||||
[[ -z "$giftag" ]] && giftag="-default"
|
||||
[[ -z "$giftagopt" ]] && giftag=""
|
||||
|
||||
for file; do
|
||||
|
||||
local output_file="${file%.*}${giftag}.gif"
|
||||
local del_after=$opt_del_after
|
||||
|
||||
if [[ -n "$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 -loop 0 "${file%.*}.webm" || return 2
|
||||
fi
|
||||
|
||||
# Set FPS to match the video if possible, otherwise fallback to default.
|
||||
if [[ -n "$infps" ]]; then
|
||||
fps=$infps
|
||||
else
|
||||
fps=$defaultfps
|
||||
if [[ -x "$mediainfo" ]]; then
|
||||
fps=$($mediainfo "$file" | grep "Frame rate " | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1)
|
||||
[[ -z "$fps" ]] && fps=$($mediainfo "$file" | grep "Minimum frame rate" | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1)
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$(tput setaf 2)Creating '$output_file' at $fps FPS ...$(tput sgr 0)"
|
||||
|
||||
if [[ "$use_gifski" = "true" ]]; then
|
||||
# I trust @pornel to do his own resizing optimization choices
|
||||
$ffmpeg -loglevel panic -i "$file" -r "$fps" -vcodec png v2gif-tmp-%05d.png \
|
||||
&& $gifski v2gif-tmp-*.png "$maxwidthski" --fps "$(printf "%.0f" "$fps")" -o "$output_file" || return 2
|
||||
else
|
||||
$ffmpeg -loglevel panic -i "$file" "$maxsize" -r "$fps" -vcodec png v2gif-tmp-%05d.png \
|
||||
&& $convert +dither -layers Optimize v2gif-tmp-*.png GIF:- \
|
||||
| $gifsicle "$lossiness" --no-warnings --colors 256 --delay="$(echo "100/$fps" | bc)" --loop --optimize=3 --multifile - > "$output_file" || return 2
|
||||
fi
|
||||
|
||||
rm v2gif-tmp-*.png
|
||||
|
||||
# Checking if the file is bigger than Twitter likes and warn
|
||||
if [[ $alert -gt 0 ]]; then
|
||||
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.$(tput sgr 0)"
|
||||
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
|
||||
del_after=""
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "$del_after" = "true" ]] && rm "$file"
|
||||
|
||||
done
|
||||
|
||||
echo "$(tput setaf 2)Done.$(tput sgr 0)"
|
||||
}
|
||||
|
||||
function any2webm() {
|
||||
about 'Converts an movies and Animated GIF files into an into a modern quality WebM video.'
|
||||
group 'gif'
|
||||
param '1: GIF/video file name(s)'
|
||||
param '2: -s <WxH> ; Optional: set <W>idth and <H>eight in pixels'
|
||||
param '3: -d ; Optional: delete the original file if succeeded'
|
||||
param '4: -t ; Optional: Tag the result with quality stamp for comparison use'
|
||||
param '5: -f <num> ; Optional: Change number of frames per second'
|
||||
param '6: -b <num> ; Optional: Set Bandwidth (quality/size of resulting file), Defaults to 2M (bits/sec, accepts fractions)"'
|
||||
param '7: -a <num> ; Optional: Alert if resulting file is over <num> kilobytes (default is 5000, 0 turns off)'
|
||||
example '$ any2webm foo.gif'
|
||||
example '$ any2webm *.mov -b 1.5M -s 600x480'
|
||||
|
||||
local args out_size
|
||||
|
||||
# Parse the options
|
||||
args=$(getopt -l alert -l "bandwidth:" -l "width:" -l del,delete -l tag -l "fps:" -l webm -o "a:b:w:f:dt" -- "$@") || {
|
||||
echo 'Terminating...' >&2
|
||||
return 2
|
||||
}
|
||||
|
||||
eval set -- "$args"
|
||||
local opt_del_after=""
|
||||
local size=""
|
||||
local webmtagopt=""
|
||||
local webmtag=""
|
||||
local defaultfps=10
|
||||
local fps=""
|
||||
local bandwidth="2M"
|
||||
local alert=5000
|
||||
while [[ $# -ge 1 ]]; do
|
||||
case "$1" in
|
||||
--)
|
||||
# No more options left.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-d | --del | --delete)
|
||||
# Delete after
|
||||
opt_del_after="true"
|
||||
shift
|
||||
;;
|
||||
-s | --size)
|
||||
size="-s $2"
|
||||
webmtag="${webmtag}-s$2"
|
||||
shift 2
|
||||
;;
|
||||
-t | --tag)
|
||||
# mark with a quality tag
|
||||
webmtagopt="true"
|
||||
shift
|
||||
;;
|
||||
-f | --fps)
|
||||
# select fps
|
||||
fps="-r $2"
|
||||
webmtag="${webmtag}-f$2"
|
||||
shift 2
|
||||
;;
|
||||
-b | --bandwidth)
|
||||
# select bandwidth
|
||||
bandwidth="$2"
|
||||
webmtag="${webmtag}-b$2"
|
||||
shift 2
|
||||
;;
|
||||
-a | --alert)
|
||||
# set size alert
|
||||
alert="$2"
|
||||
shift 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
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
|
||||
|
||||
# Prepare the quality tag if requested.
|
||||
[[ -z "$webmtag" ]] && webmtag="-default"
|
||||
[[ -z "$webmtagopt" ]] && webmtag=""
|
||||
|
||||
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" -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
|
||||
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.$(tput sgr 0)"
|
||||
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
|
||||
del_after=""
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "$del_after" = "true" ]] && rm "$file"
|
||||
|
||||
done
|
||||
|
||||
echo "$(tput setaf 2)Done.$(tput sgr 0)"
|
||||
}
|
||||
7
dot_bash_it/plugins/available/git-subrepo.plugin.bash
Normal file
7
dot_bash_it/plugins/available/git-subrepo.plugin.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'load git-subrepo if you are using it, and initialize completions'
|
||||
|
||||
if [[ -s "${GIT_SUBREPO_ROOT:=$HOME/.git-subrepo}/init" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source "$GIT_SUBREPO_ROOT/init"
|
||||
fi
|
||||
316
dot_bash_it/plugins/available/git.plugin.bash
Normal file
316
dot_bash_it/plugins/available/git.plugin.bash
Normal file
@@ -0,0 +1,316 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'git helper functions'
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
function git_remote {
|
||||
about 'adds remote $GIT_HOSTING:$1 to current repo'
|
||||
group "git"
|
||||
|
||||
echo "Running: git remote add origin ${GIT_HOSTING:?}:$1.git"
|
||||
git remote add origin "${GIT_HOSTING}:${1}".git
|
||||
}
|
||||
|
||||
function git_first_push {
|
||||
about 'push into origin refs/heads/master'
|
||||
group 'git'
|
||||
|
||||
echo "Running: git push origin master:refs/heads/master"
|
||||
git push origin master:refs/heads/master
|
||||
}
|
||||
|
||||
function git_pub() {
|
||||
about 'publishes current branch to remote origin'
|
||||
group 'git'
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
echo "Publishing ${BRANCH} to remote origin"
|
||||
git push -u origin "${BRANCH}"
|
||||
}
|
||||
|
||||
function git_revert() {
|
||||
about 'applies changes to HEAD that revert all changes after this commit'
|
||||
group 'git'
|
||||
|
||||
git reset "${1:?}"
|
||||
git reset --soft "HEAD@{1}"
|
||||
git commit -m "Revert to ${1}"
|
||||
git reset --hard
|
||||
}
|
||||
|
||||
function git_rollback() {
|
||||
about 'resets the current HEAD to this commit'
|
||||
group 'git'
|
||||
|
||||
function is_clean() {
|
||||
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
|
||||
echo "Your branch is dirty, please commit your changes"
|
||||
kill -INT $$
|
||||
fi
|
||||
}
|
||||
|
||||
function commit_exists() {
|
||||
if git rev-list --quiet "${1:?}"; then
|
||||
echo "Commit ${1} does not exist"
|
||||
kill -INT $$
|
||||
fi
|
||||
}
|
||||
|
||||
function keep_changes() {
|
||||
while true; do
|
||||
# shellcheck disable=SC2162
|
||||
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
|
||||
case "${RESP}" in
|
||||
|
||||
[yY])
|
||||
echo "Rolling back to commit ${1} with unstaged changes"
|
||||
git reset "$1"
|
||||
break
|
||||
;;
|
||||
[nN])
|
||||
echo "Rolling back to commit ${1} with a clean working tree"
|
||||
git reset --hard "$1"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Please enter Y or N"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||
is_clean
|
||||
commit_exists "$1"
|
||||
|
||||
while true; do
|
||||
# shellcheck disable=SC2162
|
||||
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
|
||||
case "${RESP}" in
|
||||
|
||||
[yY])
|
||||
keep_changes "$1"
|
||||
break
|
||||
;;
|
||||
[nN])
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Please enter Y or N"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
echo "you're currently not in a git repository"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_remove_missing_files() {
|
||||
about "git rm's missing files"
|
||||
group 'git'
|
||||
|
||||
git ls-files -d -z | xargs -0 git update-index --remove
|
||||
}
|
||||
|
||||
# Adds files to git's exclude file (same as .gitignore)
|
||||
function local-ignore() {
|
||||
about 'adds file or path to git exclude file'
|
||||
param '1: file or path fragment to ignore'
|
||||
group 'git'
|
||||
echo "$1" >> .git/info/exclude
|
||||
}
|
||||
|
||||
# get a quick overview for your git repo
|
||||
function git_info() {
|
||||
about 'overview for your git repo'
|
||||
group 'git'
|
||||
|
||||
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||
# print informations
|
||||
echo "git repo overview"
|
||||
echo "-----------------"
|
||||
echo
|
||||
|
||||
# print all remotes and thier details
|
||||
for remote in $(git remote show); do
|
||||
echo "${remote}":
|
||||
git remote show "${remote}"
|
||||
echo
|
||||
done
|
||||
|
||||
# print status of working repo
|
||||
echo "status:"
|
||||
if [ -n "$(git status -s 2> /dev/null)" ]; then
|
||||
git status -s
|
||||
else
|
||||
echo "working directory is clean"
|
||||
fi
|
||||
|
||||
# print at least 5 last log entries
|
||||
echo
|
||||
echo "log:"
|
||||
git log -5 --oneline
|
||||
echo
|
||||
|
||||
else
|
||||
echo "you're currently not in a git repository"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
function git_stats {
|
||||
about 'display stats per author'
|
||||
group 'git'
|
||||
|
||||
# awesome work from https://github.com/esc/git-stats
|
||||
# including some modifications
|
||||
|
||||
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||
echo "Number of commits per author:"
|
||||
git --no-pager shortlog -sn --all
|
||||
AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
|
||||
LOGOPTS=""
|
||||
if [ "$1" == '-w' ]; then
|
||||
LOGOPTS="${LOGOPTS} -w"
|
||||
shift
|
||||
fi
|
||||
if [ "$1" == '-M' ]; then
|
||||
LOGOPTS="${LOGOPTS} -M"
|
||||
shift
|
||||
fi
|
||||
if [ "$1" == '-C' ]; then
|
||||
LOGOPTS="${LOGOPTS} -C --find-copies-harder"
|
||||
shift
|
||||
fi
|
||||
for a in ${AUTHORS}; do
|
||||
echo '-------------------'
|
||||
echo "Statistics for: ${a}"
|
||||
echo -n "Number of files changed: "
|
||||
# shellcheck disable=SC2086
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f3 | sort -iu | wc -l
|
||||
echo -n "Number of lines added: "
|
||||
# shellcheck disable=SC2086
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f1 | awk '{s+=$1} END {print s}'
|
||||
echo -n "Number of lines deleted: "
|
||||
# shellcheck disable=SC2086
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f2 | awk '{s+=$1} END {print s}'
|
||||
echo -n "Number of merges: "
|
||||
# shellcheck disable=SC2086
|
||||
git log ${LOGOPTS} --all --merges --author="${a}" | grep -c '^commit'
|
||||
done
|
||||
else
|
||||
echo "you're currently not in a git repository"
|
||||
fi
|
||||
}
|
||||
|
||||
function gittowork() {
|
||||
about 'Places the latest .gitignore file for a given project type in the current directory, or concatenates onto an existing .gitignore'
|
||||
group 'git'
|
||||
param '1: the language/type of the project, used for determining the contents of the .gitignore file'
|
||||
example '$ gittowork java'
|
||||
|
||||
result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null)
|
||||
|
||||
if [[ "${result}" =~ ERROR ]]; then
|
||||
echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'"
|
||||
elif [[ $1 == list ]]; then
|
||||
echo "${result}"
|
||||
else
|
||||
if [[ -f .gitignore ]]; then
|
||||
result=$(grep -v "# Created by http://www.gitignore.io" <<< "${result}")
|
||||
echo ".gitignore already exists, appending..."
|
||||
fi
|
||||
echo "${result}" >> .gitignore
|
||||
fi
|
||||
}
|
||||
|
||||
function gitignore-reload() {
|
||||
about 'Empties the git cache, and readds all files not blacklisted by .gitignore'
|
||||
group 'git'
|
||||
example '$ gitignore-reload'
|
||||
|
||||
# The .gitignore file should not be reloaded if there are uncommited changes.
|
||||
# Firstly, require a clean work tree. The function require_clean_work_tree()
|
||||
# was stolen with love from https://www.spinics.net/lists/git/msg142043.html
|
||||
|
||||
# Begin require_clean_work_tree()
|
||||
|
||||
# Update the index
|
||||
git update-index -q --ignore-submodules --refresh
|
||||
err=0
|
||||
|
||||
# Disallow unstaged changes in the working tree
|
||||
if ! git diff-files --quiet --ignore-submodules --; then
|
||||
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes."
|
||||
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
|
||||
err=1
|
||||
fi
|
||||
|
||||
# Disallow uncommited changes in the index
|
||||
if ! git diff-index --cached --quiet HEAD --ignore-submodules; then
|
||||
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes."
|
||||
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
|
||||
err=1
|
||||
fi
|
||||
|
||||
# Prompt user to commit or stash changes and exit
|
||||
if [[ "${err}" == 1 ]]; then
|
||||
echo >&2 "Please commit or stash them."
|
||||
fi
|
||||
|
||||
# End require_clean_work_tree()
|
||||
|
||||
# If we're here, then there are no uncommited or unstaged changes dangling around.
|
||||
# Proceed to reload .gitignore
|
||||
if [[ "${err}" == 0 ]]; then
|
||||
# Remove all cached files
|
||||
git rm -r --cached .
|
||||
|
||||
# Re-add everything. The changed .gitignore will be picked up here and will exclude the files
|
||||
# now blacklisted by .gitignore
|
||||
echo >&2 "Running git add ."
|
||||
git add .
|
||||
echo >&2 "Files readded. Commit your new changes now."
|
||||
fi
|
||||
}
|
||||
|
||||
function git-changelog() {
|
||||
# ---------------------------------------------------------------
|
||||
# ORIGINAL ANSWER: https://stackoverflow.com/a/2979587/10362396 |
|
||||
# ---------------------------------------------------------------
|
||||
about 'Creates the git changelog from one point to another by date'
|
||||
group 'git'
|
||||
example '$ git-changelog origin/master...origin/release [md|txt]'
|
||||
|
||||
if [[ "$1" != *"..."* ]]; then
|
||||
echo "Please include the valid 'diff' to make changelog"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
local NEXT=$(date +%F)
|
||||
|
||||
if [[ "$2" == "md" ]]; then
|
||||
echo "# CHANGELOG $1"
|
||||
|
||||
# shellcheck disable=SC2162
|
||||
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
|
||||
echo
|
||||
echo "### ${DATE}"
|
||||
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
|
||||
NEXT=${DATE}
|
||||
done
|
||||
else
|
||||
echo "CHANGELOG $1"
|
||||
echo ----------------------
|
||||
|
||||
# shellcheck disable=SC2162
|
||||
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
|
||||
echo
|
||||
echo "[${DATE}]"
|
||||
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
|
||||
# shellcheck disable=SC2034
|
||||
NEXT=${DATE}
|
||||
done
|
||||
fi
|
||||
}
|
||||
26
dot_bash_it/plugins/available/gitstatus.plugin.bash
Normal file
26
dot_bash_it/plugins/available/gitstatus.plugin.bash
Normal file
@@ -0,0 +1,26 @@
|
||||
cite about-plugin
|
||||
about-plugin 'speeds up your life by using gitstatus for git status calculations. install from https://github.com/romkatv/gitstatus'
|
||||
|
||||
function gitstatus_on_disable() {
|
||||
about 'Destructor of gitstatus plugin'
|
||||
group 'gitstatus'
|
||||
|
||||
unset SCM_GIT_USE_GITSTATUS
|
||||
_command_exists gitstatus_stop && gitstatus_stop
|
||||
}
|
||||
|
||||
# No scm-check
|
||||
[[ $SCM_CHECK == "true" ]] || return
|
||||
|
||||
# non-interactive shell
|
||||
[[ $- == *i* ]] || return
|
||||
|
||||
: "${SCM_GIT_GITSTATUS_DIR:="$HOME/gitstatus"}"
|
||||
if [[ -d ${SCM_GIT_GITSTATUS_DIR} ]]; then
|
||||
source "${SCM_GIT_GITSTATUS_DIR}/gitstatus.plugin.sh"
|
||||
# Start the actual gitstatus binary
|
||||
gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1
|
||||
export SCM_GIT_USE_GITSTATUS=true
|
||||
else
|
||||
_log_warning "Could not find gitstatus directory in ${SCM_GIT_GITSTATUS_DIR}. Please specify directory location using SCM_GIT_GITSTATUS_DIR."
|
||||
fi
|
||||
36
dot_bash_it/plugins/available/go.plugin.bash
Normal file
36
dot_bash_it/plugins/available/go.plugin.bash
Normal file
@@ -0,0 +1,36 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'go environment variables & path configuration'
|
||||
|
||||
# Load after basher and goenv
|
||||
# BASH_IT_LOAD_PRIORITY: 270
|
||||
|
||||
# Test `go version` because goenv creates shim scripts that will be found in PATH
|
||||
# but do not always resolve to a working install.
|
||||
{ _command_exists go && go version &> /dev/null; } || return 0
|
||||
|
||||
export GOROOT="${GOROOT:-$(go env GOROOT)}"
|
||||
export GOPATH="${GOPATH:-$(go env GOPATH)}"
|
||||
|
||||
# $GOPATH/bin is the default location for binaries. Because GOPATH accepts a list of paths and each
|
||||
# might be managed differently, we add each path's /bin folder to PATH using pathmunge,
|
||||
# while preserving ordering.
|
||||
# e.g. GOPATH=foo:bar -> PATH=foo/bin:bar/bin
|
||||
_bash-it-gopath-pathmunge() {
|
||||
_about 'Ensures paths in GOPATH are added to PATH using pathmunge, with /bin appended'
|
||||
_group 'go'
|
||||
if [[ -z $GOPATH ]]; then
|
||||
echo 'GOPATH empty' >&2
|
||||
return 1
|
||||
fi
|
||||
local paths i
|
||||
IFS=: read -r -a paths <<< "$GOPATH"
|
||||
i=${#paths[@]}
|
||||
while [[ $i -gt 0 ]]; do
|
||||
i=$((i - 1))
|
||||
if [[ -n "${paths[i]}" ]]; then
|
||||
pathmunge "${paths[i]}/bin"
|
||||
fi
|
||||
done
|
||||
}
|
||||
_bash-it-gopath-pathmunge
|
||||
42
dot_bash_it/plugins/available/goenv.plugin.bash
Normal file
42
dot_bash_it/plugins/available/goenv.plugin.bash
Normal file
@@ -0,0 +1,42 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load goenv, if you are using it'
|
||||
|
||||
# https://github.com/syndbg/goenv
|
||||
|
||||
# Load after basher
|
||||
# BASH_IT_LOAD_PRIORITY: 260
|
||||
|
||||
# Don't modify the environment if we can't find the tool:
|
||||
# - Check if in $PATH already
|
||||
# - Check if installed manually to $GOENV_ROOT
|
||||
# - Check if installed manually to $HOME
|
||||
_command_exists goenv \
|
||||
|| [[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] \
|
||||
|| [[ -x "$HOME/.goenv/bin/goenv" ]] \
|
||||
|| return 0
|
||||
|
||||
# Set GOENV_ROOT, if not already set
|
||||
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
|
||||
|
||||
# Add GOENV_ROOT/bin to PATH, if that's where it's installed
|
||||
if ! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]]; then
|
||||
pathmunge "$GOENV_ROOT/bin"
|
||||
fi
|
||||
|
||||
# Initialize goenv
|
||||
eval "$(goenv init - bash)"
|
||||
|
||||
# If moving to a directory with a goenv version set, reload the shell
|
||||
# to ensure the shell environment matches expectations.
|
||||
_bash-it-goenv-preexec() {
|
||||
GOENV_OLD_VERSION="$(goenv version-name)"
|
||||
}
|
||||
_bash-it-goenv-precmd() {
|
||||
if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then
|
||||
exec env -u PATH -u GOROOT -u GOPATH -u GOENV_OLD_VERSION "${0/-/}" --login
|
||||
fi
|
||||
unset GOENV_OLD_VERSION
|
||||
}
|
||||
preexec_functions+=(_bash-it-goenv-preexec)
|
||||
precmd_functions+=(_bash-it-goenv-precmd)
|
||||
12
dot_bash_it/plugins/available/gradle.plugin.bash
Normal file
12
dot_bash_it/plugins/available/gradle.plugin.bash
Normal file
@@ -0,0 +1,12 @@
|
||||
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 result
|
||||
|
||||
result="$(_bash-it-find-in-ancestor "${file}")"
|
||||
|
||||
# Call gradle
|
||||
"${result:-gradle}" $*
|
||||
}
|
||||
25
dot_bash_it/plugins/available/hg.plugin.bash
Normal file
25
dot_bash_it/plugins/available/hg.plugin.bash
Normal file
@@ -0,0 +1,25 @@
|
||||
cite about-plugin
|
||||
about-plugin 'hg helper functions'
|
||||
|
||||
hg_dirty() {
|
||||
about 'displays dirty status of hg repository'
|
||||
group 'hg'
|
||||
|
||||
hg status --no-color 2> /dev/null \
|
||||
| awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
|
||||
| sort | uniq | head -c1
|
||||
}
|
||||
|
||||
hg_in_repo() {
|
||||
about 'determine if pwd is an hg repo'
|
||||
group 'hg'
|
||||
|
||||
[[ `hg branch 2> /dev/null` ]] && echo 'on '
|
||||
}
|
||||
|
||||
hg_branch() {
|
||||
about 'display current hg branch'
|
||||
group 'hg'
|
||||
|
||||
hg branch 2> /dev/null
|
||||
}
|
||||
22
dot_bash_it/plugins/available/history-eternal.plugin.bash
Normal file
22
dot_bash_it/plugins/available/history-eternal.plugin.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'eternal bash history'
|
||||
|
||||
if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 3 ]]; then
|
||||
_log_warning "Bash version 4.3 introduced the 'unlimited' history size capability."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Modify history sizes before changing location to avoid unintentionally
|
||||
# truncating the history file early.
|
||||
|
||||
# "Numeric values less than zero result in every command being saved on the history list (there is no limit)"
|
||||
readonly HISTSIZE=-1 2> /dev/null || true
|
||||
|
||||
# "Non-numeric values and numeric values less than zero inhibit truncation"
|
||||
readonly HISTFILESIZE='unlimited' 2> /dev/null || true
|
||||
|
||||
# Use a custom history file location so history is not truncated
|
||||
# if the environment ever loses this "eternal" configuration.
|
||||
HISTDIR="${XDG_STATE_HOME:-${HOME?}/.local/state}/bash"
|
||||
[[ -d ${HISTDIR?} ]] || mkdir -p "${HISTDIR?}"
|
||||
readonly HISTFILE="${HISTDIR?}/history" 2> /dev/null || true
|
||||
9
dot_bash_it/plugins/available/history-search.plugin.bash
Normal file
9
dot_bash_it/plugins/available/history-search.plugin.bash
Normal file
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'search history using the prefix already entered'
|
||||
|
||||
# enter a few characters and press UpArrow/DownArrow
|
||||
# to search backwards/forwards through the history
|
||||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||
bind '"\e[A":history-search-backward'
|
||||
bind '"\e[B":history-search-forward'
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'search history using the substring already entered'
|
||||
|
||||
# enter a few characters and press UpArrow/DownArrow
|
||||
# to search backwards/forwards through the history
|
||||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||
bind '"\e[A":history-substring-search-backward'
|
||||
bind '"\e[B":history-substring-search-forward'
|
||||
fi
|
||||
36
dot_bash_it/plugins/available/history.plugin.bash
Normal file
36
dot_bash_it/plugins/available/history.plugin.bash
Normal file
@@ -0,0 +1,36 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'improve history handling with sane defaults'
|
||||
|
||||
# Append the history list to the file named by the value of the HISTFILE
|
||||
# variable when the shell exits, rather than overwriting the file.
|
||||
shopt -s histappend
|
||||
|
||||
# 'ignorespace': don't save command lines which begin with a space to history
|
||||
# 'erasedups' (alternative 'ignoredups'): don't save duplicates to history
|
||||
# 'autoshare': automatically share history between multiple running shells
|
||||
: "${HISTCONTROL:=ignorespace:erasedups:autoshare}"
|
||||
|
||||
# resize history to 100x the default (500)
|
||||
: "${HISTSIZE:=50000}"
|
||||
|
||||
function top-history() {
|
||||
about 'print the name and count of the most commonly run tools'
|
||||
|
||||
# - Make sure formatting doesn't interfer with our parsing
|
||||
# - Use awk to count how many times the first command on each line has been called
|
||||
# - Truncate to 10 lines
|
||||
# - Print in column format
|
||||
HISTTIMEFORMAT='' history \
|
||||
| awk '{
|
||||
a[$2]++
|
||||
}END{
|
||||
for(i in a)
|
||||
printf("%s\t%s\n", a[i], i)
|
||||
}' \
|
||||
| sort --reverse --numeric-sort \
|
||||
| head \
|
||||
| column \
|
||||
--table \
|
||||
--table-columns 'Command Count,Command Name' \
|
||||
--output-separator ' | '
|
||||
}
|
||||
7
dot_bash_it/plugins/available/hub.plugin.bash
Normal file
7
dot_bash_it/plugins/available/hub.plugin.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load hub, if you are using it'
|
||||
|
||||
if _command_exists hub; then
|
||||
eval "$(hub alias -s)"
|
||||
fi
|
||||
11
dot_bash_it/plugins/available/java.plugin.bash
Normal file
11
dot_bash_it/plugins/available/java.plugin.bash
Normal file
@@ -0,0 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'Java and JAR helper functions'
|
||||
|
||||
function jar_manifest {
|
||||
about "extracts the specified JAR file's MANIFEST file and prints it to stdout"
|
||||
group 'java'
|
||||
param '1: JAR file to extract the MANIFEST from'
|
||||
example 'jar_manifest lib/foo.jar'
|
||||
|
||||
unzip -c "${1:?${FUNCNAME[0]}: JAR file must be specified}" META-INF/MANIFEST.MF
|
||||
}
|
||||
41
dot_bash_it/plugins/available/javascript.plugin.bash
Normal file
41
dot_bash_it/plugins/available/javascript.plugin.bash
Normal file
@@ -0,0 +1,41 @@
|
||||
# The install directory is hard-coded. TODO: allow the directory to be specified on the command line.
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'download jquery files into current project'
|
||||
|
||||
[[ -z "$JQUERY_VERSION_NUMBER" ]] && JQUERY_VERSION_NUMBER="1.6.1"
|
||||
[[ -z "$JQUERY_UI_VERSION_NUMBER" ]] && JQUERY_UI_VERSION_NUMBER="1.8.13"
|
||||
|
||||
function rails_jquery {
|
||||
about 'download rails.js into public/javascripts'
|
||||
group 'javascript'
|
||||
|
||||
curl -o public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js
|
||||
}
|
||||
|
||||
function jquery_install {
|
||||
about 'download jquery.js into public/javascripts'
|
||||
group 'javascript'
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
version=$JQUERY_VERSION_NUMBER
|
||||
else
|
||||
version="$1"
|
||||
fi
|
||||
curl -o public/javascripts/jquery.js "http://ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js"
|
||||
}
|
||||
|
||||
function jquery_ui_install {
|
||||
about 'download jquery_us.js into public/javascripts'
|
||||
group 'javascript'
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
version=$JQUERY_UI_VERSION_NUMBER
|
||||
else
|
||||
version="$1"
|
||||
fi
|
||||
|
||||
curl -o public/javascripts/jquery_ui.js "http://ajax.googleapis.com/ajax/libs/jqueryui/$version/jquery-ui.min.js"
|
||||
}
|
||||
288
dot_bash_it/plugins/available/jekyll.plugin.bash
Normal file
288
dot_bash_it/plugins/available/jekyll.plugin.bash
Normal file
@@ -0,0 +1,288 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'manage your jekyll site'
|
||||
|
||||
function editpost() {
|
||||
about 'edit a post'
|
||||
param '1: site directory'
|
||||
group 'jekyll'
|
||||
|
||||
local SITE site POST DATE TITLE POSTS
|
||||
local -i COUNTER=1 POST_TO_EDIT ret
|
||||
if [[ -z "${1:-}" ]]; then
|
||||
echo "Error: no site specified."
|
||||
echo "The site is the name of the directory your project is in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
for site in "${SITES[@]:-}"; do
|
||||
if [[ "${site##*/}" == "$1" ]]; then
|
||||
SITE="${site}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${SITE:-}" ]]; then
|
||||
echo "No such site."
|
||||
return 1
|
||||
fi
|
||||
|
||||
pushd "${SITE}/_posts" > /dev/null || return
|
||||
|
||||
for POST in *; do
|
||||
DATE="$(echo "${POST}" | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")"
|
||||
TITLE="$(grep -oE "title: (.+)" < "${POST}")"
|
||||
TITLE="${TITLE/title: /}"
|
||||
echo "${COUNTER}) ${DATE} ${TITLE}"
|
||||
POSTS[COUNTER]="$POST"
|
||||
COUNTER="$((COUNTER + 1))"
|
||||
done > >(less)
|
||||
read -rp "Number of post to edit: " POST_TO_EDIT
|
||||
"${JEKYLL_EDITOR:-${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}}}" "${POSTS[POST_TO_EDIT]}"
|
||||
ret="$?"
|
||||
popd > /dev/null || return "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
function newpost() {
|
||||
about 'create a new post'
|
||||
param '1: site directory'
|
||||
group 'jekyll'
|
||||
|
||||
local SITE site FNAME_POST_TITLE FNAME YAML_DATE
|
||||
local JEKYLL_FORMATTING FNAME_DATE OPTIONS OPTION POST_TYPE POST_TITLE
|
||||
local -i loc=0 ret
|
||||
if [[ -z "${1:-}" ]]; then
|
||||
echo "Error: no site specified."
|
||||
echo "The site is the name of the directory your project is in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "${SITE}" ]]; then
|
||||
echo "No such site."
|
||||
return 1
|
||||
fi
|
||||
|
||||
for site in "${SITES[@]}"; do
|
||||
if [[ "${site##*/}" == "$1" ]]; then
|
||||
SITE="$site"
|
||||
JEKYLL_FORMATTING="${MARKUPS[loc]}"
|
||||
break
|
||||
fi
|
||||
loc=$((loc + 1))
|
||||
done
|
||||
|
||||
# Change directory into the local jekyll root
|
||||
pushd "${SITE}/_posts" > /dev/null || return
|
||||
|
||||
# Get the date for the new post's filename
|
||||
FNAME_DATE="$(date "+%Y-%m-%d")"
|
||||
|
||||
# If the user is using markdown or textile formatting, let them choose what type of post they want. Sort of like Tumblr.
|
||||
OPTIONS=('Text' 'Quote' 'Image' 'Audio' 'Video' 'Link')
|
||||
|
||||
if [[ $JEKYLL_FORMATTING == "markdown" || $JEKYLL_FORMATTING == "textile" ]]; then
|
||||
select OPTION in "${OPTIONS[@]}"; do
|
||||
POST_TYPE="${OPTION}"
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
# Get the title for the new post
|
||||
read -rp "Enter title of the new post: " POST_TITLE
|
||||
|
||||
# Convert the spaces in the title to hyphens for use in the filename
|
||||
FNAME_POST_TITLE="${POST_TITLE/ /-}"
|
||||
|
||||
# Now, put it all together for the full filename
|
||||
FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING"
|
||||
|
||||
# And, finally, create the actual post file. But we're not done yet...
|
||||
{
|
||||
# Write a little stuff to the file for the YAML Front Matter
|
||||
echo "---"
|
||||
|
||||
# Now we have to get the date, again. But this time for in the header (YAML Front Matter) of the file
|
||||
YAML_DATE="$(date "+%B %d %Y %X")"
|
||||
|
||||
# Echo the YAML Formatted date to the post file
|
||||
echo "date: $YAML_DATE"
|
||||
|
||||
# Echo the original post title to the YAML Front Matter header
|
||||
echo "title: $POST_TITLE"
|
||||
|
||||
# And, now, echo the "post" layout to the YAML Front Matter header
|
||||
echo "layout: post"
|
||||
|
||||
# Close the YAML Front Matter Header
|
||||
echo "---"
|
||||
|
||||
echo
|
||||
} > "${FNAME}"
|
||||
|
||||
# Generate template text based on the post type
|
||||
if [[ $JEKYLL_FORMATTING == "markdown" ]]; then
|
||||
case $POST_TYPE in
|
||||
"Text")
|
||||
true
|
||||
;;
|
||||
"Quote")
|
||||
echo "> Quote"
|
||||
echo
|
||||
echo "— Author"
|
||||
;;
|
||||
"Image")
|
||||
echo ""
|
||||
;;
|
||||
"Audio")
|
||||
echo "<html><audio src=\"/path/to/audio/file\" controls=\"controls\"></audio></html>"
|
||||
;;
|
||||
"Video")
|
||||
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>"
|
||||
;;
|
||||
"Link")
|
||||
echo "[link][1]"
|
||||
echo
|
||||
echo "> Quote"
|
||||
echo
|
||||
echo "[1]: url"
|
||||
;;
|
||||
esac
|
||||
elif [[ $JEKYLL_FORMATTING == "textile" ]]; then
|
||||
case $POST_TYPE in
|
||||
"Text")
|
||||
true
|
||||
;;
|
||||
"Quote")
|
||||
echo "bq. Quote"
|
||||
echo
|
||||
echo "— Author"
|
||||
;;
|
||||
"Image")
|
||||
echo "!url(alt text)"
|
||||
;;
|
||||
"Audio")
|
||||
echo "<html><audio src=\"/path/to/audio/file\" controls=\"controls\"></audio></html>"
|
||||
;;
|
||||
"Video")
|
||||
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>"
|
||||
;;
|
||||
"Link")
|
||||
echo "\"Site\":url"
|
||||
echo
|
||||
echo "bq. Quote"
|
||||
;;
|
||||
esac
|
||||
fi >> "${FNAME}"
|
||||
|
||||
# Open the file in your favorite editor
|
||||
"${JEKYLL_EDITOR:-${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}}}" "${FNAME}"
|
||||
ret="$?"
|
||||
popd > /dev/null || return "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
function testsite() {
|
||||
about 'launches local jekyll server'
|
||||
param '1: site directory'
|
||||
group 'jekyll'
|
||||
|
||||
local SITE site
|
||||
local -i ret
|
||||
if [[ -z "${1:-}" ]]; then
|
||||
echo "Error: no site specified."
|
||||
echo "The site is the name of the directory your project is in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
for site in "${SITES[@]}"; do
|
||||
if [[ "${site##*/}" == "$1" ]]; then
|
||||
SITE="$site"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${SITE}" ]]; then
|
||||
echo "No such site."
|
||||
return 1
|
||||
fi
|
||||
|
||||
pushd "${SITE}" > /dev/null || return
|
||||
jekyll --server --auto
|
||||
ret="$?"
|
||||
popd > /dev/null || return "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
function buildsite() {
|
||||
about 'builds site'
|
||||
param '1: site directory'
|
||||
group 'jekyll'
|
||||
|
||||
local SITE site
|
||||
local -i ret
|
||||
if [[ -z "${1:-}" ]]; then
|
||||
echo "Error: no site specified."
|
||||
echo "The site is the name of the directory your project is in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
for site in "${SITES[@]}"; do
|
||||
if [[ "${site##*/}" == "$1" ]]; then
|
||||
SITE="$site"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${SITE}" ]]; then
|
||||
echo "No such site."
|
||||
return 1
|
||||
fi
|
||||
|
||||
pushd "${SITE}" > /dev/null || return
|
||||
rm -rf _site
|
||||
jekyll --no-server
|
||||
ret="$?"
|
||||
popd > /dev/null || return "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
function deploysite() {
|
||||
about 'rsyncs site to remote host'
|
||||
param '1: site directory'
|
||||
group 'jekyll'
|
||||
|
||||
local SITE site REMOTE
|
||||
local -i loc=0 ret
|
||||
if [[ -z "${1:-}" ]]; then
|
||||
echo "Error: no site specified."
|
||||
echo "The site is the name of the directory your project is in."
|
||||
return 1
|
||||
fi
|
||||
|
||||
for site in "${SITES[@]}"; do
|
||||
if [[ "${site##*/}" == "$1" ]]; then
|
||||
SITE="$site"
|
||||
# shellcheck disable=SC2153 # who knows
|
||||
REMOTE="${REMOTES[loc]}"
|
||||
break
|
||||
fi
|
||||
loc=$((loc + 1))
|
||||
done
|
||||
|
||||
if [[ -z "${SITE}" ]]; then
|
||||
echo "No such site."
|
||||
return 1
|
||||
fi
|
||||
|
||||
pushd "${SITE}" > /dev/null || return
|
||||
rsync -rz "${REMOTE?}"
|
||||
ret="$?"
|
||||
popd > /dev/null || return "$ret"
|
||||
return "$ret"
|
||||
}
|
||||
|
||||
# Load the Jekyll config
|
||||
if [[ -s "$HOME/.jekyllconfig" ]]; then
|
||||
source "$HOME/.jekyllconfig"
|
||||
fi
|
||||
22
dot_bash_it/plugins/available/jenv.plugin.bash
Normal file
22
dot_bash_it/plugins/available/jenv.plugin.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load jenv, if you are using it'
|
||||
|
||||
# Don't modify the environment if we can't find the tool:
|
||||
# - Check if in $PATH already
|
||||
# - Check if installed manually to $JENV_ROOT
|
||||
# - Check if installed manually to $HOME
|
||||
_command_exists jenv ||
|
||||
[[ -n "$JENV_ROOT" && -x "$JENV_ROOT/bin/jenv" ]] ||
|
||||
[[ -x "$HOME/.jenv/bin/jenv" ]] ||
|
||||
return
|
||||
|
||||
# Set JENV_ROOT, if not already set
|
||||
export JENV_ROOT="${JENV_ROOT:-$HOME/.jenv}"
|
||||
|
||||
# Add JENV_ROOT/bin to PATH, if that's where it's installed
|
||||
! _command_exists jenv &&
|
||||
[[ -x "$JENV_ROOT/bin/jenv" ]] &&
|
||||
pathmunge "$JENV_ROOT/bin"
|
||||
|
||||
# Initialize jenv
|
||||
eval "$(jenv init - bash)"
|
||||
47
dot_bash_it/plugins/available/jgitflow.plugin.bash
Normal file
47
dot_bash_it/plugins/available/jgitflow.plugin.bash
Normal 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
|
||||
}
|
||||
12
dot_bash_it/plugins/available/jump.plugin.bash
Normal file
12
dot_bash_it/plugins/available/jump.plugin.bash
Normal file
@@ -0,0 +1,12 @@
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2016
|
||||
cite about-plugin
|
||||
about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding'
|
||||
|
||||
function __init_jump() {
|
||||
if _command_exists jump; then
|
||||
eval "$(jump shell bash "${JUMP_OPTS[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
__init_jump
|
||||
19
dot_bash_it/plugins/available/latex.plugin.bash
Normal file
19
dot_bash_it/plugins/available/latex.plugin.bash
Normal file
@@ -0,0 +1,19 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'add MacTeX to PATH'
|
||||
|
||||
_bash_it_plugin_latex_paths=(
|
||||
# Standard locations
|
||||
/usr/local/texbin
|
||||
# MacOS locations
|
||||
/Library/TeX/texbin
|
||||
)
|
||||
|
||||
# add mactex to the path if its present
|
||||
for _bash_it_plugin_latex_path in "${_bash_it_plugin_latex_paths[@]}"; do
|
||||
if [[ -d "$_bash_it_plugin_latex_path/" ]]; then
|
||||
pathmunge "$_bash_it_plugin_latex_path" after && break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
unset "${!_bash_it_plugin_latex_@}"
|
||||
23
dot_bash_it/plugins/available/less-pretty-cat.plugin.bash
Normal file
23
dot_bash_it/plugins/available/less-pretty-cat.plugin.bash
Normal file
@@ -0,0 +1,23 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'pygmentize instead of cat to terminal if possible'
|
||||
|
||||
_command_exists pygmentize || return
|
||||
|
||||
# pigmentize cat and less outputs - call them ccat and cless to avoid that
|
||||
# especially cat'ed output in scripts gets mangled with pygemtized meta characters
|
||||
function ccat() {
|
||||
about 'runs pygmentize on each file passed in'
|
||||
param '*: files to concatenate (as normally passed to cat)'
|
||||
example 'ccat mysite/manage.py dir/text-file.txt'
|
||||
|
||||
pygmentize -f 256 -O style="${BASH_IT_CCAT_STYLE:-default}" -g "$@"
|
||||
}
|
||||
|
||||
function cless() {
|
||||
about 'pigments the files passed in and passes to less for pagination'
|
||||
param '*: the files to paginate with less'
|
||||
example 'cless mysite/manage.py'
|
||||
|
||||
pygmentize -f 256 -O style="${BASH_IT_CLESS_STYLE:-default}" -g "$@" | command less -R
|
||||
}
|
||||
14
dot_bash_it/plugins/available/man.plugin.bash
Normal file
14
dot_bash_it/plugins/available/man.plugin.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'colorize man pages for better readability'
|
||||
|
||||
: "${LESS_TERMCAP_mb:=$'\e[1;32m'}"
|
||||
: "${LESS_TERMCAP_md:=$'\e[1;32m'}"
|
||||
: "${LESS_TERMCAP_me:=$'\e[0m'}"
|
||||
: "${LESS_TERMCAP_se:=$'\e[0m'}"
|
||||
: "${LESS_TERMCAP_so:=$'\e[01;33m'}"
|
||||
: "${LESS_TERMCAP_ue:=$'\e[0m'}"
|
||||
: "${LESS_TERMCAP_us:=$'\e[1;4;31m'}"
|
||||
|
||||
: "${LESS:=}"
|
||||
export "${!LESS_TERMCAP@}"
|
||||
export LESS="R${LESS#-}"
|
||||
55
dot_bash_it/plugins/available/nginx.plugin.bash
Normal file
55
dot_bash_it/plugins/available/nginx.plugin.bash
Normal file
@@ -0,0 +1,55 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'manage your nginx service'
|
||||
|
||||
pathmunge "${NGINX_PATH:=/opt/nginx}/sbin" after
|
||||
export NGINX_PATH
|
||||
|
||||
function nginx_reload() {
|
||||
about 'reload your nginx config'
|
||||
group 'nginx'
|
||||
|
||||
local FILE="${NGINX_PATH?}/logs/nginx.pid"
|
||||
if [[ -s $FILE ]]; then
|
||||
echo "Reloading NGINX..."
|
||||
read -r PID < "${FILE}"
|
||||
sudo kill -HUP "${PID?}"
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_stop() {
|
||||
about 'stop nginx'
|
||||
group 'nginx'
|
||||
|
||||
local FILE="${NGINX_PATH?}/logs/nginx.pid"
|
||||
if [[ -s $FILE ]]; then
|
||||
echo "Stopping NGINX..."
|
||||
read -r PID < "${FILE}"
|
||||
sudo kill -INT "${PID?}"
|
||||
else
|
||||
echo "Nginx pid file not found"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_start() {
|
||||
about 'start nginx'
|
||||
group 'nginx'
|
||||
|
||||
local FILE="${NGINX_PATH?}/sbin/nginx"
|
||||
if [[ -x $FILE ]]; then
|
||||
echo "Starting NGINX..."
|
||||
sudo "${FILE}"
|
||||
else
|
||||
echo "Couldn't start nginx"
|
||||
fi
|
||||
}
|
||||
|
||||
function nginx_restart() {
|
||||
about 'restart nginx'
|
||||
group 'nginx'
|
||||
|
||||
nginx_stop && nginx_start
|
||||
}
|
||||
14
dot_bash_it/plugins/available/node.plugin.bash
Normal file
14
dot_bash_it/plugins/available/node.plugin.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Node.js helper functions'
|
||||
|
||||
# Check that we have npm
|
||||
_command_exists npm || return
|
||||
|
||||
# Ensure local modules are preferred in PATH
|
||||
pathmunge "./node_modules/.bin" "after"
|
||||
|
||||
# If not using nodenv, ensure global modules are in PATH
|
||||
if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then
|
||||
pathmunge "$(npm config get prefix)/bin" "after"
|
||||
fi
|
||||
10
dot_bash_it/plugins/available/nodenv.plugin.bash
Normal file
10
dot_bash_it/plugins/available/nodenv.plugin.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load nodenv, if you are using it'
|
||||
|
||||
export NODENV_ROOT="$HOME/.nodenv"
|
||||
pathmunge "$NODENV_ROOT/bin"
|
||||
|
||||
if _command_exists nodenv; then
|
||||
eval "$(nodenv init - bash)"
|
||||
fi
|
||||
31
dot_bash_it/plugins/available/nvm.plugin.bash
Normal file
31
dot_bash_it/plugins/available/nvm.plugin.bash
Normal file
@@ -0,0 +1,31 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# BASH_IT_LOAD_PRIORITY: 225
|
||||
#
|
||||
# Bash-it no longer bundles nvm, as this was quickly becoming outdated.
|
||||
# Please install nvm from https://github.com/creationix/nvm.git if you want to use it.
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'node version manager configuration'
|
||||
|
||||
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||||
# This loads nvm
|
||||
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]]
|
||||
then
|
||||
source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh"
|
||||
else
|
||||
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
||||
fi
|
||||
|
||||
if ! _command_exists nvm
|
||||
then
|
||||
function nvm() {
|
||||
echo "Bash-it no longer bundles the nvm script. Please install the latest version from"
|
||||
echo ""
|
||||
echo "https://github.com/creationix/nvm.git"
|
||||
echo ""
|
||||
echo "if you want to use nvm. You can keep this plugin enabled once you have installed nvm."
|
||||
}
|
||||
|
||||
nvm
|
||||
fi
|
||||
95
dot_bash_it/plugins/available/osx-timemachine.plugin.bash
Normal file
95
dot_bash_it/plugins/available/osx-timemachine.plugin.bash
Normal file
@@ -0,0 +1,95 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'OS X Time Machine functions'
|
||||
|
||||
if [[ "${OSTYPE}" != 'darwin'* ]]; then
|
||||
_log_warning "This plugin only works with Mac OS X"
|
||||
return 1
|
||||
fi
|
||||
|
||||
function time-machine-destination() {
|
||||
group "osx-timemachine"
|
||||
about "Shows the OS X Time Machine destination/mount point"
|
||||
|
||||
tmutil destinationinfo | grep "Mount Point" | sed -e 's/Mount Point : \(.*\)/\1/g'
|
||||
}
|
||||
|
||||
function time-machine-list-machines() {
|
||||
group "osx-timemachine"
|
||||
about "Lists the OS X Time Machine machines on the backup volume"
|
||||
|
||||
local tmdest
|
||||
tmdest="$(time-machine-destination)/Backups.backupdb"
|
||||
|
||||
find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read -r line; do
|
||||
echo "${line##*/}"
|
||||
done
|
||||
}
|
||||
|
||||
function time-machine-list-all-backups() {
|
||||
group "osx-timemachine"
|
||||
about "Shows all of the backups for the specified machine"
|
||||
param "1: Machine name (optional)"
|
||||
example "time-machine-list-all-backups my-laptop"
|
||||
|
||||
# Use the local hostname if none provided
|
||||
local COMPUTERNAME BACKUP_LOCATION
|
||||
COMPUTERNAME=${1:-$(scutil --get ComputerName)}
|
||||
BACKUP_LOCATION="$(time-machine-destination)/Backups.backupdb/$COMPUTERNAME"
|
||||
|
||||
find "$BACKUP_LOCATION" -maxdepth 1 -mindepth 1 -type d | while read -r line; do
|
||||
echo "$line"
|
||||
done
|
||||
}
|
||||
|
||||
function time-machine-list-old-backups() {
|
||||
group "osx-timemachine"
|
||||
about "Shows all of the backups for the specified machine, except for the most recent backup"
|
||||
param "1: Machine name (optional)"
|
||||
example "time-machine-list-old-backups my-laptop"
|
||||
|
||||
# Use the local hostname if none provided
|
||||
local COMPUTERNAME BACKUP_LOCATION
|
||||
COMPUTERNAME=${1:-$(scutil --get ComputerName)}
|
||||
BACKUP_LOCATION="$(time-machine-destination)/Backups.backupdb/$COMPUTERNAME"
|
||||
|
||||
# List all but the most recent one
|
||||
find "$BACKUP_LOCATION" -maxdepth 1 -mindepth 1 -type d -name 2\* | sed \$d | while read -r line; do
|
||||
echo "$line"
|
||||
done
|
||||
}
|
||||
|
||||
# Taken from here: http://stackoverflow.com/a/30547074/1228454
|
||||
function _tm_startsudo() {
|
||||
local -x SUDO_COMMAND="plugin/osx-timemachine: keep 'sudo' token alive during long-run 'tmutil' commands"
|
||||
sudo "-${SUDO_ASKPASS:+A}v" # validate without running a command, using `ssh-askpass` if available.
|
||||
(while sudo "-${SUDO_ASKPASS:+A}v"; do
|
||||
sleep 50
|
||||
done) &
|
||||
SUDO_PID="$!"
|
||||
trap _tm_stopsudo SIGINT SIGTERM
|
||||
}
|
||||
function _tm_stopsudo() {
|
||||
kill "$SUDO_PID"
|
||||
trap - SIGINT SIGTERM
|
||||
sudo -k
|
||||
}
|
||||
|
||||
function time-machine-delete-old-backups() {
|
||||
group "osx-timemachine"
|
||||
about "Deletes all of the backups for the specified machine, with the exception of the most recent one"
|
||||
param "1: Machine name (optional)"
|
||||
example "time-machine-delete-old-backups my-laptop"
|
||||
|
||||
# Use the local hostname if none provided
|
||||
local COMPUTERNAME=${1:-$(scutil --get ComputerName)} _old_backup
|
||||
|
||||
# Ask for sudo credentials only once
|
||||
_tm_startsudo
|
||||
|
||||
while read -r _old_backup; do
|
||||
# Delete the backup
|
||||
sudo tmutil delete "$_old_backup"
|
||||
done <<< "$(time-machine-list-old-backups "$COMPUTERNAME")"
|
||||
|
||||
_tm_stopsudo
|
||||
}
|
||||
132
dot_bash_it/plugins/available/osx.plugin.bash
Normal file
132
dot_bash_it/plugins/available/osx.plugin.bash
Normal file
@@ -0,0 +1,132 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'osx-specific functions'
|
||||
|
||||
if [[ "${OSTYPE}" != 'darwin'* ]]; then
|
||||
_log_warning "This plugin only works with Mac OS X."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# OS X: Open new tabs in same directory
|
||||
if _is_function update_terminal_cwd; then
|
||||
safe_append_prompt_command 'update_terminal_cwd'
|
||||
fi
|
||||
|
||||
function tab() {
|
||||
about 'opens a new terminal tab'
|
||||
group 'osx'
|
||||
|
||||
osascript 2> /dev/null << EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
end
|
||||
tell application "Terminal"
|
||||
activate
|
||||
do script with command " cd \"$PWD\"; $*" in window 0
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
# renames the current os x terminal tab title
|
||||
function tabname {
|
||||
printf '%b' "\e]1;$1\a"
|
||||
}
|
||||
|
||||
# renames the current os x terminal window title
|
||||
function winname {
|
||||
printf '%b' "\e]2;$1\a"
|
||||
}
|
||||
|
||||
function pman() {
|
||||
about 'view man documentation in Preview'
|
||||
param '1: man page to view'
|
||||
example '$ pman bash'
|
||||
group 'osx'
|
||||
man -t "${1}" | open -fa 'Preview'
|
||||
}
|
||||
|
||||
function pri() {
|
||||
about 'display information about Ruby classes, modules, or methods, in Preview'
|
||||
param '1: Ruby method, module, or class'
|
||||
example '$ pri Array'
|
||||
group 'osx'
|
||||
ri -T "${1}" | open -fa 'Preview'
|
||||
}
|
||||
|
||||
# Download a file and open it in Preview
|
||||
function prevcurl() {
|
||||
about 'download a file and open it in Preview'
|
||||
param '1: url'
|
||||
group 'osx'
|
||||
|
||||
curl "$*" | open -fa 'Preview'
|
||||
}
|
||||
|
||||
function refresh-launchpad() {
|
||||
about 'Reset launchpad layout in macOS'
|
||||
example '$ refresh-launchpad'
|
||||
group 'osx'
|
||||
|
||||
defaults write com.apple.dock ResetLaunchPad -bool TRUE
|
||||
killall Dock
|
||||
}
|
||||
|
||||
function list-jvms() {
|
||||
about 'List java virtual machines and their states in macOS'
|
||||
example 'list-jvms'
|
||||
group 'osx'
|
||||
|
||||
local JVMS_DIR="/Library/Java/JavaVirtualMachines"
|
||||
# The following variables are intended to impact the enclosing scope, not local.
|
||||
JVMS=("${JVMS_DIR}"/*)
|
||||
JVMS_STATES=()
|
||||
|
||||
# Map state of JVM
|
||||
for ((i = 0; i < ${#JVMS[@]}; i++)); do
|
||||
if [[ -f "${JVMS[i]}/Contents/Info.plist" ]]; then
|
||||
JVMS_STATES[i]=enabled
|
||||
else
|
||||
JVMS_STATES[i]=disabled
|
||||
fi
|
||||
printf '%s\t%s\t%s\n' "${i}" "${JVMS[i]##*/}" "${JVMS_STATES[i]}"
|
||||
done
|
||||
}
|
||||
|
||||
function pick-default-jvm() {
|
||||
about 'Pick the default Java Virtual Machines in system-wide scope in macOS'
|
||||
example 'pick-default-jvm'
|
||||
|
||||
# Declare variables
|
||||
local JVMS JVMS_STATES
|
||||
local DEFAULT_JVM_DIR DEFAULT_JVM OPTION
|
||||
|
||||
# Call function for listing
|
||||
list-jvms
|
||||
|
||||
# OPTION for default jdk and set variables
|
||||
while [[ ! "$OPTION" =~ ^[0-9]+$ || OPTION -ge "${#JVMS[@]}" ]]; do
|
||||
read -rp "Enter Default JVM: " OPTION
|
||||
if [[ ! "$OPTION" =~ ^[0-9]+$ ]]; then
|
||||
echo "Please enter a number"
|
||||
fi
|
||||
|
||||
if [[ OPTION -ge "${#JVMS[@]}" ]]; then
|
||||
echo "Please select one of the displayed JVMs"
|
||||
fi
|
||||
done
|
||||
|
||||
DEFAULT_JVM_DIR="${JVMS[OPTION]}"
|
||||
DEFAULT_JVM="${JVMS[OPTION]##*/}"
|
||||
|
||||
# Disable all jdk
|
||||
for ((i = 0; i < ${#JVMS[@]}; i++)); do
|
||||
if [[ "${JVMS[i]}" != "${DEFAULT_JVM_DIR}" && -f "${JVMS[i]}/Contents/Info.plist" ]]; then
|
||||
sudo mv "${JVMS[i]}/Contents/Info.plist" "${JVMS[i]}/Contents/Info.plist.disable"
|
||||
fi
|
||||
done
|
||||
|
||||
# Enable default jdk
|
||||
if [[ -f "${DEFAULT_JVM_DIR}/Contents/Info.plist.disable" ]]; then
|
||||
sudo mv -vn "${DEFAULT_JVM_DIR}/Contents/Info.plist.disable" "${DEFAULT_JVM_DIR}/Contents/Info.plist" \
|
||||
&& echo "Enabled ${DEFAULT_JVM} as default JVM"
|
||||
fi
|
||||
}
|
||||
621
dot_bash_it/plugins/available/pack.plugin.bash
Normal file
621
dot_bash_it/plugins/available/pack.plugin.bash
Normal file
@@ -0,0 +1,621 @@
|
||||
# bash completion for pack -*- shell-script -*-
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'CNB pack cli aliases'
|
||||
|
||||
|
||||
__pack_debug()
|
||||
{
|
||||
if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
|
||||
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
|
||||
# _init_completion. This is a very minimal version of that function.
|
||||
__pack_init_completion()
|
||||
{
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref "$@" cur prev words cword
|
||||
}
|
||||
|
||||
__pack_index_of_word()
|
||||
{
|
||||
local w word=$1
|
||||
shift
|
||||
index=0
|
||||
for w in "$@"; do
|
||||
[[ $w = "$word" ]] && return
|
||||
index=$((index+1))
|
||||
done
|
||||
index=-1
|
||||
}
|
||||
|
||||
__pack_contains_word()
|
||||
{
|
||||
local w word=$1; shift
|
||||
for w in "$@"; do
|
||||
[[ $w = "$word" ]] && return
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
__pack_handle_reply()
|
||||
{
|
||||
__pack_debug "${FUNCNAME[0]}"
|
||||
case $cur in
|
||||
-*)
|
||||
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
local allflags
|
||||
if [ ${#must_have_one_flag[@]} -ne 0 ]; then
|
||||
allflags=("${must_have_one_flag[@]}")
|
||||
else
|
||||
allflags=("${flags[*]} ${two_word_flags[*]}")
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") )
|
||||
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||
[[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
|
||||
fi
|
||||
|
||||
# complete after --flag=abc
|
||||
if [[ $cur == *=* ]]; then
|
||||
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||
compopt +o nospace
|
||||
fi
|
||||
|
||||
local index flag
|
||||
flag="${cur%=*}"
|
||||
__pack_index_of_word "${flag}" "${flags_with_completion[@]}"
|
||||
COMPREPLY=()
|
||||
if [[ ${index} -ge 0 ]]; then
|
||||
PREFIX=""
|
||||
cur="${cur#*=}"
|
||||
${flags_completion[${index}]}
|
||||
if [ -n "${ZSH_VERSION}" ]; then
|
||||
# zsh completion needs --flag= prefix
|
||||
eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
return 0;
|
||||
;;
|
||||
esac
|
||||
|
||||
# check if we are handling a flag with special work handling
|
||||
local index
|
||||
__pack_index_of_word "${prev}" "${flags_with_completion[@]}"
|
||||
if [[ ${index} -ge 0 ]]; then
|
||||
${flags_completion[${index}]}
|
||||
return
|
||||
fi
|
||||
|
||||
# we are parsing a flag and don't have a special handler, no completion
|
||||
if [[ ${cur} != "${words[cword]}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local completions
|
||||
completions=("${commands[@]}")
|
||||
if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
|
||||
completions=("${must_have_one_noun[@]}")
|
||||
fi
|
||||
if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
|
||||
completions+=("${must_have_one_flag[@]}")
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") )
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
|
||||
COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") )
|
||||
fi
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
|
||||
declare -F __custom_func >/dev/null && __custom_func
|
||||
fi
|
||||
|
||||
# available in bash-completion >= 2, not always present on macOS
|
||||
if declare -F __ltrim_colon_completions >/dev/null; then
|
||||
__ltrim_colon_completions "$cur"
|
||||
fi
|
||||
|
||||
# If there is only 1 completion and it is a flag with an = it will be completed
|
||||
# but we don't want a space after the =
|
||||
if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
}
|
||||
|
||||
# The arguments should be in the form "ext1|ext2|extn"
|
||||
__pack_handle_filename_extension_flag()
|
||||
{
|
||||
local ext="$1"
|
||||
_filedir "@(${ext})"
|
||||
}
|
||||
|
||||
__pack_handle_subdirs_in_dir_flag()
|
||||
{
|
||||
local dir="$1"
|
||||
pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1
|
||||
}
|
||||
|
||||
__pack_handle_flag()
|
||||
{
|
||||
__pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
|
||||
|
||||
# if a command required a flag, and we found it, unset must_have_one_flag()
|
||||
local flagname=${words[c]}
|
||||
local flagvalue
|
||||
# if the word contained an =
|
||||
if [[ ${words[c]} == *"="* ]]; then
|
||||
flagvalue=${flagname#*=} # take in as flagvalue after the =
|
||||
flagname=${flagname%=*} # strip everything after the =
|
||||
flagname="${flagname}=" # but put the = back
|
||||
fi
|
||||
__pack_debug "${FUNCNAME[0]}: looking for ${flagname}"
|
||||
if __pack_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
|
||||
must_have_one_flag=()
|
||||
fi
|
||||
|
||||
# if you set a flag which only applies to this command, don't show subcommands
|
||||
if __pack_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
|
||||
commands=()
|
||||
fi
|
||||
|
||||
# keep flag value with flagname as flaghash
|
||||
# flaghash variable is an associative array which is only supported in bash > 3.
|
||||
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
|
||||
if [ -n "${flagvalue}" ] ; then
|
||||
flaghash[${flagname}]=${flagvalue}
|
||||
elif [ -n "${words[ $((c+1)) ]}" ] ; then
|
||||
flaghash[${flagname}]=${words[ $((c+1)) ]}
|
||||
else
|
||||
flaghash[${flagname}]="true" # pad "true" for bool flag
|
||||
fi
|
||||
fi
|
||||
|
||||
# skip the argument to a two word flag
|
||||
if __pack_contains_word "${words[c]}" "${two_word_flags[@]}"; then
|
||||
c=$((c+1))
|
||||
# if we are looking for a flags value, don't show commands
|
||||
if [[ $c -eq $cword ]]; then
|
||||
commands=()
|
||||
fi
|
||||
fi
|
||||
|
||||
c=$((c+1))
|
||||
|
||||
}
|
||||
|
||||
__pack_handle_noun()
|
||||
{
|
||||
__pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
|
||||
|
||||
if __pack_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
|
||||
must_have_one_noun=()
|
||||
elif __pack_contains_word "${words[c]}" "${noun_aliases[@]}"; then
|
||||
must_have_one_noun=()
|
||||
fi
|
||||
|
||||
nouns+=("${words[c]}")
|
||||
c=$((c+1))
|
||||
}
|
||||
|
||||
__pack_handle_command()
|
||||
{
|
||||
__pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
|
||||
|
||||
local next_command
|
||||
if [[ -n ${last_command} ]]; then
|
||||
next_command="_${last_command}_${words[c]//:/__}"
|
||||
else
|
||||
if [[ $c -eq 0 ]]; then
|
||||
next_command="_pack_root_command"
|
||||
else
|
||||
next_command="_${words[c]//:/__}"
|
||||
fi
|
||||
fi
|
||||
c=$((c+1))
|
||||
__pack_debug "${FUNCNAME[0]}: looking for ${next_command}"
|
||||
declare -F "$next_command" >/dev/null && $next_command
|
||||
}
|
||||
|
||||
__pack_handle_word()
|
||||
{
|
||||
if [[ $c -ge $cword ]]; then
|
||||
__pack_handle_reply
|
||||
return
|
||||
fi
|
||||
__pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
|
||||
if [[ "${words[c]}" == -* ]]; then
|
||||
__pack_handle_flag
|
||||
elif __pack_contains_word "${words[c]}" "${commands[@]}"; then
|
||||
__pack_handle_command
|
||||
elif [[ $c -eq 0 ]]; then
|
||||
__pack_handle_command
|
||||
elif __pack_contains_word "${words[c]}" "${command_aliases[@]}"; then
|
||||
# aliashash variable is an associative array which is only supported in bash > 3.
|
||||
if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
|
||||
words[c]=${aliashash[${words[c]}]}
|
||||
__pack_handle_command
|
||||
else
|
||||
__pack_handle_noun
|
||||
fi
|
||||
else
|
||||
__pack_handle_noun
|
||||
fi
|
||||
__pack_handle_word
|
||||
}
|
||||
|
||||
_pack_build()
|
||||
{
|
||||
last_command="pack_build"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--builder=")
|
||||
local_nonpersistent_flags+=("--builder=")
|
||||
flags+=("--buildpack=")
|
||||
local_nonpersistent_flags+=("--buildpack=")
|
||||
flags+=("--clear-cache")
|
||||
local_nonpersistent_flags+=("--clear-cache")
|
||||
flags+=("--env=")
|
||||
two_word_flags+=("-e")
|
||||
local_nonpersistent_flags+=("--env=")
|
||||
flags+=("--env-file=")
|
||||
local_nonpersistent_flags+=("--env-file=")
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-pull")
|
||||
local_nonpersistent_flags+=("--no-pull")
|
||||
flags+=("--path=")
|
||||
two_word_flags+=("-p")
|
||||
local_nonpersistent_flags+=("--path=")
|
||||
flags+=("--publish")
|
||||
local_nonpersistent_flags+=("--publish")
|
||||
flags+=("--run-image=")
|
||||
local_nonpersistent_flags+=("--run-image=")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_run()
|
||||
{
|
||||
last_command="pack_run"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--builder=")
|
||||
local_nonpersistent_flags+=("--builder=")
|
||||
flags+=("--buildpack=")
|
||||
local_nonpersistent_flags+=("--buildpack=")
|
||||
flags+=("--clear-cache")
|
||||
local_nonpersistent_flags+=("--clear-cache")
|
||||
flags+=("--env=")
|
||||
two_word_flags+=("-e")
|
||||
local_nonpersistent_flags+=("--env=")
|
||||
flags+=("--env-file=")
|
||||
local_nonpersistent_flags+=("--env-file=")
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-pull")
|
||||
local_nonpersistent_flags+=("--no-pull")
|
||||
flags+=("--path=")
|
||||
two_word_flags+=("-p")
|
||||
local_nonpersistent_flags+=("--path=")
|
||||
flags+=("--port=")
|
||||
local_nonpersistent_flags+=("--port=")
|
||||
flags+=("--run-image=")
|
||||
local_nonpersistent_flags+=("--run-image=")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_rebase()
|
||||
{
|
||||
last_command="pack_rebase"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-pull")
|
||||
local_nonpersistent_flags+=("--no-pull")
|
||||
flags+=("--publish")
|
||||
local_nonpersistent_flags+=("--publish")
|
||||
flags+=("--run-image=")
|
||||
local_nonpersistent_flags+=("--run-image=")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_create-builder()
|
||||
{
|
||||
last_command="pack_create-builder"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--builder-config=")
|
||||
two_word_flags+=("-b")
|
||||
local_nonpersistent_flags+=("--builder-config=")
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-pull")
|
||||
local_nonpersistent_flags+=("--no-pull")
|
||||
flags+=("--publish")
|
||||
local_nonpersistent_flags+=("--publish")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_flag+=("--builder-config=")
|
||||
must_have_one_flag+=("-b")
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_set-run-image-mirrors()
|
||||
{
|
||||
last_command="pack_set-run-image-mirrors"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--mirror=")
|
||||
two_word_flags+=("-m")
|
||||
local_nonpersistent_flags+=("--mirror=")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_flag+=("--mirror=")
|
||||
must_have_one_flag+=("-m")
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_inspect-builder()
|
||||
{
|
||||
last_command="pack_inspect-builder"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_set-default-builder()
|
||||
{
|
||||
last_command="pack_set-default-builder"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_version()
|
||||
{
|
||||
last_command="pack_version"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_completion()
|
||||
{
|
||||
last_command="pack_completion"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
_pack_root_command()
|
||||
{
|
||||
last_command="pack"
|
||||
|
||||
command_aliases=()
|
||||
|
||||
commands=()
|
||||
commands+=("build")
|
||||
commands+=("run")
|
||||
commands+=("rebase")
|
||||
commands+=("create-builder")
|
||||
commands+=("set-run-image-mirrors")
|
||||
commands+=("inspect-builder")
|
||||
commands+=("set-default-builder")
|
||||
commands+=("version")
|
||||
commands+=("completion")
|
||||
|
||||
flags=()
|
||||
two_word_flags=()
|
||||
local_nonpersistent_flags=()
|
||||
flags_with_completion=()
|
||||
flags_completion=()
|
||||
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
local_nonpersistent_flags+=("--help")
|
||||
flags+=("--no-color")
|
||||
flags+=("--quiet")
|
||||
flags+=("-q")
|
||||
flags+=("--timestamps")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_noun=()
|
||||
noun_aliases=()
|
||||
}
|
||||
|
||||
__start_pack()
|
||||
{
|
||||
local cur prev words cword
|
||||
declare -A flaghash 2>/dev/null || :
|
||||
declare -A aliashash 2>/dev/null || :
|
||||
if declare -F _init_completion >/dev/null 2>&1; then
|
||||
_init_completion -s || return
|
||||
else
|
||||
__pack_init_completion -n "=" || return
|
||||
fi
|
||||
|
||||
local c=0
|
||||
local flags=()
|
||||
local two_word_flags=()
|
||||
local local_nonpersistent_flags=()
|
||||
local flags_with_completion=()
|
||||
local flags_completion=()
|
||||
local commands=("pack")
|
||||
local must_have_one_flag=()
|
||||
local must_have_one_noun=()
|
||||
local last_command
|
||||
local nouns=()
|
||||
|
||||
__pack_handle_word
|
||||
}
|
||||
|
||||
if [[ $(type -t compopt) = "builtin" ]]; then
|
||||
complete -o default -F __start_pack pack
|
||||
else
|
||||
complete -o default -o nospace -F __start_pack pack
|
||||
fi
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
||||
32
dot_bash_it/plugins/available/percol.plugin.bash
Normal file
32
dot_bash_it/plugins/available/percol.plugin.bash
Normal file
@@ -0,0 +1,32 @@
|
||||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Search&Select history with percol'
|
||||
|
||||
# Notice
|
||||
## You have to upgrade bash to bash 4.x on Mac OS X.
|
||||
## http://stackoverflow.com/questions/16416195/how-do-i-upgrade-bash-in-mac-osx-mountain-lion-and-set-it-the-correct-path
|
||||
|
||||
# Install
|
||||
## (sudo) pip install percol
|
||||
## bash-it enable percol
|
||||
|
||||
# Usage
|
||||
## C-r to search&select from history
|
||||
|
||||
_command_exists percol || return
|
||||
|
||||
if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
|
||||
_log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin."
|
||||
_log_warning "Your current Bash version is $BASH_VERSION."
|
||||
return
|
||||
fi
|
||||
|
||||
function _replace_by_history() {
|
||||
local HISTTIMEFORMAT= # Ensure we can parse history properly
|
||||
#TODO: "${histlines[@]/*( )+([[:digit:]])*( )/}"
|
||||
local l
|
||||
l="$(history | tail -r | sed -e 's/^\ *[0-9]*\ *//' | percol --query "${READLINE_LINE:-}")"
|
||||
READLINE_LINE="${l}"
|
||||
READLINE_POINT=${#l}
|
||||
}
|
||||
bind -x '"\C-r": _replace_by_history'
|
||||
7
dot_bash_it/plugins/available/pipsi.plugin.bash
Normal file
7
dot_bash_it/plugins/available/pipsi.plugin.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
cite about-plugin
|
||||
about-plugin 'load pipsi, if you are using it'
|
||||
|
||||
if [[ -f "$HOME/.local/bin/pipsi" ]]
|
||||
then
|
||||
pathmunge ~/.local/bin
|
||||
fi
|
||||
16
dot_bash_it/plugins/available/plenv.plugin.bash
Normal file
16
dot_bash_it/plugins/available/plenv.plugin.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# plugin for plenv
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'plenv plugin for Perl'
|
||||
|
||||
if [[ -d "${HOME}/.plenv/bin" ]]; then
|
||||
# load plenv bin dir into path if it exists
|
||||
pathmunge "${HOME}/.plenv/bin"
|
||||
fi
|
||||
|
||||
if _command_exists plenv; then
|
||||
# init plenv
|
||||
eval "$(plenv init - bash)"
|
||||
fi
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user