From 9a04ff2430da856c42ba67e34baa0bcf016ec848 Mon Sep 17 00:00:00 2001 From: ElfQrin Date: Sat, 21 Sep 2019 15:45:35 +0200 Subject: [PATCH] Add files via upload --- back.sh | 16 ++++++++++++++++ cdm.sh | 7 +++++++ dirm.sh | 10 ++++++++++ ldirm.sh | 9 +++++++++ showdirm.sh | 9 +++++++++ up.sh | 19 +++++++++++++++++++ upm.sh | 19 +++++++++++++++++++ 7 files changed, 89 insertions(+) create mode 100644 back.sh create mode 100644 cdm.sh create mode 100644 dirm.sh create mode 100644 ldirm.sh create mode 100644 showdirm.sh create mode 100644 up.sh create mode 100644 upm.sh diff --git a/back.sh b/back.sh new file mode 100644 index 0000000..25bb668 --- /dev/null +++ b/back.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# back # back from cdm and upm # r2017-02-01 fr2017-02-01 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias back=". PATH/back.sh" +if [ "$MPWD" == "" ]; then LIMIT=0; fi +LIMIT="$1" +if [ "$LIMIT" == "" ]; then LIMIT=1; fi +P="$MPWD" +# echo -n "cd from $P " +for ((i=1; i <= LIMIT; i++)) +do +P="${P%/..}" +done +# echo "to $P" +cd "$P" +export MPWD="$P" diff --git a/cdm.sh b/cdm.sh new file mode 100644 index 0000000..071a837 --- /dev/null +++ b/cdm.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# cdm # change directory (and back) # r2017-02-01 fr2017-02-01 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias cdm=". PATH/cdm.sh" +# echo "cd from $P to $1" +export MPWD="$PWD" +cd "$1" diff --git a/dirm.sh b/dirm.sh new file mode 100644 index 0000000..aa58a90 --- /dev/null +++ b/dirm.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# dirm # memorize directory (to get back) # r2019-09-21 fr2017-02-01 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias dirm=". PATH/dirm.sh" +# echo "directory to remember: $1" +if [ -z "$1" ]; then +export MPWD="$PWD" +else +export MPWD="$1" +fi diff --git a/ldirm.sh b/ldirm.sh new file mode 100644 index 0000000..55e21f9 --- /dev/null +++ b/ldirm.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# ldirm # list memorized directory # r2019-09-21 fr2019-09-21 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias ldirm=". PATH/ldirm.sh" +if [ "$MPWD" ]; then +ls -laF --group-directories-first --color=auto "$MPWD" +else +ls -laF --group-directories-first --color=auto +fi diff --git a/showdirm.sh b/showdirm.sh new file mode 100644 index 0000000..edcd9aa --- /dev/null +++ b/showdirm.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# showdirm # echo memorized directory # r2019-09-21 fr2019-09-21 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias showdirm=". PATH/showdirm.sh" +if [ "$MPWD" ]; then +echo "$MPWD" +else +echo "" +fi diff --git a/up.sh b/up.sh new file mode 100644 index 0000000..a70e5a4 --- /dev/null +++ b/up.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# up # up one directory # r2017-02-01 fr2017-02-01 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias up=". PATH/up.sh" +LIMIT="$1" +if [ "$LIMIT" == "" ]; then LIMIT=1; fi +if [ "$LIMIT" -lt 0 ]; then LIMIT=0; fi +P="$PWD" +if [ "$P" == "/" ]; then LIMIT=0; fi +# echo -n "cd from $P " +for ((i=1; i <= LIMIT; i++)) +do +P=`echo -n "$P" | rev | cut -d "/" -f2- | rev` +# P="$P/.." # alternative method +done +if [ "$P" == "" ]; then P="/"; fi +# echo "to $P" +cd "$P" +# export MPWD="$P" diff --git a/upm.sh b/upm.sh new file mode 100644 index 0000000..756770d --- /dev/null +++ b/upm.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# upm # up one directory (and back) # r2017-02-01 fr2017-02-01 +# by Valerio Capello - http://labs.geody.com/ - GPL +# alias upm=". PATH/upm.sh" +LIMIT="$1" +if [ "$LIMIT" == "" ]; then LIMIT=1; fi +if [ "$LIMIT" -lt 0 ]; then LIMIT=0; fi +P="$PWD" +if [ "$P" == "/" ]; then LIMIT=0; fi +# echo -n "cd from $P " +for ((i=1; i <= LIMIT; i++)) +do +# P=`echo -n "$P" | rev | cut -d "/" -f2- | rev` # this won't work with back +P="$P/.." +done +if [ "$P" == "" ]; then P="/"; fi +# echo "to $P" +cd "$P" +export MPWD="$P" \ No newline at end of file