commit a302de9efee5eb10414037d8c651c0efa7eb89c6 parent bcf8a1bbbcbdefc675381f15a1c3b215d6ee9384 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 8 Apr 2020 13:34:04 +0200 Handle dirs in plumber and o() Diffstat:
M | .local/bin/plumb | | | 4 | +++- |
M | .profile | | | 13 | +++++-------- |
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -101,7 +101,9 @@ handle_calendar_invite() { handle_target() { t="$1" - if [ -e "$t" ]; then + if [ -d "$t" ]; then + termopen cd $t; $SHELL + elif [ -e "$t" ]; then mime_type="$(file -ib "$t")" case "$mime_type" in image/*) diff --git a/.profile b/.profile @@ -40,20 +40,17 @@ h() { } o() { - [ "$(uname)" = 'Darwin' ] && open="open" || open="xdg-open" - if [ "$#" -gt 0 ] && [ -f "$1" ]; then - for f in "$@"; do - $open "$f" - done - else - target="$(find "${1:-.}" | fzy -l 25)" + if [ "$#" -eq 0 ] || [ -d "$1" ]; then + target="$(find "${1:-.}" | fzy -l 25)" || return 1 if [ -f "$target" ]; then - $open "$target" + plumb "$target" elif [ -d "$target" ]; then cd "$target" else echo "unknown target type" >&2 fi + else + plumb "$@" fi }