From 089fc6fff34c4481672925b332d2f08380b5d702 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Fri, 26 Jan 2024 15:04:12 -0500 Subject: [PATCH] Add idea about turning functions into scripts --- zshrc.org | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/zshrc.org b/zshrc.org index aa9cc76..23208a4 100644 --- a/zshrc.org +++ b/zshrc.org @@ -57,6 +57,29 @@ defined in the previous section. *** TODO replace pomodoro aliases with actual scripts +*** TODO have a look at this idea: + Instead of defining a lot of functions in your `.zshrc', all of which you may not use, it is often better to use the autoload builtin. The idea is, you create a directory where function definitions are stored, declare the names in your `.zshrc', and tell the shell where to look for them. Whenever you reference a function, the shell will automatically load it into memory. + +% mkdir /tmp/funs +% cat >/tmp/funs/yp +ypmatch $1 passwd.byname +^D +% cat >/tmp/funs/cx +chmod +x $* +^D +% FPATH=/tmp/funs +% autoload cx yp +% functions cx yp +undefined cx () +undefined yp () +% chmod 755 /tmp/funs/{cx,yp} +% yp egsirer +egsirer:*:3214:35:Emin Gun Sirer:/u/egsirer:/bin/sh +% functions yp +yp () { + ypmatch $1 passwd.byname +} + *** Include :daily:android: First, include a script that sets a number of confidential data (e.g. API keys and such) #+begin_src sh