MarkHedleyJones / dmenu-extended

An extension to dmenu for quickly opening files and folders.
MIT License
389 stars 33 forks source link

Open with operator (:) not working with terminal commands #102

Open pawelgalecki opened 4 years ago

pawelgalecki commented 4 years ago

I am using dmenu-extended with i3. In my config file I put: bindsym $mod+d exec --no-startup-id dmenu_extended_run --debug > dmenu.log to capture the log. Let's say I have some .java file I would like to edit in terminal with vi. I type: /home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java:vi and this brings no result... When I check my log file I can see following lines:

Vim: Error reading input, exiting...er.java" [dos] 87L, 2324C 1,1           Top
Debugging enabled
Launch arguments: []
Frequently used items cache does not exist, will return nothing
Opening cache at /home/pawel/.cache/dmenu-extended/dmenuExtended_plugins.txt
Opening cache at /home/pawel/.cache/dmenu-extended/dmenuExtended_all.txt
First menu closed with user input: /home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java:vi
Loading plugins
Loaded plugin plugin_sheets
Loaded plugin plugin_internetSearch
This command is not related to a plugin
Converting '/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java:vi' into its aliased command
/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java:vi
No suitable candidate was found
Colon detected in command, could be a path or attempt to open something with something
/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java:vi
First item is a path
Second item passed so assume this is what the user wants to use to open path with
Command=vi '/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java'
Executing: vi '/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java'
Command converted into:
[u'vi', u'/home/pawel/Dropbox/gitRepos/command/src/test/java/hamcrest/custom/ValueOfTheFieldMatcher.java']

My workaround is to select the file first, tab-complete then type ; and go to the beginning of the line and type vi;

Also it works just fine when I run dmenu-extended from console.

Any ideas?

MarkHedleyJones commented 4 years ago

Thanks! This is an issue. It seems that only one operator, : in your case, is being processed and the final ; to tell dmenu-extended to run the program in the terminal is being ignored. Ideally, dmenu would detect that vi is a terminal program automatically and execute as such. Thank you for the report. I'm not sure when I'll have time to address this but thank you for creating the issue :+1:

themooleman commented 2 years ago

I can confirm this issue. My solution was to copy /usr/share/applications/vim.desktop to ~/.local/share/applications/vim.desktop (the user directory is checked first by xdg-open) and edit the Exec line to Exec=alacritty -e vim.

After running update-desktop-database ~/.local/share/applications, dmenu_extended_run is able to use the new vim.desktop file (via xdg-open) to open the file, eliminating a need to use the "Open with" operator.

Note that you may need to update your mimeapps.list file such that vim is the default file handler for all text files. A handy tool for this is selectdefaultapplication, available here: https://github.com/sandsmark/selectdefaultapplication