Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hotkey for copying PWD to clipboard #510

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/internal/config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ type HotkeysType struct {
OpenCommandLine []string `toml:"open_command_line"`

CopyPath []string `toml:"copy_path"`
CopyPWD []string `toml:"copy_present_working_directory"`

ToggleFooter []string `toml:"toggle_footer"`

Expand Down
7 changes: 7 additions & 0 deletions src/internal/handle_file_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,10 @@ func (m model) copyPath() {
outPutLog("Copy path error", panel.element[panel.cursor].location, err)
}
}

func (m model) copyPWD() {
panel := m.fileModel.filePanels[m.filePanelFocusIndex]
if err := clipboard.WriteAll(panel.location); err != nil {
outPutLog("Copy present working directory error", panel.location, err)
}
}
2 changes: 2 additions & 0 deletions src/internal/key_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ func (m *model) normalAndBrowserModeKey(msg string) {
m.searchBarFocus()
case containsKey(msg, hotkeys.CopyPath):
m.copyPath()
case containsKey(msg, hotkeys.CopyPWD):
m.copyPWD()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/superfile_config/hotkeys.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ change_panel_mode = ['v', '']
open_help_menu = ['?', '']
open_command_line = [':', '']
copy_path = ['ctrl+p', '']
copy_present_working_directory = ['c', '']
toggle_footer = ['F', '']
# =================================================================================================
# Typing hotkeys (can conflict with all hotkeys)
Expand Down
1 change: 1 addition & 0 deletions src/superfile_config/vimHotkeys.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ change_panel_mode = ['m', '']
open_help_menu = ['?', '']
open_command_line = [':', '']
copy_path = ['Y', '']
copy_present_working_directory = ['c', '']
toggle_footer = ['ctrl+f', '']
# =================================================================================================
# Typing hotkeys (can conflict with all hotkeys)
Expand Down