README.md | 4 +++- config.def.h | 2 ++ nlay | 11 +++++++++++ nnn.1 | 2 ++ nnn.c | 10 ++++++++++ diff --git a/README.md b/README.md index d8766db48bc082a1ab2438c1e7b9dbe362305ccb..c8661c816c66bece1897f8a759b4d825d834b5cb 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ & | Jump to initial dir - | Jump to last visited dir o | Open dir in NNN_DE_FILE_MANAGER / | Filter dir contents + ^/ | Search dir in catfish c | Show change dir prompt d | Toggle detail view D | Toggle current file details screen @@ -200,11 +201,12 @@ export NNN_OPENER=xdg-open export NNN_OPENER="gio open" export NNN_OPENER=gvfs-open - - If nnn recognizes the file extension, it invokes nlay (which invokes the players). Default players: + - If nnn recognizes the file extension, it invokes nlay (which invokes the players). Default apps: - mpv - audio and video - viewnior - image - [zathura](https://pwmt.org/projects/zathura/) - pdf - vim - plain text + - catfish - search - to add, remove recognized extensions in nnn, see [how to change file associations](#change-file-associations) - If a file without any extension is a plain text file, it is opened in EDITOR (fallback vi) - Set `NNN_FALLBACK_OPENER` as the fallback opener. E.g.: diff --git a/config.def.h b/config.def.h index e23fe3c374f18b955545fd1bb002d0a99922df48..c5c9ce1bfc087b0b97854b21a7363efa05be58f9 100644 --- a/config.def.h +++ b/config.def.h @@ -35,6 +35,8 @@ { KEY_RIGHT, SEL_GOIN, "", "" }, { 'l', SEL_GOIN, "", "" }, /* Filter */ { '/', SEL_FLTR, "", "" }, + /* Desktop search */ + { CONTROL('_'), SEL_SEARCH, "", "" }, /* Next */ { 'j', SEL_NEXT, "", "" }, { KEY_DOWN, SEL_NEXT, "", "" }, diff --git a/nlay b/nlay index 20d6e8ed7d0775c24e2c9e35d9d39ec17b549e38..bc9eaaa6a93902a027aca97d5a8b7180664cbe6c 100755 --- a/nlay +++ b/nlay @@ -120,3 +120,14 @@ eval $app $txt_opts "\"$1\"" $bg exit 0 fi + +#----------------- SEARCH ------------------- +if [ "$2" == "search" ]; then + app=catfish + #search_opts= + + bg=">/dev/null 2>&1 &" + + eval $app $search_opts "\"$1\"" $bg + exit 0 +fi diff --git a/nnn.1 b/nnn.1 index b51450cd047d1f1315b7b229cfda86c9a7e00a87..cb980139bacc32d7898a62e13d02e141cf648582 100644 --- a/nnn.1 +++ b/nnn.1 @@ -51,6 +51,8 @@ .It Ic o Open directory in NNN_DE_FILE_MANAGER .It Ic / Change filter (more information below) +.It Ic ^/ +Search directory in catfish .It Ic c Change into the given directory .It Ic d diff --git a/nnn.c b/nnn.c index cf5932b39fdbfefb98f10d310df44e7cc679ead7..c7a20f54ae4c590357c6df5b181bea182d830366 100644 --- a/nnn.c +++ b/nnn.c @@ -84,6 +84,7 @@ SEL_CDQUIT, SEL_BACK, SEL_GOIN, SEL_FLTR, + SEL_SEARCH, SEL_NEXT, SEL_PREV, SEL_PGDN, @@ -1212,6 +1213,7 @@ & | Jump to initial dir\n\ - | Jump to last visited dir\n\ o | Open dir in NNN_DE_FILE_MANAGER\n\ / | Filter dir contents\n\ + ^/ | Search dir in catfish\n\ c | Show change dir prompt\n\ d | Toggle detail view\n\ D | Toggle current file details screen\n\ @@ -1658,6 +1660,14 @@ /* Save current */ if (ndents > 0) mkpath(path, dents[cur].name, oldpath, PATH_MAX); goto nochange; + case SEL_SEARCH: + exitcurses(); + if (player) + spawn(player, path, "search", NULL, 0); + else + spawn("nlay", path, "search", NULL, 0); + initcurses(); + break; case SEL_NEXT: if (cur < ndents - 1) cur++;