Add item to Context menu for Linux: "Open in Terminal"?

How difficult would it be to add a context menu item for “Open in Terminal”?

This seems to be pretty common on Linux distributions (I’m using Linux Mint). For my use case I use a terminal for a pandoc conversion, because the plugin is unfortunately a little hit or miss, which I can seem to pinpoint exactly why it’s not working. So I just use the terminal to do the conversion. So I right click the Obsidian note I want to convert and hit “Show in system explorer” and there then “Open in Terminal”

Would it be possible to skip this step and add that into the Obsidian context menu?

Thanks!

Yes, use GitHub - Taitava/obsidian-shellcommands: Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.

On macOS, I set a shortcut for /Users/obsequious/bin/iterm2-new-tab-with-path.sh {{file_path:absolute}}, which contains something akin to https://raw.githubusercontent.com/fitztrev/shuttle/master/apple-scripts/iTermStable/iTerm2-stable-new-tab-default.applescript

1 Like

Awesome, I was just looking for “terminal” so I hadn’t found this.

Does this work for something like my use case? I’m sorry, I don’t really understand your shell script there.

Thanks!

The script doesn’t matter. Just applies to macOS. Forgot you were on Linux.

I guess your command may be something like gnome-terminal or something. But you’d have to figure out how to pass arguments to it to change the directory to {{file_path:absolute}}

Yeah, I’m having trouble with that. When I do gnome-terminal {{file_uri}} I do get a terminal window, but it’s opened to the vault root, which for this is not useful, because I have lots of folders and subfolders. So I’d need it to be opened right in the folder I trigger the command in. Any ideas on that?

This also happens for: {{file_path:absolute}} and :relative; {{folder_path:absolute} and relative. These all just open a terminal in the vault’s root. I need it to be more specific.

Interestingly, the little preview line under the input line in the plugin menu shows the correct path, but it doesn’t do anything with it, I guess.

So I solved this, by using this in the command line: pandoc {{file_path:absolute}} -o {{folder_path:absolute}}/{{title}}.tex

However, now the output has lots of escape characters \. This makes the .tex file unrunnable, because \ mean something there. How do I get rid of these escape characters when the shell plugin names a file?
Edit: nevermind, I had my " in the wrong place. It’s fine now. This setup works for me, thank you!!

1 Like