You are not logged in.
Hi,
I am trying to replace dmenu with fzf, but the problem I face is that every time when my script is trying to open result of fzf in phpstorm I get two windows one with terminal and the other one with phpstorm. If I close terminal window it closes the phpstorm. I do understand that I need to start phpstorm process in a background but no matter what I try it doesn't work. Here are my scripts.
storm script
#!/bin/sh
result=$(find $HOME/www -type d | fzf)
[[ -z $result ]] && exit
phpstorm $result
fzfmenu script for binding
#!/usr/bin/env bash
# fzfmenu - fzf as dmenu replacement
input=$(mktemp -u --suffix .storm.input)
output=$(mktemp -u --suffix .storm.output)
mkfifo $input
mkfifo $output
chmod 600 $input $output
# it's better to use st here (starts a lot faster than pretty much everything else)
st -c stormfzf -n stormfzf -e sh -c "storm" & disown
# handle ctrl+c outside child terminal window
trap "kill $! 2>/dev/null; rm -f $input $output" EXIT
cat > $input
cat $output
If I add `&` to phpstorm $result command it just closes windows before phpstorm starts
Last edited by AcidGod (2020-07-27 15:20:39)
Offline
Your script seems overly complicated to me.
What are those fifo's for?
If your intent is to emulate dmenu behaviour with a terminal & fzf, this is what I came up with:
#!/bin/sh
# fzfmenu - fzf as dmenu replacement
# it's better to use st here (starts a lot faster than pretty much everything else)
exec urxvt -e sh -c 'result=$(find $HOME -name "*.sh" | fzf);[ -z "$result" ] && exit;exec geany "$result"'
edit: Ooops, I can see the problem now, which presents just as described in the shorter script above.
Last edited by ondoho (2020-07-27 16:25:21)
Offline
The example of fzfmenu script comes from official repo https://github.com/junegunn/fzf/wiki/Ex … eplacement, I am running it with dwm rather than urxvt.
Basically I need to run fzfmenu to get a suckless terminal popup with fzf running in it. The official fzf menu uses & disown to send st to the background. Unlike vscode and sublime, phpstorm is using java to start the application which causes the output to be displayed within opened st terminal from fzfmenu script. If I change storm script to nohup for starting phpstorm I can close that st window with java outpup and it keeps the application open, but that the extra step that I want to remove, so that if I bind fzfmenu to the keyboard I can select the folder I need and get it opened in phpstorm without any additional windows.
I can do something as simple as that but it keeps the terminal open after phpstorm starts.
storm script:
#!/bin/bash
result=$(find ~/www -type d | fzf )
[ -z $result ] && exit
nohup phpstorm $result >/dev/null 2>&1
fzfmenu script
#!/usr/bin/env bash
# it's better to use st here (starts a lot faster than pretty much everything else)
st -c fzfmenu -n fzfmenu -e sh -c "storm" & disown
Last edited by AcidGod (2020-07-27 17:17:11)
Offline
I have managed to close the window by adding `sleep 9; kill $!` to fzfmenu script, which gives me 9 seconds to make a selection and then it closes terminal window. Ideally, I need it to be closed straight after fzf selection is made and phpstorm is starting but I have not idea how.
Last edited by AcidGod (2020-07-27 17:26:54)
Offline
I think this does what you want:
phpstorm "$(find $HOME/www -type d | fzfmenu)"
(use the example script exactly as it is in the wiki)
Offline
@ondoho I don't if you read the post but I am not trying to figure out the command I need to use to initiate the opening of phpstorm, I am struggling to get the terminal window with phpstorm output to be closed upon phpstorms opening.
On top of that the command you specified in its form will cause phpstorm opening even if no selection is done.
Last edited by AcidGod (2020-07-28 10:03:56)
Offline
@ondoho I don't if you read the post but I am not trying to figure out the command I need to use to initiate the opening of phpstorm, I am struggling to get the terminal window with phpstorm output to be closed upon phpstorms opening.
I know what you want. We both tried it your way and didn't succeed.
The command above does what you want.
On top of that the command you specified in its form will cause phpstorm opening even if no selection is done.
You can script around that easily. C'mon.
Offline
AcidGod wrote:@ondoho I don't if you read the post but I am not trying to figure out the command I need to use to initiate the opening of phpstorm, I am struggling to get the terminal window with phpstorm output to be closed upon phpstorms opening.
I know what you want. We both tried it your way and didn't succeed.
The command above does what you want.AcidGod wrote:On top of that the command you specified in its form will cause phpstorm opening even if no selection is done.
You can script around that easily. C'mon.
thank you for your kind suggestion
Offline
Here is the solution I came up with so far.
fzfmenu script:
#!/usr/bin/env bash
st -c fzfmenu -n fzfmenu -g "100x12" -e sh -c "storm" & disown
storm script:
#!/bin/bash
result=$(find ~/www -type d | fzf)
[ -z $result ] && exit
(nohup phpstorm $result >/dev/null 2>&1 &)
pkill -f fzfmenu
Last edited by AcidGod (2020-07-28 16:21:22)
Offline