charmbracelet / gum

A tool for glamorous shell scripts 🎀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to read stdin with pager

FBDev64 opened this issue · comments

Hi! So I have a 'bug' in my bash script. The following is the scipt

#!/bin/sh

# Customize Console
PROMPT_COMMAND='echo -en "\033]0; $("FBD") \a"'
now=$(date)
echo "Undertale Jokes, that's all. Mainly. You know, as ya want."

while true
  do 

    #Input
    VHS=$(gum input --placeholder " Enter Command")

    # Treat Input
	case $VHS in 
	
		exit)
			exit
			;;
		clear | cls)
			clear
			;;
		puns)
			gum pager > ./jokes/puns.txt
			;;
		sans)
			gum pager > ./jokes/sans.txt
			;;
		help)
			echo "clear"
			echo "cls"
			echo "date"
			echo "exit"
			echo "help"
			echo "issue"
			echo "puns"
			echo "rules"
			echo "sans"
			echo "time"
			;;
		issue)
			echo "Report issue at github.com/FBD/issues"
			;;
		rules)
			echo "3 rules : 1. do NOT insult and NO NSFW. 2. BE a troll 3. Arch users should use the command arch on every startup."
			;;	
		time | date)
			echo "$now"
			;;
		*)
		echo -n "Command unknown or not implemented yet."
		;;
	esac	
done

It is shellchecked, but when I do type 'sans' or 'puns', it would normally use the pager and display the content of puns or sans in the pager, but nothing happens. I tried typing directly in the terminal, but is says in the pager : unable to read stdin.

@FBDev64 You're not sending content to stdin. Replacing gum pager > ./jokes/puns.txt with gum pager < ./jokes/puns.txt should do it.

commented

kay