1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-21 00:30:00 +02:00

Record current directory on switch

This commit is contained in:
David Roman
2022-03-15 14:12:26 +01:00
committed by Jesse Duffield
parent 950bb5090d
commit b8fc829f86
5 changed files with 27 additions and 7 deletions

View File

@ -11,16 +11,18 @@ import (
// shell can then change to that directory. That means you don't get kicked
// back to the directory that you started with.
func (gui *Gui) recordCurrentDirectory() error {
if os.Getenv("LAZYGIT_NEW_DIR_FILE") == "" {
return nil
}
// determine current directory, set it in LAZYGIT_NEW_DIR_FILE
dirName, err := os.Getwd()
if err != nil {
return err
}
return gui.recordDirectory(dirName)
}
func (gui *Gui) recordDirectory(dirName string) error {
if os.Getenv("LAZYGIT_NEW_DIR_FILE") == "" {
return nil
}
return gui.OSCommand.CreateFileWithContent(os.Getenv("LAZYGIT_NEW_DIR_FILE"), dirName)
}