I'm trying to pipe the output of dmenu to surf (browser) in order to browse a selected URL. I'm doing:
cat ~/.surf/bookmarks | dmenu | surf
but surf starts before dmenu has exited with my chosen URL. This means it doesn't open with the correct URL. I don't see what the problem is because dmenu prints the URL to standard output after a choice is made, and surf works taking a URL as its argument. To clarify, the bookmarks file just contains URLs on separate lines.
I'm using this in i3, as a bindsym. I also tried
surf (cat ~/.surf/bookmarks | dmenu)
fish shell syntax, as that is my shell. Thanks in advance.
As mentioned in tkauusl's comment, surf
should get the URL as a command line argument, not piped to stdin
.
For bash
and POSIX compatible shells you can use this syntax:
surf $(cat ~/.surf/bookmarks | dmenu)
For other shells you might have to use
surf `cat ~/.surf/bookmarks | dmenu`
If the URL can contain spaces, you should quote the result of the command substitution.
surf "$(cat ~/.surf/bookmarks | dmenu)"