Look, you don't have to like it.
Run make
to bundle the library into a single file
build/jdvlib.sh
.
Copy that file to your project and source it in your scripts.
# shellcheck source=./jdvlib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/jdvlib.sh"
These variables affect the behaviour:
JDVLIB_DEBUG
: Set totrue
to enable debug output. There is not a lot of this, though.- Deprecation messages will include file and line of the caller.
JDVLIB_LOG_DEPRECATIONS
: Set to something to log deprecation messages to~/.jdvlib-deprecations.log
.
Functions that support the library. This module is the basis for imports, so there should never be an import of this file.
meta::for_each_library_module
meta::import
meta::is_compiling
meta::lib_is_compiled
meta::library_path
meta::module_is_running
Functions related to ANSI escape codes. This code is vendored in from Tyler Akins' ansi project.
Click to expand (118 functions)
ansi::ansi
ansi::backward
ansi::bell
ansi::bgBlack
ansi::bgBlackIntense
ansi::bgBlue
ansi::bgBlueIntense
ansi::bgColor
ansi::bgCyan
ansi::bgCyanIntense
ansi::bgGreen
ansi::bgGreenIntense
ansi::bgMagenta
ansi::bgMagentaIntense
ansi::bgRed
ansi::bgRedIntense
ansi::bgRgb
ansi::bgWhite
ansi::bgWhiteIntense
ansi::bgYellow
ansi::bgYellowIntense
ansi::black
ansi::blackIntense
ansi::blink
ansi::blue
ansi::blueIntense
ansi::bold
ansi::color
ansi::colorCodePatch
ansi::colorCodes
ansi::colorTable
ansi::colorTableLine
ansi::column
ansi::columnRelative
ansi::cyan
ansi::cyanIntense
ansi::deleteChars
ansi::deleteLines
ansi::doubleUnderline
ansi::down
ansi::encircle
ansi::eraseChars
ansi::eraseDisplay
ansi::eraseLine
ansi::faint
ansi::font
ansi::forward
ansi::fraktur
ansi::frame
ansi::green
ansi::greenIntense
ansi::hideCursor
ansi::icon
ansi::ideogramLeft
ansi::ideogramLeftDouble
ansi::ideogramRight
ansi::ideogramRightDouble
ansi::ideogramStress
ansi::insertChars
ansi::insertLines
ansi::inverse
ansi::invisible
ansi::isAnsiSupported
ansi::italic
ansi::line
ansi::lineRelative
ansi::magenta
ansi::magentaIntense
ansi::nextLine
ansi::noBlink
ansi::noBorder
ansi::noInverse
ansi::noOverline
ansi::noStrike
ansi::noUnderline
ansi::normal
ansi::overline
ansi::plain
ansi::position
ansi::previousLine
ansi::rapidBlink
ansi::red
ansi::redIntense
ansi::repeat
ansi::report
ansi::reportIcon
ansi::reportPosition
ansi::reportScreenChars
ansi::reportTitle
ansi::reportWindowChars
ansi::reportWindowPixels
ansi::reportWindowPosition
ansi::reportWindowState
ansi::reset
ansi::resetAttributes
ansi::resetBackground
ansi::resetColor
ansi::resetFont
ansi::resetForeground
ansi::resetIdeogram
ansi::restoreCursor
ansi::rgb
ansi::saveCursor
ansi::scrollDown
ansi::scrollUp
ansi::showCursor
ansi::showHelp
ansi::strike
ansi::tabBackward
ansi::tabForward
ansi::title
ansi::underline
ansi::up
ansi::visible
ansi::white
ansi::whiteIntense
ansi::yellow
ansi::yellowIntense
Functions to help with parsing and validation of command line arguments.
args::check_help_arg
args::ensure_num_args
args::ensure_num_args_between
args::flag_value
args::get_flag_value
Functions that relate to the code itself, where it is located, and how it is used.
code::is_sourced
code::script_dir
This is a compatibility layer for deprecated functions. It is intended to be used when refactoring code to use the new functions. It will be removed in the future.
Click to expand (38 functions)
ask
can_user_write_to_dir
check_help_arg
deco_message
die
dotenv_delete
dotenv_load
dotenv_save
echo_step
ensure_debian
ensure_dir_exists
ensure_docker_host
ensure_file_exists
ensure_has_commands
ensure_in_path
ensure_in_remote_mount
ensure_num_args
ensure_pve
ensure_root
ensure_var_is_set
fail
flag_value
get_arch
get_os
has_command
info
is_in_remote_mount
is_linux
is_lxc
is_macos
is_owned_by_user
load_env
noop
ok
print_aligned
replace_between_markers
run_as
script_dir
Functions used to manage environment variables.
env::dotenv_delete
env::dotenv_load
env::dotenv_save
env::ensure_is_set
Functions related to the filesystem. Existance, permissions, etc.
fs::can_user_write_to_dir
fs::ensure_dir_exists
fs::ensure_file_exists
fs::ensure_in_remote_mount
fs::is_in_remote_mount
fs::is_owned_by_user
Functions related to functions and function management.
func::ensure
func::list_functions_in_file
Functions related to Proxmox Virtual Environment (PVE).
pve::ensure_lxc
pve::ensure_pve
pve::is_lxc
pve::is_pve
Functions related to the system, its attributes and capabilities.
sys::ensure_debian
sys::ensure_docker_host
sys::ensure_has_commands
sys::ensure_in_path
sys::ensure_linux
sys::ensure_macos
sys::get_arch
sys::get_os
sys::has_command
sys::is_debian
sys::is_docker_host
sys::is_in_path
sys::is_linux
sys::is_macos
sys::run_as
Functions that relate to text manipulation.
text::apply_in_place
text::comment_out_inside_markers
text::delete_around_markers
text::delete_inside_markers
text::filter_inside_markers
text::format_inside_markers
text::print_aligned
text::read_inside_markers
text::replace_between_markers_legacy
text::replace_inside_markers
Functions to interact with the user.
ui::ask
ui::deco_message
ui::deprecate
ui::die
ui::echo_step
ui::fail
ui::info
ui::noop
ui::ok
ui::reassurance_required
ui::reassure
Functions related to users and groups.
user::add_to_groups
user::create
user::ensure_exists
user::ensure_group_exists
user::ensure_in_group
user::ensure_root
user::exists
user::group_exists
user::is_in_group
user::is_root