From f2e9ed2b7609c19aa3aa0752e794a4b8585f73fe Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Thu, 28 Mar 2019 12:10:26 +0200 Subject: [PATCH] ncd descend subfolder --- qcd_function | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qcd_function b/qcd_function index 27d4b2c..8a87d8f 100644 --- a/qcd_function +++ b/qcd_function @@ -181,11 +181,19 @@ complete -F _qcd qcd function ncd() { # echo Next sibling cd [[ "$1" = "-h" ]] && { - echo Next sibling cd: change directory to [../next_folder]. ncd - to go to previous. + echo -e "Next sibling cd: change directory to [../next_folder]. \nncd - to go to previous folder. \nncd . to descend to first subfolder." return } local _current_pwd _iter_d _iter_prev _current_found _current_pwd=$( basename "$( pwd )" ) + if [ "$1" = "." ]; then + for _iter_d in *; do + if [ ! -d "$_iter_d" ]; then continue; fi + \cd "$_iter_d" + return + done + return + fi \cd .. for _iter_d in *; do if [ ! -d "$_iter_d" ]; then continue; fi