MCPcopy
hub / github.com/micro-editor/micro / CdCmd

Method CdCmd

internal/action/command.go:245–267  ·  view source on GitHub ↗

CdCmd changes the current working directory

(args []string)

Source from the content-addressed store, hash-verified

243
244// CdCmd changes the current working directory
245func (h *BufPane) CdCmd(args []string) {
246 if len(args) > 0 {
247 path, err := util.ReplaceHome(args[0])
248 if err != nil {
249 InfoBar.Error(err)
250 return
251 }
252 err = os.Chdir(path)
253 if err != nil {
254 InfoBar.Error(err)
255 return
256 }
257 wd, _ := os.Getwd()
258 for _, b := range buffer.OpenBuffers {
259 if len(b.Path) > 0 {
260 b.Path, _ = util.MakeRelative(b.AbsPath, wd)
261 if p, _ := filepath.Abs(b.Path); !strings.Contains(p, wd) {
262 b.Path = b.AbsPath
263 }
264 }
265 }
266 }
267}
268
269// MemUsageCmd prints micro's memory usage
270// Alloc shows how many bytes are currently in use

Callers

nothing calls this directly

Calls 3

ReplaceHomeFunction · 0.92
MakeRelativeFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected