---
doc/nfm.1 | 1 +
example/config.ini | 1 +
src/Config.zig | 2 ++
src/key-operations/misc.zig | 10 ++++++++++
4 files changed, 14 insertions(+)
diff --git a/doc/nfm.1 b/doc/nfm.1
index 9435f1445cac..31ffc232bc58 100644
--- a/doc/nfm.1
+++ b/doc/nfm.1
@@ -123,6 +123,7 @@ h, left, C-b@enter-parent-dir
l, right, C-f@commit-file-at-cursor
G, end@cursor-move-to-bottom
g, home@cursor-move-to-top
+~@go-home
page-down@cursor-move-page-down
page-up@cursor-move-page-up
enter@commit-marks
diff --git a/example/config.ini b/example/config.ini
index ee92b8f23745..299f100ce064 100644
--- a/example/config.ini
+++ b/example/config.ini
@@ -21,6 +21,7 @@ home = cursor-move-to-top;
end = cursor-move-to-bottom;
page-down = cursor-move-page-down;
page-up = cursor-move-page-up;
+~ = go-home;
: = open-cmd;
m = mark-file-at-cursor;
M = open-select;
diff --git a/src/Config.zig b/src/Config.zig
index ac6fb1810bd3..5352ff078231 100644
--- a/src/Config.zig
+++ b/src/Config.zig
@@ -53,6 +53,7 @@ pub const impl = struct {
pub const @"commit-marks" = @import("key-operations/commit.zig").commitMarks;
pub const @"enter-parent-dir" = @import("key-operations/misc.zig").enterParentDir;
+ pub const @"go-home" = @import("key-operations/misc.zig").goHome;
pub const @"jump-back" = @import("key-operations/misc.zig").jumpBack;
pub const @"quit" = @import("key-operations/misc.zig").quit;
pub const @"run" = @import("key-operations/misc.zig").run;
@@ -116,6 +117,7 @@ pub fn init(self: *Self) !void {
try self.addBindIfUndefined("f", impl.@"toggle-view-filesystems", null);
try self.addBindIfUndefined("b", impl.@"toggle-view-bookmarks", null);
try self.addBindIfUndefined("escape", impl.@"set-view-files", null);
+ try self.addBindIfUndefined("~", impl.@"go-home", null);
// Make the emacs people happy
try self.addBindIfUndefined("C-n", impl.@"cursor-move-down", null);
diff --git a/src/key-operations/misc.zig b/src/key-operations/misc.zig
index 12568696c0af..3d08c495db29 100644
--- a/src/key-operations/misc.zig
+++ b/src/key-operations/misc.zig
@@ -32,6 +32,16 @@ pub fn enterParentDir(_: *const KeyOperation) !void {
try context.setCwd("..");
}
+pub fn goHome(_: *const KeyOperation) !void {
+ if (context.view != .nav) {
+ context.mode.setMessage(.err, "Operation not supported in this view");
+ return;
+ }
+
+ context.mode.setNav();
+ try context.setCwd("~");
+}
+
pub fn jumpBack(_: *const KeyOperation) !void {
if (context.view != .nav) {
context.mode.setMessage(.err, "Operation not supported in this view");
--
2.36.1