forked from denisidoro/navi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] Define OPTIONS as global in opts::eval - [x] Add script - [x] Minor changes
- Loading branch information
1 parent
2ee253a
commit 36cd52f
Showing
13 changed files
with
187 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
debian="${1:-false}" | ||
|
||
if $debian; then | ||
docker run \ | ||
-it \ | ||
--entrypoint /bin/bash \ | ||
-v "$(pwd):/navi" \ | ||
debian \ | ||
-c 'apt update; apt install -y git curl; git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && yes | ~/.fzf/install; export PATH=$PATH:/navi; bash' | ||
else | ||
docker run \ | ||
-it \ | ||
--entrypoint /bin/bash \ | ||
-v "$(pwd):/navi" \ | ||
ellerbrock/alpine-bash-git \ | ||
-c 'git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && yes | ~/.fzf/install; export PATH=$PATH:/navi; bash' | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
test::run "We can find at least one known cheatsheet" \ | ||
'cheat::find | grep -q "docker.cheat"' | ||
assert_docker_cheat() { | ||
cheat::find | grep -q "docker.cheat" | ||
} | ||
|
||
test::run "We can find at least one known cheatsheet" assert_docker_cheat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
|
||
_export_colors() { | ||
if ! ${DOT_COLORS_EXPORTED:-false}; then | ||
if [ -z ${TERM:-} ] || [ $TERM = "dumb" ]; then | ||
bold="" | ||
underline="" | ||
freset="" | ||
purple="" | ||
red="" | ||
green="" | ||
tan="" | ||
blue="" | ||
else | ||
bold=$(tput bold) | ||
underline=$(tput sgr 0 1) | ||
freset=$(tput sgr0) | ||
purple=$(tput setaf 171) | ||
red=$(tput setaf 1) | ||
green=$(tput setaf 76) | ||
tan=$(tput setaf 3) | ||
blue=$(tput setaf 38) | ||
fi | ||
|
||
log_black=30 | ||
log_red=31 | ||
log_green=32 | ||
log_yellow=33 | ||
log_blue=34 | ||
log_purple=35 | ||
log_cyan=36 | ||
log_white=37 | ||
|
||
log_regular=0 | ||
log_bold=1 | ||
log_underline=4 | ||
|
||
readonly DOT_COLORS_EXPORTED=true | ||
fi | ||
} | ||
|
||
log::color() { | ||
_export_colors | ||
local bg=false | ||
case "$@" in | ||
*reset*) echo "\e[0m"; exit 0 ;; | ||
*black*) color=$log_black ;; | ||
*red*) color=$log_red ;; | ||
*green*) color=$log_green ;; | ||
*yellow*) color=$log_yellow ;; | ||
*blue*) color=$log_blue ;; | ||
*purple*) color=$log_purple ;; | ||
*cyan*) color=$log_cyan ;; | ||
*white*) color=$log_white ;; | ||
esac | ||
case "$@" in | ||
*regular*) mod=$log_regular ;; | ||
*bold*) mod=$log_bold ;; | ||
*underline*) mod=$log_underline ;; | ||
esac | ||
case "$@" in | ||
*background*) bg=true ;; | ||
*bg*) bg=true ;; | ||
esac | ||
|
||
if $bg; then | ||
echo "\e[${color}m" | ||
else | ||
echo "\e[${mod:-$log_regular};${color}m" | ||
fi | ||
} | ||
|
||
if [ -z ${LOG_FILE+x} ]; then | ||
readonly LOG_FILE="/tmp/$(basename "$0").log" | ||
fi | ||
|
||
_log() { | ||
local template=$1 | ||
shift | ||
if ${log_to_file:-false}; then | ||
echo -e $(printf "$template" "$@") | tee -a "$LOG_FILE" >&2 | ||
else | ||
echo -e $(printf "$template" "$@") | ||
fi | ||
} | ||
|
||
_header() { | ||
local TOTAL_CHARS=60 | ||
local total=$TOTAL_CHARS-2 | ||
local size=${#1} | ||
local left=$((($total - $size) / 2)) | ||
local right=$(($total - $size - $left)) | ||
printf "%${left}s" '' | tr ' ' = | ||
printf " $1 " | ||
printf "%${right}s" '' | tr ' ' = | ||
} | ||
|
||
log::header() { _export_colors && _log "\n${bold}${purple}$(_header "$1")${freset}\n"; } | ||
log::success() { _export_colors && _log "${green}✔ %s${freset}\n" "$@"; } | ||
log::error() { _export_colors && _log "${red}✖ %s${freset}\n" "$@"; } | ||
log::warning() { _export_colors && _log "${tan}➜ %s${freset}\n" "$@"; } | ||
log::note() { _export_colors && _log "${blue}➜ %s${freset}\n" "$@"; } |