How to open terminal in new tab at currently opened file path? #3724
Answered
by
Andriamanitra
vulpes-vulpeos
asked this question in
Q&A
-
term command does't accept path as argument, so is it even possible in micro? Here is keybinding I use in neovim:
|
Beta Was this translation helpful? Give feedback.
Answered by
Andriamanitra
Apr 23, 2025
Replies: 1 comment 3 replies
-
The
To get the working directory from the current file you can write a small plugin (put this in your local config = import("micro/config")
local filepath = import("filepath")
function init()
config.MakeCommand("myterm", termInCurrentDir, config.NoComplete)
end
function termInCurrentDir(bufpane, args)
local shellCommand = (args == nil or #args == 0) and "/bin/bash" or args[1]
local workdir = filepath.Dir(bufpane.Buf.Path)
-- WARNING: if you need to deal with paths that contain double quotes you will need better shell quoting than this
bufpane:HandleCommand(string.format("term env --chdir=\"%s\" %s", workdir, shellCommand))
end |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
vulpes-vulpeos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
term
command accepts a command as argument so you can use it like this:To get the working directory from the current file you can write a small plugin (put this in your
~/.config/micro/init.lua
):