mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-14 18:20:40 +01:00
28 lines
807 B
Bash
28 lines
807 B
Bash
#!/usr/bin/env bash
|
|
# -----------------------------------------------------------------------------
|
|
# bat-extras | Copyright (C) 2019 eth-p | MIT License
|
|
#
|
|
# Repository: https://github.com/eth-p/bat-extras
|
|
# Issues: https://github.com/eth-p/bat-extras/issues
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Option parser hook: --terminal-width support.
|
|
# This will accept --terminal-width=number.
|
|
#
|
|
# The variable OPT_TERMINAL_WIDTH will be set.
|
|
hook_width() {
|
|
SHIFTOPT_HOOKS+=("__shiftopt_hook__width")
|
|
__shiftopt_hook__width() {
|
|
case "$OPT" in
|
|
|
|
--terminal-width) shiftval; OPT_TERMINAL_WIDTH="$OPT_VAL" ;;
|
|
|
|
*) return 1 ;;
|
|
esac
|
|
return 0
|
|
}
|
|
|
|
# Default terminal width.
|
|
OPT_TERMINAL_WIDTH="$({ stty size 2>/dev/null || echo "22 80"; } | cut -d' ' -f 2)"
|
|
}
|