diff options
| -rw-r--r-- | .bashrc | 1 | ||||
| -rwxr-xr-x | bin/cle | 9 |
2 files changed, 9 insertions, 1 deletions
@@ -51,6 +51,7 @@ export LESS=iXFRx4 # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' +alias fd='find . -iname' alias grep='grep -i --color' alias more='less' alias vi='vim' @@ -2,7 +2,14 @@ clip() { print "$1" | tee /dev/tty | head -n 1 | pbcopy; } -del() { rm -i ~/.cle/"$1"; } +checkpath() { set -- $(realpath "$1"); [ "${1#~/.cle/}" != "$1" ]; } + +del() { + set -- ~/.cle/"$1" + checkpath "$1" || die "invalid path $1" + rm -i "$1" + rmdir -p "${1%/*}" 2>/dev/null || true +} die() { echo "$@" >&2; exit 1; } |
