šŸ’¾ Archived View for idiomdrottning.org ā€ŗ re-shell-automation captured on 2022-04-28 at 17:35:08. Gemini links have been rewritten to link to archived content

View Raw

More Information

ā¬…ļø Previous capture (2021-12-03)

āž”ļø Next capture (2024-02-05)

-=-=-=-=-=-=-

Re: The Linux shell is not a good automation platform

Re: The Linux shell is not a good automation platform

Unless you 100% use command line utilities

Wellā€¦ thatā€™s the solution right thereā™„

Shell can read the clipboard with xclip and you can make shell scripts that are emacs-aware with emacsclient -e.

You can run shell scripts from your dwm / sway or from emacs or from your other apps.

I currently have over 320 custom shell functions and around 200 standalone homemade scripts and binaries. Kind of beyond what I think most people have in their Tasker setups.

Iā€™ve gradually over the past 20 years built up this disgusting palimpsest of scripts upon scripts upon scripts. My lisp shells out and my shell calls lisp and vice versa recursively. Itā€™s completely gross.

Follow-Up

Kensanata wrote in:

When you posted about the number of shell scripts and aliases a while back, you beat me by factor of 100, more or less. I donā€™t think I ever used cal in a script! šŸ˜…

I was really bitten by that actually, once. I didnā€™t think of the ā€œjust type the actual pathā€ thing, which has saved me on other occasions since.

Yeah, I source, letā€™s see now: currently 1595 lines of functions and aliases into every shell I open. Thatā€™s in addition to hashbang scripts and binaries. Of course, they all call each other in a huge mess. My Chicken Scheme programs and my Emacs Lisp commands call shell script functions and vice versa.

I have a command called zshrun for when I need to use this stuff externally, from cron, from posix scripts, from Chicken, from Emacs. Itā€™s simply this:

ellen% cat /usr/local/bin/zshrun
#!/usr/bin/zsh
source /home/sandra/.zshrc
$*

From zsh itā€™s easy to call emacs stuff:

ellen% which emx
emx () {
    for command in $*
    do
        emacsclient -n -e "($command)"
    done
}

And of course to call my liā€™l Chicken utils, theyā€™re just binaries.

dc is a language I use very often but they are not convient to make into hashbangs. Instead, I do things like this:

ellen% which fcp
fcp () {
    dc -e "$* 4*sp4*sc9*sflplclf++st[Fat: ]Plf100*lt/n[%]p[Carbs: ]Plc100*lt/n[%]p[Protein: ]Plp100*lt/n[%]p"
}

As in, shell functions that just call dc -e ā€œsome stringā€ and that string is interpolated to contain the function args.