LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-24-2020, 09:08 AM   #16
frrobert
Member
 
Registered: Mar 2008
Location: South Bend, IN
Distribution: Ubuntu 18.04 & 20.04
Posts: 42

Original Poster
Rep: Reputation: 1

ondoho,

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.

Code:
#!/bin/bash
# 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.
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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