Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-24-2020, 09:08 AM   #16
LQ Newbie
Registered: Mar 2008
Location: South Bend, IN
Distribution: Ubuntu 18.04 & 20.04
Posts: 29

Original Poster
Rep: Reputation: 1


Thanks for the lead. The script on the fzf page was the solution. The key is you need to call the terminal from inside the script and you need to you you temp variables with named pipes to get everything to work.

I don't have the full script done but here is a proof of concept.

Thanks again to everyone.

# fzfmenu - fzf as dmenu replacement
input=$(mktemp -u --suffix .fzfmenu.input)
output=$(mktemp -u --suffix .fzfmenu.output)
mkfifo $input
mkfifo $output

  TERMINAL_CMD="uxterm -e"
#cat in the values for the first menu from files into pipe
cat ~/.cache/dmenu-recent/all ~/.cache/dmenu-recent/recent > $input &

#create terminal with fzf menu with values from pipe
uxterm -class fzfmenu -T fzfmenu -e sh -c "cat $input | fzf $* | tee $output" & disown

#set variable to value from output pipe
cmd=$(cat $output)
#cat new values into input pipe 
cat ~/.cache/knowntypes > $input &
#create terminal with fzf menu with new values from pipe
uxterm -class fzfmenu -T fzfmenu -e sh -c "cat $input | fzf $* | tee $output" & disown
#assignvalue from output pipe to type variable
type=$(cat $output)
#delete temp files 
rm -f $input $output
#run command based on selections
[[ "$type" = "background" ]] && exec $cmd 
[[ "$type" = "terminal" ]] && exec $TERMINAL_CMD "$cmd"
[[ "$type" = "terminal_hold" ]] && exec $TERMINAL_CMD sh -c "$cmd && echo Press Enter to kill me... && read line"
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cursor does not move to the bottom line and overwrite to same line on command line mesuutt Linux - Newbie 3 02-25-2012 08:04 AM
Print all PID folders from /proc line-by-line with this format (( PID: command-line )) courteous Linux - Newbie 7 12-12-2010 04:47 PM
awk command line: blank line record sep, new line field sep robertmarkbram Programming 4 02-21-2010 05:25 AM
grab the line below a blank line and the line above the next blank line awk or perl? Pantomime Linux - General 7 06-26-2008 08:13 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:02 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration