diff --git a/src/internal/common/config_type.go b/src/internal/common/config_type.go index f1645bce3..193069e30 100644 --- a/src/internal/common/config_type.go +++ b/src/internal/common/config_type.go @@ -95,6 +95,7 @@ type ConfigType struct { FilePreviewWidth int `toml:"file_preview_width" comment:"\nFile preview width allow '0' (this mean same as file panel),'x' x must be less than 10 and greater than 1 (This means that the width of the file preview will be one xth of the total width.)"` EnableFilePreviewBorder bool `toml:"enable_file_preview_border" comment:"\nEnable border around the file preview panel (default: false)"` CodePreviewer string `toml:"code_previewer" comment:"\nWhether to use the builtin syntax highlighting with chroma or use bat. Values: \"\" for builtin chroma, \"bat\" for bat"` + OpenFileWithDefaultApp bool `toml:"open_file_with_default_app" comment:"\nWhether pressing confirm (Enter/right/l) on a file opens it with the system default application. Set to false to disable launching external programs (e.g. open/xdg-open); the file will just be selected. Directories are still entered. (default: true)"` SidebarWidth int `toml:"sidebar_width" comment:"\nThe length of the sidebar(excluding borders). If you don't find to display the sidebar, you can input 0 directly. If you want to display the value, please place it in the range of 5-20."` SidebarSections []string `toml:"sidebar_sections" comment:"\nOrder of sidebar sections (valid values: \"home\", \"pinned\", \"disks\").\nOnly sections included in this list will be displayed."` diff --git a/src/internal/handle_panel_movement.go b/src/internal/handle_panel_movement.go index 4c672f554..094eecdaf 100644 --- a/src/internal/handle_panel_movement.go +++ b/src/internal/handle_panel_movement.go @@ -68,6 +68,11 @@ func (m *model) enterPanel() { } func (m *model) executeOpenCommand() { + if !common.Config.OpenFileWithDefaultApp { + // User disabled launching external programs. The file is just + // selected; preview panel still shows its content. + return + } panel := m.getFocusedFilePanel() filePath := panel.GetFocusedItem().Location diff --git a/src/superfile_config/config.toml b/src/superfile_config/config.toml index b6c7ccc9e..7d311d0a4 100644 --- a/src/superfile_config/config.toml +++ b/src/superfile_config/config.toml @@ -126,6 +126,14 @@ file_preview_width = 0 # Default: false (no border) enable_file_preview_border = false +#-- Open File With Default App +# Whether pressing confirm (Enter/right/l) on a file opens it with the +# system default application (open on macOS, xdg-open on Linux, etc.). +# Set to false to disable launching external programs; the file will just +# be selected and its preview shown. Directories are still entered. +# Default: true +open_file_with_default_app = true + #-- Sidebar Width # If you don't want to display the sidebar, you can input 0 directly. # Values recommended to be in 5–20.