From 7c9edd63347e104ac281b0ac5ea29e97f2200798 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Wed, 21 May 2025 09:28:20 +0200 Subject: [PATCH] fix(bash): l* dirname if file not found (#23) Reviewed-on: https://codeberg.org/vlw/dotfiles/pulls/23 --- .bash_aliases | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index e324dd5..f457fd2 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -5,32 +5,32 @@ mkcdir () { # Preview contents of a file or list the contents of a directory l () { - if [ -n "$1" ] ; then + if [ -f "$1" ] ; then less $1 return fi - ls -lh $1 + ls -lh $1 || l $(dirname "$1") } # Preview the contents of a file or list the contents of a directory with hidden files shown ll () { - if [ -n "$1" ] ; then + if [ -f "$1" ] ; then less $1 return fi - ls -lah $1 + ls -lah $1 || ll $(dirname "$1") } # Edit the contents of a file or list the contents of a directory (with hidden files shown) if that file is not found lll () { - if [ -n "$1" ] ; then + if [ -f "$1" ] ; then nano $1 return fi - ls -lah $1 + ls -lah $1 || lll $(dirname "$1") } .. () {