Skip to content

How to open terminal in new tab at currently opened file path? #3724

Discussion options

You must be logged in to vote

The term command accepts a command as argument so you can use it like this:

term env --chdir=/path/to/some/directory /bin/bash

To get the working directory from the current file you can write a small plugin (put this in your ~/.config/micro/init.lua):

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 quoti…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@vulpes-vulpeos
Comment options

@Andriamanitra
Comment options

@vulpes-vulpeos
Comment options

Answer selected by vulpes-vulpeos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants