]> Sergey Matveev's repositories - nnn.git/commitdiff
Add command to cd back to HOME
authorsin <sin@2f30.org>
Thu, 25 Feb 2016 15:06:57 +0000 (15:06 +0000)
committersin <sin@2f30.org>
Thu, 25 Feb 2016 15:14:08 +0000 (15:14 +0000)
Original patch written by Richard Hyde and taken from
https://github.com/RichardHyde/noice

config.def.h
noice.1
noice.c

index 640407976bc79168d7b28b985ec895626d491d4f..af9bcbb641d49dafcc68ab448ff7e27be1199936 100644 (file)
@@ -56,6 +56,7 @@ struct key bindings[] = {
        { '$',            SEL_END },
        /* Change dir */
        { 'c',            SEL_CD },
+       { '~',            SEL_CDHOME },
        /* Toggle hide .dot files */
        { '.',            SEL_TOGGLEDOT },
        /* Toggle sort by time */
diff --git a/noice.1 b/noice.1
index cb5b56d40aadef8d8e855bd3fad71792c8800994..f9ac1afce8252601f56dff6212083cde6a9f75f3 100644 (file)
--- a/noice.1
+++ b/noice.1
@@ -1,4 +1,4 @@
-.Dd November 26, 2015
+.Dd February 25, 2016
 .Dt NOICE 1
 .Os
 .Sh NAME
@@ -49,6 +49,8 @@ Back up one directory level.
 Change filter (see below for more information).
 .It Ic c
 Change into the given directory.
+.It Ic ~
+Change to the HOME directory.
 .It Ic \&.
 Toggle hide .dot files.
 .It Ic t
diff --git a/noice.c b/noice.c
index b3a28525e58e226dea8f20d32b7846e9a0810218..489caabe617b7c1cc25d26bdc3522de72971fff4 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -57,6 +57,7 @@ enum action {
        SEL_HOME,
        SEL_END,
        SEL_CD,
+       SEL_CDHOME,
        SEL_TOGGLEDOT,
        SEL_MTIME,
        SEL_REDRAW,
@@ -707,6 +708,21 @@ nochange:
                        strlcpy(fltr, ifilter, sizeof(fltr))
                        DPRINTF_S(path);
                        goto begin;
+               case SEL_CDHOME:
+                       tmp = getenv("HOME");
+                       if (tmp == NULL) {
+                               clearprompt();
+                               goto nochange;
+                       }
+                       if (canopendir(tmp) == 0) {
+                               printwarn();
+                               goto nochange;
+                       }
+                       strlcpy(path, tmp, sizeof(path));
+                       /* Reset filter */
+                       strlcpy(fltr, ifilter, sizeof(fltr));
+                       DPRINTF_S(path);
+                       goto begin;
                case SEL_TOGGLEDOT:
                        if (strcmp(fltr, ifilter) != 0)
                                strlcpy(fltr, ifilter, sizeof(fltr));