ncd, the Next cd
This commit is contained in:
31
qcd_function
31
qcd_function
@@ -281,6 +281,37 @@ sys.stderr.write(os.path.join(pat_dir,key_match))
|
|||||||
' "$@" 2>&1 1>&$out); } {out}>&1 ; \cd "$cdto"
|
' "$@" 2>&1 1>&$out); } {out}>&1 ; \cd "$cdto"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ncd() {
|
||||||
|
# Next cd: cd to ../[next_folder]. ncd - to go to previous
|
||||||
|
local _current_pwd _iter_d _iter_prev _current_found
|
||||||
|
_current_pwd=$( basename $( pwd ) )
|
||||||
|
\cd ..
|
||||||
|
for _iter_d in *; do
|
||||||
|
if [ ! -d "$_iter_d" ]; then continue; fi
|
||||||
|
if [ -n "$_current_found" ]; then
|
||||||
|
\cd "$_iter_d"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ "$_iter_d" = "$_current_pwd" ]; then
|
||||||
|
_current_found=true
|
||||||
|
if [ "$1" = "-" ]; then
|
||||||
|
if [ -z "$_iter_prev" ]; then
|
||||||
|
echo $_current_pwd was the first folder.
|
||||||
|
else
|
||||||
|
\cd "$_iter_prev";
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_iter_prev="$_iter_d"
|
||||||
|
done
|
||||||
|
if [ -n "$_current_found" ]; then
|
||||||
|
echo "$_current_pwd" was the last folder.
|
||||||
|
else
|
||||||
|
echo "$_current_pwd" was not found in ../
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function rmv () {
|
function rmv () {
|
||||||
# mv files/folders with rsync (shows speed and progress)
|
# mv files/folders with rsync (shows speed and progress)
|
||||||
local sources
|
local sources
|
||||||
|
|||||||
Reference in New Issue
Block a user