ncd descend subfolder

This commit is contained in:
ville rantanen
2019-03-28 12:10:26 +02:00
parent 412339e35e
commit f2e9ed2b76

View File

@@ -181,11 +181,19 @@ complete -F _qcd qcd
function ncd() { function ncd() {
# echo Next sibling cd # echo Next sibling cd
[[ "$1" = "-h" ]] && { [[ "$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 return
} }
local _current_pwd _iter_d _iter_prev _current_found local _current_pwd _iter_d _iter_prev _current_found
_current_pwd=$( basename "$( pwd )" ) _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 .. \cd ..
for _iter_d in *; do for _iter_d in *; do
if [ ! -d "$_iter_d" ]; then continue; fi if [ ! -d "$_iter_d" ]; then continue; fi