mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Separate menu item for Exec shell
Login to container's shell is very popular operation and to make it easier it will be better to make it as a separate menu item with a dedicated hot key.
This commit is contained in:
parent
430600063c
commit
2688801cbd
3 changed files with 24 additions and 0 deletions
|
|
@ -509,6 +509,21 @@ func (gui *Gui) handleContainerViewLogs(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.Errors.ErrSubProcess
|
return gui.Errors.ErrSubProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleContainersExecShell(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
container, err := gui.getSelectedContainer()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
commandObject := gui.DockerCommand.NewCommandObject(commands.CommandObject{
|
||||||
|
Container: container,
|
||||||
|
})
|
||||||
|
resolvedCommand := utils.ApplyTemplate("docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'", commandObject)
|
||||||
|
// attach and return the subprocess error
|
||||||
|
cmd := gui.OSCommand.ExecutableFromString(resolvedCommand)
|
||||||
|
gui.SubProcess = cmd
|
||||||
|
return gui.Errors.ErrSubProcess
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleContainersCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleContainersCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||||
container, err := gui.getSelectedContainer()
|
container, err := gui.getSelectedContainer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleContainerViewLogs,
|
Handler: gui.handleContainerViewLogs,
|
||||||
Description: gui.Tr.ViewLogs,
|
Description: gui.Tr.ViewLogs,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "containers",
|
||||||
|
Key: 'E',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleContainersExecShell,
|
||||||
|
Description: gui.Tr.ExecShell,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "containers",
|
ViewName: "containers",
|
||||||
Key: 'c',
|
Key: 'c',
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ type TranslationSet struct {
|
||||||
StopAllContainers string
|
StopAllContainers string
|
||||||
RemoveAllContainers string
|
RemoveAllContainers string
|
||||||
ViewRestartOptions string
|
ViewRestartOptions string
|
||||||
|
ExecShell string
|
||||||
RunCustomCommand string
|
RunCustomCommand string
|
||||||
ViewBulkCommands string
|
ViewBulkCommands string
|
||||||
|
|
||||||
|
|
@ -148,6 +149,7 @@ func englishSet() TranslationSet {
|
||||||
StopAllContainers: "stop all containers",
|
StopAllContainers: "stop all containers",
|
||||||
RemoveAllContainers: "remove all containers (forced)",
|
RemoveAllContainers: "remove all containers (forced)",
|
||||||
ViewRestartOptions: "view restart options",
|
ViewRestartOptions: "view restart options",
|
||||||
|
ExecShell: "exec shell",
|
||||||
RunCustomCommand: "run predefined custom command",
|
RunCustomCommand: "run predefined custom command",
|
||||||
ViewBulkCommands: "view bulk commands",
|
ViewBulkCommands: "view bulk commands",
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue