alignment fixes

This commit is contained in:
anon 2023-09-24 20:44:31 +02:00
parent 3d537ba5fd
commit 0f11caf14e

28
qckcmd

@ -22,17 +22,17 @@ exec 1>&2
function usage(){ function usage(){
echo -e "${BOLD}${SCRIPT_NAME} [options]${NORMAL}" echo -e "${BOLD}${SCRIPT_NAME} [options]${NORMAL}"
echo -e " -h : print this help message" echo -e "\t-h : print this help message"
echo -e " -i [file] : specify init file" echo -e "\t-i [file] : specify init file"
echo -e "${YELLOW}Qckcmd allows you to map keys to commands.${NORMAL}" echo -e "${YELLOW}Qckcmd allows you to map keys to commands.${NORMAL}"
echo -e "${YELLOW}Effectively it's a hack to compensate for the in unreliableness of what key combinations are trapped by terminal emulators/multiplexers by adding a prefix key.${NORMAL}" echo -e "${YELLOW}Effectively it's a hack to compensate for the in unreliableness of what key combinations are trapped by terminal emulators/multiplexers by adding a prefix key.${NORMAL}"
echo -e "${YELLOW}Qckcmd does not directly execute commands, if one is successfully selected it will be echod to stdout.${NORMAL}" echo -e "${YELLOW}Qckcmd does not directly execute commands, if one is successfully selected it will be echod to stdout.${NORMAL}"
echo -e "${YELLOW}Nothing else will ever be printed on stdout.${NORMAL}" echo -e "${YELLOW}Nothing else will ever be printed on stdout.${NORMAL}"
echo -e "${YELLOW}The intended way to run is to execute it's output like so:${NORMAL}" echo -e "${YELLOW}The intended way to run is to execute it's output like so:${NORMAL}"
echo -e "${BLUE} \$(qckcmd -i myinit.conf)${NORMAL}" echo -e "${BLUE}\t\$(qckcmd -i myinit.conf)${NORMAL}"
echo -e "${YELLOW}As a result commands modifying the shells internal state are valid to map to (e.g.: cd, source, <alias>).${NORMAL}" echo -e "${YELLOW}As a result commands modifying the shells internal state are valid to map to (e.g.: cd, source, <alias>).${NORMAL}"
echo -e "${YELLOW}The configuration follows this format:${NORMAL}" echo -e "${YELLOW}The configuration follows this format:${NORMAL}"
echo -e "${BLUE} <KEY>: <COMMAND>${NORMAL}" echo -e "${BLUE}\t<KEY>: <COMMAND>${NORMAL}"
} }
function list_options() { function list_options() {
@ -52,29 +52,29 @@ function read_config() {
OPTSTR="hi:" OPTSTR="hi:"
while getopts "${OPTSTR}" O; do while getopts "${OPTSTR}" O; do
case $O in case $O in
h) usage && exit ;; h) usage && exit ;;
i) read_config ${OPTARG} ;; i) read_config ${OPTARG} ;;
*) echo -e "${RED}Unrecognized option, exiting...${NORMAL}" && exit 1 ;; *) echo -e "${RED}Unrecognized option, exiting...${NORMAL}" && exit 1 ;;
esac esac
done done
while true; do while true; do
list_options list_options
printf "${RED}> ${NORMAL}" printf "${RED}> ${NORMAL}"
read -n 1 INPUT read -n 1 INPUT
echo "" echo ""
INPUT="${INPUT#"${INPUT%%[![:space:]]*}"}" INPUT="${INPUT#"${INPUT%%[![:space:]]*}"}"
if [[ -z "$INPUT" ]]; then if [[ -z "$INPUT" ]]; then
continue continue
fi fi
if [[ -n "${POINTS[$INPUT]}" ]]; then if [[ -n "${POINTS[$INPUT]}" ]]; then
echo -e "${BOLD}$ ${POINTS[$INPUT]}${NORMAL}" echo -e "${BOLD}$ ${POINTS[$INPUT]}${NORMAL}"
exec 1>&3 exec 1>&3
echo "${POINTS[$INPUT]}" echo "${POINTS[$INPUT]}"
exit 0 exit 0
fi fi
done done