Merge branch 'master' of https://github.com/bash-it/bash-it
commit
bf7d070516
|
|
@ -10,3 +10,6 @@ insert_final_newline = true
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[.git*]
|
||||||
|
indent_style = tab
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
[submodule "test_lib/bats-core"]
|
[submodule "test_lib/bats-core"]
|
||||||
path = test_lib/bats-core
|
path = test_lib/bats-core
|
||||||
url = https://github.com/bats-core/bats-core
|
url = https://github.com/bats-core/bats-core
|
||||||
|
branch = tags/v1.2.0
|
||||||
[submodule "test_lib/bats-support"]
|
[submodule "test_lib/bats-support"]
|
||||||
path = test_lib/bats-support
|
path = test_lib/bats-support
|
||||||
url = https://github.com/ztombol/bats-support
|
url = https://github.com/bats-core/bats-support
|
||||||
|
branch = tags/v0.3.0
|
||||||
[submodule "test_lib/bats-assert"]
|
[submodule "test_lib/bats-assert"]
|
||||||
path = test_lib/bats-assert
|
path = test_lib/bats-assert
|
||||||
url = https://github.com/ztombol/bats-assert
|
url = https://github.com/bats-core/bats-assert
|
||||||
|
branch = tags/v2.0.0
|
||||||
[submodule "test_lib/bats-file"]
|
[submodule "test_lib/bats-file"]
|
||||||
path = test_lib/bats-file
|
path = test_lib/bats-file
|
||||||
url = https://github.com/ztombol/bats-file
|
url = https://github.com/bats-core/bats-file
|
||||||
|
branch = tags/v0.3.0
|
||||||
|
|
|
||||||
23
.travis.yml
23
.travis.yml
|
|
@ -1,6 +1,17 @@
|
||||||
sudo: false
|
# YAML anchors need to appear first.
|
||||||
script: test/run
|
# Keys starting with an underscore are the custom ones, refer to
|
||||||
language: c
|
# https://docs.travis-ci.com/user/build-config-yaml#private-keys-as-yaml-anchors-and-aliases-and-external-tooling
|
||||||
os:
|
|
||||||
- linux
|
_native_job: &native_job
|
||||||
- osx
|
script: |
|
||||||
|
test/run
|
||||||
|
|
||||||
|
language: shell
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
- <<: *native_job
|
||||||
|
name: default Ubuntu
|
||||||
|
os: linux
|
||||||
|
- <<: *native_job
|
||||||
|
name: MacOS
|
||||||
|
os: osx
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# Bash-it
|
# Bash-it
|
||||||
|
|
||||||
[](https://travis-ci.org/Bash-it/bash-it) [](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://travis-ci.com/Bash-it/bash-it)
|
||||||
|
[](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
|
**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:)
|
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
cite about-alias
|
||||||
|
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"
|
||||||
|
|
@ -28,7 +28,6 @@ alias vbpf="vim ~/.bash_profile"
|
||||||
if grep --color=auto "a" "${BASH_IT}/"*.md &> /dev/null
|
if grep --color=auto "a" "${BASH_IT}/"*.md &> /dev/null
|
||||||
then
|
then
|
||||||
alias grep='grep --color=auto'
|
alias grep='grep --color=auto'
|
||||||
export GREP_COLOR='1;33'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which gshuf &> /dev/null
|
if which gshuf &> /dev/null
|
||||||
|
|
@ -75,27 +74,6 @@ fi
|
||||||
alias md='mkdir -p'
|
alias md='mkdir -p'
|
||||||
alias rd='rmdir'
|
alias rd='rmdir'
|
||||||
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Shorten extract
|
# Shorten extract
|
||||||
alias xt="extract"
|
alias xt="extract"
|
||||||
|
|
||||||
|
|
@ -113,3 +91,12 @@ catt() {
|
||||||
fi
|
fi
|
||||||
done
|
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=./bash-it.aliases.bash
|
||||||
|
source "$BASH_IT/aliases/available/bash-it.aliases.bash"
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,32 @@ alias gprom="git fetch origin master && git rebase origin/master && git update-r
|
||||||
alias gpunch="git push --force-with-lease"
|
alias gpunch="git push --force-with-lease"
|
||||||
alias ggui="git gui"
|
alias ggui="git gui"
|
||||||
alias gcsam="git commit -S -am"
|
alias gcsam="git commit -S -am"
|
||||||
|
# Stash aliases
|
||||||
alias gst="git stash"
|
alias gst="git stash"
|
||||||
alias gstb="git stash branch"
|
alias gstb="git stash branch"
|
||||||
alias gstd="git stash drop"
|
alias gstd="git stash drop"
|
||||||
alias gstl="git stash list"
|
alias gstl="git stash list"
|
||||||
|
# Push introduced in git v2.13.2
|
||||||
|
alias gstpu="git stash push"
|
||||||
|
alias gstpum="git stash push -m"
|
||||||
|
# Save deprecated since git v2.16.0
|
||||||
|
# - aliases now resolve to push
|
||||||
|
alias gsts="git stash push"
|
||||||
|
alias gstsm="git stash push -m"
|
||||||
|
# Alias gstpo added for symmetry with gstpu (push)
|
||||||
|
# - gstp remains as alias for pop due to long-standing usage
|
||||||
|
alias gstpo="git stash pop"
|
||||||
alias gstp="git stash pop"
|
alias gstp="git stash pop"
|
||||||
alias gh='cd "$(git rev-parse --show-toplevel)"'
|
# Switch aliases - Requires git v2.23+
|
||||||
|
alias gsw="git switch"
|
||||||
|
alias gswm="git switch master"
|
||||||
|
alias gswc="git switch --create"
|
||||||
|
alias gswt="git switch --track"
|
||||||
|
# Git home
|
||||||
|
alias ghm='cd "$(git rev-parse --show-toplevel)"'
|
||||||
|
if ! _command_exists gh; then
|
||||||
|
alias gh='ghm'
|
||||||
|
fi
|
||||||
# Show untracked files
|
# Show untracked files
|
||||||
alias gu='git ls-files . --exclude-standard --others'
|
alias gu='git ls-files . --exclude-standard --others'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,11 @@
|
||||||
cite 'about-alias'
|
cite 'about-alias'
|
||||||
about-alias 'kubectl aliases'
|
about-alias 'kubectl aliases'
|
||||||
|
|
||||||
# set apt aliases
|
|
||||||
function _set_pkg_aliases()
|
function _set_pkg_aliases()
|
||||||
{
|
{
|
||||||
if [ -x $(which kubectl) ]; then
|
if _command_exists kubectl; then
|
||||||
alias kc='kubectl'
|
alias kc='kubectl'
|
||||||
alias kcgp='kubectl get pods'
|
alias kcgp='kubectl get pods'
|
||||||
alias kcgd='kubectl get deployments'
|
alias kcgd='kubectl get deployments'
|
||||||
alias kcgn='kubectl get nodes'
|
alias kcgn='kubectl get nodes'
|
||||||
alias kcdp='kubectl describe pod'
|
alias kcdp='kubectl describe pod'
|
||||||
|
|
@ -18,8 +17,9 @@ function _set_pkg_aliases()
|
||||||
alias kcdn='kubectl describe node'
|
alias kcdn='kubectl describe node'
|
||||||
alias kcgpan='kubectl get pods --all-namespaces'
|
alias kcgpan='kubectl get pods --all-namespaces'
|
||||||
alias kcgdan='kubectl get deployments --all-namespaces'
|
alias kcgdan='kubectl get deployments --all-namespaces'
|
||||||
alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(uuidgen | tr A-Z a-z | sed 's/-//g') --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
|
# launches a disposable netshoot pod in the k8s cluster
|
||||||
fi
|
alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_set_pkg_aliases
|
_set_pkg_aliases
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
cite 'uuid-alias'
|
cite 'uuid-alias'
|
||||||
about-alias 'uuidgen aliases'
|
about-alias 'uuidgen aliases'
|
||||||
|
|
||||||
alias uuidu="uuidgen"
|
if _command_exists uuid; then # Linux
|
||||||
alias uuidl="uuidgen | tr '[:upper:]' '[:lower:]'"
|
alias uuidu="uuid | tr '[:lower:]' '[:upper:]'"
|
||||||
alias uuid=uuidl # because upper case is like YELLING
|
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
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1 @@
|
||||||
|
_command_exists minishift && source <(minishift completion bash)
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
|
||||||
. <(ng completion --bash)
|
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
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
#!/usr/bin/env bash
|
_command_exists oc && source <(oc completion bash)
|
||||||
|
|
||||||
[ -x "$(which oc)" ] && eval "$(oc completion bash)"
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ function __awskeys_help {
|
||||||
function __awskeys_get {
|
function __awskeys_get {
|
||||||
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
|
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
|
||||||
if [[ -n "${ln}" ]]; then
|
if [[ -n "${ln}" ]]; then
|
||||||
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ function myip ()
|
||||||
list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/")
|
list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/")
|
||||||
for url in ${list[*]}
|
for url in ${list[*]}
|
||||||
do
|
do
|
||||||
res=$(curl -s "${url}")
|
res=$(curl -fs "${url}")
|
||||||
if [ $? -eq 0 ];then
|
if [ $? -eq 0 ];then
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,28 @@ End-Of-Usage
|
||||||
|
|
||||||
[ $# -eq 0 ] && extract -h && return 1
|
[ $# -eq 0 ] && extract -h && return 1
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
if [ -f "$1" ]; then
|
if [[ ! -f "$1" ]]; then
|
||||||
case "$1" in
|
echo "extract: '$1' is not a valid file" >&2
|
||||||
*.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" ;;
|
shift
|
||||||
*.tar.gz|*.tgz) tar "x${verbose}zf" "$1" ;;
|
continue
|
||||||
*.tar.xz) xz --decompress "$1"; set -- "$@" "${1:0:-3}" ;;
|
fi
|
||||||
*.tar.Z) uncompress "$1"; set -- "$@" "${1:0:-2}" ;;
|
|
||||||
|
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$\)//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" ;;
|
*.bz2) bunzip2 "$1" ;;
|
||||||
*.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;;
|
*.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;;
|
||||||
*.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;;
|
*.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;;
|
||||||
|
|
@ -43,17 +59,15 @@ End-Of-Usage
|
||||||
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
|
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
|
||||||
*.rar) unrar x "$1" ;;
|
*.rar) unrar x "$1" ;;
|
||||||
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
|
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
|
||||||
*.tar) tar "x${verbose}f" "$1" ;;
|
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
*.txz) mv "$1" "${1:0:-4}.tar.xz"; set -- "$@" "${1:0:-4}.tar.xz" ;;
|
|
||||||
*.xz) xz --decompress "$1" ;;
|
*.xz) xz --decompress "$1" ;;
|
||||||
*.zip|*.war|*.jar) unzip "$1" ;;
|
*.zip|*.war|*.jar) unzip "$1" ;;
|
||||||
*.Z) uncompress "$1" ;;
|
*.Z) uncompress "$1" ;;
|
||||||
*.7z) 7za x "$1" ;;
|
*.7z) 7za x "$1" ;;
|
||||||
*) echo "'$1' cannot be extracted via extract" >&2;;
|
*) echo "'$1' cannot be extracted via extract" >&2;;
|
||||||
esac
|
esac
|
||||||
else
|
fi
|
||||||
echo "extract: '$1' is not a valid file" >&2
|
|
||||||
fi
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
cite about-plugin
|
||||||
|
about-plugin 'load fasd, if you are using it'
|
||||||
|
|
||||||
|
_command_exists fasd || return
|
||||||
|
|
||||||
|
eval "$(fasd --init auto)"
|
||||||
|
|
@ -3,8 +3,10 @@ about-plugin 'load goenv, if you are using it'
|
||||||
|
|
||||||
# Don't modify the environment if we can't find the tool:
|
# Don't modify the environment if we can't find the tool:
|
||||||
# - Check if in $PATH already
|
# - Check if in $PATH already
|
||||||
|
# - Check if installed manually to $GOENV_ROOT
|
||||||
# - Check if installed manually to $HOME
|
# - Check if installed manually to $HOME
|
||||||
_command_exists goenv ||
|
_command_exists goenv ||
|
||||||
|
[[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] ||
|
||||||
[[ -x "$HOME/.goenv/bin/goenv" ]] ||
|
[[ -x "$HOME/.goenv/bin/goenv" ]] ||
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -12,7 +14,7 @@ _command_exists goenv ||
|
||||||
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
|
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
|
||||||
|
|
||||||
# Add GOENV_ROOT/bin to PATH, if that's where it's installed
|
# Add GOENV_ROOT/bin to PATH, if that's where it's installed
|
||||||
[[ -x "$HOME/.goenv/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin"
|
! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin"
|
||||||
|
|
||||||
# Initialize goenv
|
# Initialize goenv
|
||||||
eval "$(goenv init - bash)"
|
eval "$(goenv init - bash)"
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ function _ensure_valid_sshagent_env() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "There's a dead ssh-agent at the landing..."
|
|
||||||
ssh-agent > "${SSH_AGENT_ENV}"
|
ssh-agent > "${SSH_AGENT_ENV}"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +124,7 @@ function sshagent() {
|
||||||
about 'ensures ssh-agent is up and running'
|
about 'ensures ssh-agent is up and running'
|
||||||
param '1: on|off '
|
param '1: on|off '
|
||||||
example '$ sshagent on'
|
example '$ sshagent on'
|
||||||
group 'ssh'
|
group 'ssh'
|
||||||
[[ -z "${SSH_AGENT_ENV}" ]] \
|
[[ -z "${SSH_AGENT_ENV}" ]] \
|
||||||
&& export SSH_AGENT_ENV="${HOME}/.ssh/agent_env.${HOSTNAME}"
|
&& export SSH_AGENT_ENV="${HOME}/.ssh/agent_env.${HOSTNAME}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
cite about-plugin
|
||||||
|
about-plugin 'Toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice'
|
||||||
|
|
||||||
|
function sudo-command-line() {
|
||||||
|
about "toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice"
|
||||||
|
group "sudo"
|
||||||
|
|
||||||
|
[[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs)
|
||||||
|
if [[ $READLINE_LINE == sudo\ * ]]; then
|
||||||
|
READLINE_LINE="${READLINE_LINE#sudo }"
|
||||||
|
else
|
||||||
|
READLINE_LINE="sudo $READLINE_LINE"
|
||||||
|
fi
|
||||||
|
READLINE_POINT=${#READLINE_LINE}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define shortcut keys: [Esc] [Esc]
|
||||||
|
|
||||||
|
# Readline library requires bash version 4 or later
|
||||||
|
if [ "${BASH_VERSINFO}" -ge 4 ]; then
|
||||||
|
bind -x '"\e\e": sudo-command-line'
|
||||||
|
fi
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
cite about-plugin
|
|
||||||
about-plugin 'Defines the `code` executable for Visual Studio Code on OS X'
|
|
||||||
|
|
||||||
# Based on https://code.visualstudio.com/Docs/editor/setup
|
|
||||||
if [[ `uname -s` == "Darwin" ]]; then
|
|
||||||
function code () {
|
|
||||||
about 'Starts Visual Studio Code in the provided directory'
|
|
||||||
group 'visual-studio-code'
|
|
||||||
|
|
||||||
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
@ -3,7 +3,7 @@ about-plugin 'automatically set your xterm title with host and location info'
|
||||||
|
|
||||||
|
|
||||||
_short-dirname () {
|
_short-dirname () {
|
||||||
local dir_name=`dirs -0`
|
local dir_name=`dirs +0`
|
||||||
[ "$SHORT_TERM_LINE" = true ] && [ ${#dir_name} -gt 8 ] && echo ${dir_name##*/} || echo $dir_name
|
[ "$SHORT_TERM_LINE" = true ] && [ ${#dir_name} -gt 8 ] && echo ${dir_name##*/} || echo $dir_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
## Testing with [Bats](https://github.com/sstephenson/bats#installing-bats-from-source)
|
# Testing with Bats
|
||||||
|
|
||||||
|
## 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:
|
To execute the unit tests, please run the `run` script:
|
||||||
|
|
||||||
|
|
@ -10,4 +19,22 @@ To execute the unit tests, please run the `run` script:
|
||||||
test/run
|
test/run
|
||||||
```
|
```
|
||||||
|
|
||||||
The `run` script will automatically install [Bats](https://github.com/sstephenson/bats#installing-bats-from-source) if it is not already present, and will then run all tests found under the `test` directory, including subdirectories.
|
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:
|
||||||
|
|
||||||
|
```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.
|
||||||
|
|
|
||||||
|
|
@ -4,36 +4,17 @@ load ../test_helper
|
||||||
load ../../lib/composure
|
load ../../lib/composure
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
echo "Bi : $BASH_IT"
|
|
||||||
echo "Lib: $lib_directory"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
# Copy the test fixture to the Bash-it folder
|
# Copy the test fixture to the Bash-it folder
|
||||||
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
if command -v rsync &> /dev/null
|
||||||
|
then
|
||||||
# Don't pollute the user's actual $HOME directory
|
rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/"
|
||||||
# Use a test home directory instead
|
else
|
||||||
export BASH_IT_TEST_CURRENT_HOME="${HOME}"
|
find "$BASH_IT/test/fixtures/bash_it" \
|
||||||
export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME"
|
-mindepth 1 -maxdepth 1 \
|
||||||
mkdir -p "${BASH_IT_TEST_HOME}"
|
-exec cp -r {} "$BASH_IT/" \;
|
||||||
export HOME="${BASH_IT_TEST_HOME}"
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export HOME="${BASH_IT_TEST_CURRENT_HOME}"
|
|
||||||
|
|
||||||
rm -rf "${BASH_IT_TEST_HOME}"
|
|
||||||
|
|
||||||
assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "bash-it: verify that the test fixture is available" {
|
@test "bash-it: verify that the test fixture is available" {
|
||||||
|
|
|
||||||
|
|
@ -5,36 +5,7 @@ load ../../lib/composure
|
||||||
load ../../completion/available/bash-it.completion
|
load ../../completion/available/bash-it.completion
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
# Don't pollute the user's actual $HOME directory
|
|
||||||
# Use a test home directory instead
|
|
||||||
export BASH_IT_TEST_CURRENT_HOME="${HOME}"
|
|
||||||
export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME"
|
|
||||||
mkdir -p "${BASH_IT_TEST_HOME}"
|
|
||||||
export HOME="${BASH_IT_TEST_HOME}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export HOME="${BASH_IT_TEST_CURRENT_HOME}"
|
|
||||||
|
|
||||||
rm -rf "${BASH_IT_TEST_HOME}"
|
|
||||||
|
|
||||||
assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "completion bash-it: ensure that the _bash-it-comp function is available" {
|
@test "completion bash-it: ensure that the _bash-it-comp function is available" {
|
||||||
|
|
|
||||||
|
|
@ -14,31 +14,7 @@ case $OSTYPE in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
# Don't pollute the user's actual $HOME directory
|
|
||||||
# Use a test home directory instead
|
|
||||||
export BASH_IT_TEST_CURRENT_HOME="${HOME}"
|
|
||||||
export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME"
|
|
||||||
mkdir -p "${BASH_IT_TEST_HOME}"
|
|
||||||
export HOME="${BASH_IT_TEST_HOME}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export HOME="${BASH_IT_TEST_CURRENT_HOME}"
|
|
||||||
|
|
||||||
rm -rf "${BASH_IT_TEST_HOME}"
|
|
||||||
|
|
||||||
assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install: verify that the install script exists" {
|
@test "install: verify that the install script exists" {
|
||||||
|
|
|
||||||
|
|
@ -14,31 +14,7 @@ case $OSTYPE in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
# Don't pollute the user's actual $HOME directory
|
|
||||||
# Use a test home directory instead
|
|
||||||
export BASH_IT_TEST_CURRENT_HOME="${HOME}"
|
|
||||||
export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME"
|
|
||||||
mkdir -p "${BASH_IT_TEST_HOME}"
|
|
||||||
export HOME="${BASH_IT_TEST_HOME}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function local_teardown {
|
|
||||||
export HOME="${BASH_IT_TEST_CURRENT_HOME}"
|
|
||||||
|
|
||||||
rm -rf "${BASH_IT_TEST_HOME}"
|
|
||||||
|
|
||||||
assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "uninstall: verify that the uninstall script exists" {
|
@test "uninstall: verify that the uninstall script exists" {
|
||||||
|
|
|
||||||
|
|
@ -11,21 +11,7 @@ cite _about _param _example _group _author _version
|
||||||
load ../../lib/helpers
|
load ../../lib/helpers
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO Create global __is_enabled function
|
# TODO Create global __is_enabled function
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ load ../../lib/composure
|
||||||
load ../../lib/helpers
|
load ../../lib/helpers
|
||||||
load ../../lib/utilities
|
load ../../lib/utilities
|
||||||
load ../../lib/search
|
load ../../lib/search
|
||||||
|
|
||||||
|
cite _about _param _example _group _author _version
|
||||||
|
|
||||||
load ../../plugins/available/base.plugin
|
load ../../plugins/available/base.plugin
|
||||||
load ../../aliases/available/git.aliases
|
load ../../aliases/available/git.aliases
|
||||||
load ../../plugins/available/ruby.plugin
|
load ../../plugins/available/ruby.plugin
|
||||||
|
|
@ -13,27 +16,10 @@ load ../../completion/available/bundler.completion
|
||||||
load ../../completion/available/gem.completion
|
load ../../completion/available/gem.completion
|
||||||
load ../../completion/available/rake.completion
|
load ../../completion/available/rake.completion
|
||||||
|
|
||||||
cite _about _param _example _group _author _version
|
|
||||||
|
|
||||||
load ../../lib/helpers
|
load ../../lib/helpers
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
rm -rf "$BASH_IT"/tmp/cache
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
export OLD_PATH="$PATH"
|
||||||
export PATH="/usr/bin:/bin:/usr/sbin"
|
export PATH="/usr/bin:/bin:/usr/sbin"
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,7 @@ load ../../lib/search
|
||||||
cite _about _param _example _group _author _version
|
cite _about _param _example _group _author _version
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
rm -rf "$BASH_IT"/tmp/cache
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function has_match() {
|
function has_match() {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ load ../../plugins/available/base.plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins base: myip()' {
|
@test 'plugins base: myip()' {
|
||||||
if [[ ! $SLOW_TESTS ]]; then
|
|
||||||
skip 'myip is slow - run only with SLOW_TESTS=true'
|
|
||||||
fi
|
|
||||||
|
|
||||||
run myip
|
run myip
|
||||||
assert_success
|
assert_success
|
||||||
declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?')
|
declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?')
|
||||||
|
|
@ -43,7 +39,7 @@ load ../../plugins/available/base.plugin
|
||||||
|
|
||||||
mkcd "${dir_name}"
|
mkcd "${dir_name}"
|
||||||
assert_success
|
assert_success
|
||||||
assert_file_exist "${BASH_IT_ROOT}/${dir_name}"
|
assert_dir_exist "${BASH_IT_ROOT}/${dir_name}"
|
||||||
assert_equal $(pwd) "${BASH_IT_ROOT}/${dir_name}"
|
assert_equal $(pwd) "${BASH_IT_ROOT}/${dir_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ load ../../lib/helpers
|
||||||
load ../../lib/composure
|
load ../../lib/composure
|
||||||
|
|
||||||
@test 'ensure _go_pathmunge_wrap is defined' {
|
@test 'ensure _go_pathmunge_wrap is defined' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
run type -t _go_pathmunge_wrap
|
run type -t _go_pathmunge_wrap
|
||||||
assert_line 'function'
|
assert_line 'function'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: single entry in GOPATH' {
|
@test 'plugins go: single entry in GOPATH' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo"
|
export GOPATH="/foo"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
@ -18,6 +20,7 @@ load ../../lib/composure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: single entry in GOPATH, with space' {
|
@test 'plugins go: single entry in GOPATH, with space' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo bar"
|
export GOPATH="/foo bar"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
@ -25,6 +28,7 @@ load ../../lib/composure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: single entry in GOPATH, with escaped space' {
|
@test 'plugins go: single entry in GOPATH, with escaped space' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo\ bar"
|
export GOPATH="/foo\ bar"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
@ -32,6 +36,7 @@ load ../../lib/composure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: multiple entries in GOPATH' {
|
@test 'plugins go: multiple entries in GOPATH' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo:/bar"
|
export GOPATH="/foo:/bar"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
@ -39,6 +44,7 @@ load ../../lib/composure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: multiple entries in GOPATH, with space' {
|
@test 'plugins go: multiple entries in GOPATH, with space' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo:/foo bar"
|
export GOPATH="/foo:/foo bar"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
@ -46,6 +52,7 @@ load ../../lib/composure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'plugins go: multiple entries in GOPATH, with escaped space' {
|
@test 'plugins go: multiple entries in GOPATH, with escaped space' {
|
||||||
|
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||||
export GOPATH="/foo:/foo\ bar"
|
export GOPATH="/foo:/foo\ bar"
|
||||||
export GOROOT="/baz"
|
export GOROOT="/baz"
|
||||||
load ../../plugins/available/go.plugin
|
load ../../plugins/available/go.plugin
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,7 @@ load ../../lib/composure
|
||||||
load ../../plugins/available/ruby.plugin
|
load ../../plugins/available/ruby.plugin
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
mkdir -p "$BASH_IT"
|
setup_test_fixture
|
||||||
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
# Use rsync to copy Bash-it to the temp folder
|
|
||||||
# rsync is faster than cp, since we can exclude the large ".git" folder
|
|
||||||
rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT"
|
|
||||||
|
|
||||||
rm -rf "$BASH_IT"/enabled
|
|
||||||
rm -rf "$BASH_IT"/aliases/enabled
|
|
||||||
rm -rf "$BASH_IT"/completion/enabled
|
|
||||||
rm -rf "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
mkdir -p "$BASH_IT"/enabled
|
|
||||||
mkdir -p "$BASH_IT"/aliases/enabled
|
|
||||||
mkdir -p "$BASH_IT"/completion/enabled
|
|
||||||
mkdir -p "$BASH_IT"/plugins/enabled
|
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
export OLD_PATH="$PATH"
|
||||||
export PATH="/usr/bin:/bin:/usr/sbin"
|
export PATH="/usr/bin:/bin:/usr/sbin"
|
||||||
|
|
|
||||||
31
test/run
31
test/run
|
|
@ -16,4 +16,33 @@ else
|
||||||
test_dirs=( "$1" )
|
test_dirs=( "$1" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec $bats_executable ${CI:+--tap} "${test_dirs[@]}"
|
# Make sure that the `parallel` command is installed,
|
||||||
|
# AND that it is the GNU version of `parallel`.
|
||||||
|
# If that is the case, try to guess the number of CPU cores,
|
||||||
|
# so we can run `bats` in parallel processing mode, which is a lot faster.
|
||||||
|
if command -v parallel &> /dev/null \
|
||||||
|
&& parallel -V &> /dev/null \
|
||||||
|
&& { parallel -V 2> /dev/null | grep -q '^GNU\>'; }
|
||||||
|
then
|
||||||
|
# Expect to run at least on a dual-core CPU; slightly degraded performance
|
||||||
|
# shouldn't matter otherwise.
|
||||||
|
declare -i -r test_jobs_default=2
|
||||||
|
declare -i -r test_jobs_effective="$(
|
||||||
|
if [ "${TEST_JOBS:-detect}" = "detect" ] \
|
||||||
|
&& command -v nproc &> /dev/null
|
||||||
|
then
|
||||||
|
nproc
|
||||||
|
elif [ -n "${TEST_JOBS}" ] \
|
||||||
|
&& [ "${TEST_JOBS}" != "detect" ]
|
||||||
|
then
|
||||||
|
echo "${TEST_JOBS}"
|
||||||
|
else
|
||||||
|
echo ${test_jobs_default}
|
||||||
|
fi
|
||||||
|
)"
|
||||||
|
exec "$bats_executable" ${CI:+--tap} --jobs ${test_jobs_effective} \
|
||||||
|
"${test_dirs[@]}"
|
||||||
|
else
|
||||||
|
# Run `bats` in single-threaded mode.
|
||||||
|
exec "$bats_executable" ${CI:+--tap} "${test_dirs[@]}"
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,12 @@ unset TODO
|
||||||
unset SCM_CHECK
|
unset SCM_CHECK
|
||||||
unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE
|
unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE
|
||||||
|
|
||||||
BASH_IT_TEST_DIR="${BATS_TMPDIR}/.bash_it"
|
|
||||||
|
|
||||||
# guard against executing this block twice due to bats internals
|
|
||||||
if [ "$BASH_IT_ROOT" != "${BASH_IT_TEST_DIR}/root" ]; then
|
|
||||||
export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root"
|
|
||||||
export BASH_IT=$BASH_IT_TEST_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.."
|
export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.."
|
||||||
export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}"
|
export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}"
|
||||||
|
|
||||||
|
# be independent of git's system configuration
|
||||||
|
export GIT_CONFIG_NOSYSTEM
|
||||||
|
|
||||||
load "${TEST_DEPS_DIR}/bats-support/load.bash"
|
load "${TEST_DEPS_DIR}/bats-support/load.bash"
|
||||||
load "${TEST_DEPS_DIR}/bats-assert/load.bash"
|
load "${TEST_DEPS_DIR}/bats-assert/load.bash"
|
||||||
load "${TEST_DEPS_DIR}/bats-file/load.bash"
|
load "${TEST_DEPS_DIR}/bats-file/load.bash"
|
||||||
|
|
@ -29,9 +24,70 @@ local_teardown() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function sets up a local test fixture, i.e. a completely
|
||||||
|
# fresh and isolated Bash-it directory. This is done to avoid
|
||||||
|
# messing with your own Bash-it source directory.
|
||||||
|
# If you need this, call it in your .bats file's `local_setup` function.
|
||||||
|
setup_test_fixture() {
|
||||||
|
mkdir -p "$BASH_IT"
|
||||||
|
lib_directory="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
local src_topdir="$lib_directory/../../../.."
|
||||||
|
|
||||||
|
if command -v rsync &> /dev/null
|
||||||
|
then
|
||||||
|
# Use rsync to copy Bash-it to the temp folder
|
||||||
|
rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled "$src_topdir" "$BASH_IT"
|
||||||
|
else
|
||||||
|
rm -rf "$BASH_IT"
|
||||||
|
mkdir -p "$BASH_IT"
|
||||||
|
|
||||||
|
find "$src_topdir" \
|
||||||
|
-mindepth 1 -maxdepth 1 \
|
||||||
|
-not -name .git \
|
||||||
|
-exec cp -r {} "$BASH_IT" \;
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$BASH_IT"/enabled
|
||||||
|
rm -rf "$BASH_IT"/aliases/enabled
|
||||||
|
rm -rf "$BASH_IT"/completion/enabled
|
||||||
|
rm -rf "$BASH_IT"/plugins/enabled
|
||||||
|
|
||||||
|
mkdir -p "$BASH_IT"/enabled
|
||||||
|
mkdir -p "$BASH_IT"/aliases/enabled
|
||||||
|
mkdir -p "$BASH_IT"/completion/enabled
|
||||||
|
mkdir -p "$BASH_IT"/plugins/enabled
|
||||||
|
|
||||||
|
# Some tests use the BASH_IT_TEST_HOME variable, e.g. install/uninstall
|
||||||
|
export BASH_IT_TEST_HOME="$TEST_TEMP_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
# The `temp_make` function from "bats-file" requires the tralston/bats-file fork,
|
||||||
|
# since the original ztombol/bats-file's `temp_make` does not work on macOS.
|
||||||
|
TEST_TEMP_DIR="$(temp_make --prefix 'bash-it-test-')"
|
||||||
|
export TEST_TEMP_DIR
|
||||||
|
|
||||||
|
export BASH_IT_TEST_DIR="${TEST_TEMP_DIR}/.bash_it"
|
||||||
|
|
||||||
|
export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root"
|
||||||
|
export BASH_IT=$BASH_IT_TEST_DIR
|
||||||
|
|
||||||
mkdir -p -- "${BASH_IT_ROOT}"
|
mkdir -p -- "${BASH_IT_ROOT}"
|
||||||
|
|
||||||
|
# Some tools, e.g. `git` use configuration files from the $HOME directory,
|
||||||
|
# which interferes with our tests. The only way to keep `git` from doing this
|
||||||
|
# seems to set HOME explicitly to a separate location.
|
||||||
|
# Refer to https://git-scm.com/docs/git-config#FILES.
|
||||||
|
unset XDG_CONFIG_HOME
|
||||||
|
export HOME="${TEST_TEMP_DIR}"
|
||||||
|
mkdir -p "${HOME}"
|
||||||
|
|
||||||
|
# For `git` tests to run well, user name and email need to be set.
|
||||||
|
# Refer to https://git-scm.com/docs/git-commit#_commit_information.
|
||||||
|
# This goes to the test-specific config, due to the $HOME overridden above.
|
||||||
|
git config --global user.name "John Doe"
|
||||||
|
git config --global user.email "johndoe@example.com"
|
||||||
|
|
||||||
local_setup
|
local_setup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,49 +95,5 @@ teardown() {
|
||||||
local_teardown
|
local_teardown
|
||||||
|
|
||||||
rm -rf "${BASH_IT_TEST_DIR}"
|
rm -rf "${BASH_IT_TEST_DIR}"
|
||||||
}
|
temp_del "${TEST_TEMP_DIR}"
|
||||||
|
|
||||||
# Fail and display path of the link if it does not exist. Also fails
|
|
||||||
# if the path exists, but is not a link.
|
|
||||||
# This function is the logical complement of `assert_file_not_exist'.
|
|
||||||
# There is no dedicated function for checking that a link does not exist.
|
|
||||||
#
|
|
||||||
# Globals:
|
|
||||||
# BATSLIB_FILE_PATH_REM
|
|
||||||
# BATSLIB_FILE_PATH_ADD
|
|
||||||
# Arguments:
|
|
||||||
# $1 - path
|
|
||||||
# Returns:
|
|
||||||
# 0 - link exists and is a link
|
|
||||||
# 1 - otherwise
|
|
||||||
# Outputs:
|
|
||||||
# STDERR - details, on failure
|
|
||||||
assert_link_exist() {
|
|
||||||
local -r file="$1"
|
|
||||||
local -r target="$2"
|
|
||||||
if [[ ! -L "$file" ]]; then
|
|
||||||
local -r rem="$BATSLIB_FILE_PATH_REM"
|
|
||||||
local -r add="$BATSLIB_FILE_PATH_ADD"
|
|
||||||
if [[ -e "$file" ]]; then
|
|
||||||
batslib_print_kv_single 4 'path' "${file/$rem/$add}" \
|
|
||||||
| batslib_decorate 'exists, but is not a link' \
|
|
||||||
| fail
|
|
||||||
else
|
|
||||||
batslib_print_kv_single 4 'path' "${file/$rem/$add}" \
|
|
||||||
| batslib_decorate 'link does not exist' \
|
|
||||||
| fail
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -n "$target" ]; then
|
|
||||||
local link_target=''
|
|
||||||
link_target=$(readlink "$file")
|
|
||||||
if [[ "$link_target" != "$target" ]]; then
|
|
||||||
batslib_print_kv_single_or_multi 8 'path' "${file/$rem/$add}" \
|
|
||||||
'expected' "$target" \
|
|
||||||
'actual' "$link_target" \
|
|
||||||
| batslib_decorate 'link exists, but does not point to target file' \
|
|
||||||
| fail
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9f88b4207da750093baabc4e3f41bf68f0dd3630
|
Subproject commit d750c5a1b44bf6fc96726aea76f4621db5fd602f
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 85388685632f85d5a1c32e6bca2deec401964cf7
|
Subproject commit 73b8d2f95513207b319efe34685553b75c0b214e
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2fddb2b831d65cdf2e411f3b47f4677fbb15729c
|
Subproject commit c128a1de53ba4a811835af410ce427f1049e2d7f
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 004e707638eedd62e0481e8cdc9223ad471f12ee
|
Subproject commit 24a72e14349690bcbf7c151b9d2d1cdd32d36eb1
|
||||||
|
|
@ -194,7 +194,7 @@ ___atomic_prompt_char() {
|
||||||
color=$white
|
color=$white
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
||||||
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
||||||
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
if sudo -vn 1>/dev/null 2>&1; then
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,75 @@ A minimal theme with a clean git prompt
|
||||||
* Current path (red when user is root)
|
* Current path (red when user is root)
|
||||||
* Current git info
|
* Current git info
|
||||||
* Last command exit code (only shown when the exit code is greater than 0)
|
* Last command exit code (only shown when the exit code is greater than 0)
|
||||||
|
* user@hostname for ssh connection
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
```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=' '
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customize glyphs
|
||||||
|
|
||||||
|
Define your custom glyphs before sourcing bash-it:
|
||||||
|
|
||||||
|
```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`.
|
||||||
|
|
||||||
|
```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
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat << EOF > /etc/sudoers.d/keepenv
|
||||||
|
Defaults env_keep += HOME
|
||||||
|
Defaults env_keep += SSH_CONNECTION
|
||||||
|
EOF
|
||||||
|
chmod 400 /etc/sudoers.d/keepenv
|
||||||
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|
@ -21,4 +90,10 @@ A minimal theme with a clean git prompt
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
~/.dotfiles on master ⤏ origin ↑2 •7 ✗ ❯
|
~/.dotfiles on master ⤏ origin ↑2 •7 ✗ ❯
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Ssh
|
||||||
|
|
||||||
|
```bash
|
||||||
|
user@hostname in ~/bash-it on master ✓ ❯
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,21 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=2034,2154
|
# shellcheck disable=2034,2154
|
||||||
|
|
||||||
SCM_GIT_CHAR_GITLAB=' '
|
# Theme custom glyphs
|
||||||
SCM_GIT_CHAR_BITBUCKET=' '
|
SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '}
|
||||||
SCM_GIT_CHAR_GITHUB=' '
|
SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '}
|
||||||
SCM_GIT_CHAR_DEFAULT=' '
|
SCM_GIT_CHAR_GITHUB=${BARBUK_GITHUB_CHAR:=' '}
|
||||||
SCM_GIT_CHAR_ICON_BRANCH=''
|
SCM_GIT_CHAR_DEFAULT=${BARBUK_GIT_DEFAULT_CHAR:=' '}
|
||||||
SCM_HG_CHAR='☿ '
|
SCM_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''}
|
||||||
SCM_SVN_CHAR='⑆ '
|
SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '}
|
||||||
|
SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '}
|
||||||
|
EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '}
|
||||||
|
|
||||||
|
# Ssh user and hostname display
|
||||||
|
SSH_INFO=${BARBUK_SSH_INFO:=true}
|
||||||
|
HOST_INFO=${BARBUK_HOST_INFO:=long}
|
||||||
|
|
||||||
|
# Bash-it default glyphs customization
|
||||||
SCM_NONE_CHAR=
|
SCM_NONE_CHAR=
|
||||||
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗"
|
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗"
|
||||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||||
|
|
@ -25,10 +33,9 @@ GIT_THEME_PROMPT_SUFFIX="${cyan}"
|
||||||
SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}"
|
SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}"
|
||||||
SCM_THEME_CURRENT_USER_PREFFIX=' '
|
SCM_THEME_CURRENT_USER_PREFFIX=' '
|
||||||
SCM_GIT_SHOW_CURRENT_USER=false
|
SCM_GIT_SHOW_CURRENT_USER=false
|
||||||
EXIT_CODE_ICON=' '
|
|
||||||
|
|
||||||
function _git-uptream-remote-logo {
|
function _git-uptream-remote-logo {
|
||||||
[[ "$(_git-upstream)" == "" ]] && return
|
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"
|
||||||
|
|
||||||
local remote remote_domain
|
local remote remote_domain
|
||||||
remote=$(_git-upstream-remote)
|
remote=$(_git-upstream-remote)
|
||||||
|
|
@ -59,7 +66,7 @@ function _exit-code {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _prompt {
|
function _prompt {
|
||||||
local exit_code="$?" wrap_char=' ' dir_color=$green
|
local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' host
|
||||||
|
|
||||||
_exit-code exit_code
|
_exit-code exit_code
|
||||||
_git-uptream-remote-logo
|
_git-uptream-remote-logo
|
||||||
|
|
@ -71,7 +78,17 @@ function _prompt {
|
||||||
dir_color=$red
|
dir_color=$red
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="\\n ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}"
|
# Detect ssh
|
||||||
|
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
|
||||||
|
if [ "$HOST_INFO" = long ]; then
|
||||||
|
host="\H"
|
||||||
|
else
|
||||||
|
host="\h"
|
||||||
|
fi
|
||||||
|
ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PS1="\\n${ssh_info} ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}"
|
||||||
|
|
||||||
[[ ${#PS1} -gt $((COLUMNS*3)) ]] && wrap_char="\\n"
|
[[ ${#PS1} -gt $((COLUMNS*3)) ]] && wrap_char="\\n"
|
||||||
PS1="${PS1}${wrap_char}❯${normal} "
|
PS1="${PS1}${wrap_char}❯${normal} "
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,6 @@ THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
|
||||||
USER_HOST_THEME_PROMPT_PREFIX=''
|
USER_HOST_THEME_PROMPT_PREFIX=''
|
||||||
USER_HOST_THEME_PROMPT_SUFFIX=''
|
USER_HOST_THEME_PROMPT_SUFFIX=''
|
||||||
|
|
||||||
VIRTUAL_ENV=
|
|
||||||
|
|
||||||
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
|
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
|
||||||
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
|
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ ____brainy_bottom() {
|
||||||
___brainy_prompt_user_info() {
|
___brainy_prompt_user_info() {
|
||||||
color=$bold_blue
|
color=$bold_blue
|
||||||
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
||||||
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
if sudo -vn 1>/dev/null 2>&1; then
|
||||||
color=$bold_red
|
color=$bold_red
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -85,5 +85,6 @@ You can configure various aspects of the prompt to use less whitespace. Supporte
|
||||||
|POWERLINE_COMPACT_AFTER_LAST_SEGMENT | Removes the trailing space on the last 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_PROMPT | Removes the space after the prompt character
|
||||||
|POWERLINE_COMPACT | Enable all Compact settings (you can still override individual settings)
|
|POWERLINE_COMPACT | Enable all Compact settings (you can still override individual settings)
|
||||||
|
|POWERLINE_PROMPT_AFTER | Adds characters after the prompt
|
||||||
|
|
||||||
The default value for all settings is `0` (disabled). Use `1` to enable.
|
The default value for all settings is `0` (disabled). Use `1` to enable.
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ function __powerline_prompt_command {
|
||||||
LEFT_PROMPT=""
|
LEFT_PROMPT=""
|
||||||
SEGMENTS_AT_LEFT=0
|
SEGMENTS_AT_LEFT=0
|
||||||
LAST_SEGMENT_COLOR=""
|
LAST_SEGMENT_COLOR=""
|
||||||
|
PROMPT_AFTER="${POWERLINE_PROMPT_AFTER}"
|
||||||
|
|
||||||
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
|
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ function __powerline_prompt_command {
|
||||||
LEFT_PROMPT+=" "
|
LEFT_PROMPT+=" "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="${LEFT_PROMPT}"
|
PS1="${LEFT_PROMPT}${PROMPT_AFTER}"
|
||||||
|
|
||||||
## cleanup ##
|
## cleanup ##
|
||||||
unset LAST_SEGMENT_COLOR \
|
unset LAST_SEGMENT_COLOR \
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ POWERLINE_COMPACT_AFTER_SEPARATOR=${POWERLINE_COMPACT_AFTER_SEPARATOR:=${POWERLI
|
||||||
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
|
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
|
||||||
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
|
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
|
||||||
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
|
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
|
||||||
|
POWERLINE_PROMPT_AFTER=${POWERLINE_PROMPT_AFTER:-""}
|
||||||
|
|
||||||
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "}
|
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "}
|
||||||
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "}
|
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,7 @@ function __powerline_user_info_prompt {
|
||||||
local color=${USER_INFO_THEME_PROMPT_COLOR}
|
local color=${USER_INFO_THEME_PROMPT_COLOR}
|
||||||
|
|
||||||
if [[ "${THEME_CHECK_SUDO}" = true ]]; then
|
if [[ "${THEME_CHECK_SUDO}" = true ]]; then
|
||||||
if sudo -n uptime 2>&1 | grep -q "load"; then
|
sudo -vn 1>/dev/null 2>&1 && color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
|
||||||
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
|
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCM_THEME_PROMPT_DIRTY=" ${bold_yellow}✗"
|
||||||
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||||
|
SCM_THEME_PROMPT_PREFIX=" ${bold_blue}scm:("
|
||||||
|
SCM_THEME_PROMPT_SUFFIX="${bold_blue})"
|
||||||
|
|
||||||
|
GIT_THEME_PROMPT_DIRTY=" ${bold_yellow}✗"
|
||||||
|
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||||
|
GIT_THEME_PROMPT_PREFIX=" ${bold_blue}git:("
|
||||||
|
GIT_THEME_PROMPT_SUFFIX="${bold_blue})"
|
||||||
|
|
||||||
|
RVM_THEME_PROMPT_PREFIX="|"
|
||||||
|
RVM_THEME_PROMPT_SUFFIX="|"
|
||||||
|
|
||||||
|
function git_prompt_info {
|
||||||
|
git_prompt_vars
|
||||||
|
echo -e "$SCM_PREFIX${bold_red}$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function prompt_command() {
|
||||||
|
PS1="${bold_green}➜ ${bold_cyan}\W${reset_color}$(scm_prompt_info)${reset_color} "
|
||||||
|
}
|
||||||
|
|
||||||
|
PROMPT_COMMAND=prompt_command;
|
||||||
Loading…
Reference in New Issue