mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-22 07:11:01 +00:00
commit
3663fe583b
3 changed files with 32 additions and 0 deletions
|
|
@ -571,3 +571,26 @@ func (gui *Gui) handleContainersBulkCommand(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
return gui.createBulkCommandMenu(bulkCommands, commandObject)
|
||||
}
|
||||
|
||||
// Open first port in browser
|
||||
func (gui *Gui) handleContainersOpenInBrowserCommand(g *gocui.Gui, v *gocui.View) error {
|
||||
container, err := gui.getSelectedContainer()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
// skip if no any ports
|
||||
if len(container.Container.Ports) == 0 {
|
||||
return nil
|
||||
}
|
||||
// skip if the first port is not published
|
||||
port := container.Container.Ports[0]
|
||||
if port.IP == "" {
|
||||
return nil
|
||||
}
|
||||
ip := port.IP
|
||||
if ip == "0.0.0.0" {
|
||||
ip = "localhost"
|
||||
}
|
||||
link := fmt.Sprintf("http://%s:%d/", ip, port.PublicPort)
|
||||
return gui.OSCommand.OpenLink(link)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,6 +262,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleContainersBulkCommand,
|
||||
Description: gui.Tr.ViewBulkCommands,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 'w',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainersOpenInBrowserCommand,
|
||||
Description: gui.Tr.OpenInBrowser,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'd',
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ type TranslationSet struct {
|
|||
ViewRestartOptions string
|
||||
RunCustomCommand string
|
||||
ViewBulkCommands string
|
||||
OpenInBrowser string
|
||||
|
||||
LogsTitle string
|
||||
ConfigTitle string
|
||||
|
|
@ -150,6 +151,7 @@ func englishSet() TranslationSet {
|
|||
ViewRestartOptions: "view restart options",
|
||||
RunCustomCommand: "run predefined custom command",
|
||||
ViewBulkCommands: "view bulk commands",
|
||||
OpenInBrowser: "open in browser (first port is http)",
|
||||
|
||||
AnonymousReportingTitle: "Help make lazydocker better",
|
||||
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker?",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue