From cac5dd8399d55807551bdc09a21ca8a4ddabe6f8 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Wed, 21 May 2025 08:54:10 +0200 Subject: [PATCH] feat(bash): preview or edit files with l-functions --- .bash_aliases | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index 2fa000b..e324dd5 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,23 +1,48 @@ # Make dir and cd into it mkcdir () { - mkdir -p -- "$1" && - cd -P -- "$1" + mkdir -p -- "$1" && cd -P -- "$1" } -# ls -la -alias l="ls -lh" -alias ll="ls -lah" -alias lll="ls -lah | less" +# Preview contents of a file or list the contents of a directory +l () { + if [ -n "$1" ] ; then + less $1 + return + fi + + ls -lh $1 +} + +# Preview the contents of a file or list the contents of a directory with hidden files shown +ll () { + if [ -n "$1" ] ; then + less $1 + return + fi + + ls -lah $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 + nano $1 + return + fi + + ls -lah $1 +} + +.. () { + cd .. && l +} -# cd + cdl () { - cd -P -- "$1" && - l + cd -P -- "$1" && l } cdll () { - cp -P -- "$1" && - ll + cp -P -- "$1" && ll } # Create standard git WIP commit with timestamps