diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-10-07 12:34:12 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-11 21:45:31 +1100 |
commit | cbc82cd3c1e8668d37aad049401222a382613f98 (patch) | |
tree | 1925bc51831d4f8c7505947e1cef70e7f88d2e68 /pkg/gui/gui.go | |
parent | 29ee2399876bccbc4fe388252545df2763b11029 (diff) |
allow for changing the current directory on exit
For this to work you'll need to put this in your ~/.zshrc (or equivalent rc file):
lg()
{
export LAZYGIT_NEW_DIR_FILE=/Users/jesseduffieldduffield/Library/Application\ Support/jesseduffield/lazygit/.lastd
lazygit "$@"
if [ -f $LAZYGIT_NEW_DIR_FILE ]; then
cd "$(cat $LAZYGIT_NEW_DIR_FILE)"
rm -f $LAZYGIT_NEW_DIR_FILE > /dev/null
fi
}
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index b65f01747..982e1879c 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -160,6 +160,7 @@ type guiState struct { Context string // important not to set this value directly but to use gui.changeContext("new context") CherryPickedCommits []*commands.Commit SplitMainPanel bool + RetainOriginalDir bool } // for now the split view will always be on @@ -779,6 +780,12 @@ func (gui *Gui) RunWithSubprocesses() error { for { if err := gui.Run(); err != nil { if err == gocui.ErrQuit { + if !gui.State.RetainOriginalDir { + if err := gui.recordCurrentDirectory(); err != nil { + return err + } + } + break } else if err == gui.Errors.ErrSwitchRepo { continue @@ -818,18 +825,6 @@ func (gui *Gui) runCommand() error { return nil } -func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error { - if gui.State.Updating { - return gui.createUpdateQuitConfirmation(g, v) - } - if gui.Config.GetUserConfig().GetBool("confirmOnQuit") { - return gui.createConfirmationPanel(g, v, true, "", gui.Tr.SLocalize("ConfirmQuit"), func(g *gocui.Gui, v *gocui.View) error { - return gocui.ErrQuit - }, nil) - } - return gocui.ErrQuit -} - func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error { if !gui.g.Mouse { return nil |