alignment fixes

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

28
qckcmd
View File

@ -22,17 +22,17 @@ exec 1>&2
function usage(){
echo -e "${BOLD}${SCRIPT_NAME} [options]${NORMAL}"
echo -e " -h : print this help message"
echo -e " -i [file] : specify init file"
echo -e "\t-h : print this help message"
echo -e "\t-i [file] : specify init file"
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}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}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}The configuration follows this format:${NORMAL}"
echo -e "${BLUE} <KEY>: <COMMAND>${NORMAL}"
echo -e "${BLUE}\t<KEY>: <COMMAND>${NORMAL}"
}
function list_options() {
@ -52,29 +52,29 @@ function read_config() {
OPTSTR="hi:"
while getopts "${OPTSTR}" O; do
case $O in
h) usage && exit ;;
i) read_config ${OPTARG} ;;
*) echo -e "${RED}Unrecognized option, exiting...${NORMAL}" && exit 1 ;;
esac
case $O in
h) usage && exit ;;
i) read_config ${OPTARG} ;;
*) echo -e "${RED}Unrecognized option, exiting...${NORMAL}" && exit 1 ;;
esac
done
while true; do
list_options
printf "${RED}> ${NORMAL}"
read -n 1 INPUT
read -n 1 INPUT
echo ""
INPUT="${INPUT#"${INPUT%%[![:space:]]*}"}"
if [[ -z "$INPUT" ]]; then
continue
fi
fi
if [[ -n "${POINTS[$INPUT]}" ]]; then
if [[ -n "${POINTS[$INPUT]}" ]]; then
echo -e "${BOLD}$ ${POINTS[$INPUT]}${NORMAL}"
exec 1>&3
echo "${POINTS[$INPUT]}"
echo "${POINTS[$INPUT]}"
exit 0
fi
fi
done