I can never remember what parameters I want for ls so I made an alias for it. I still couldn’t remember them so I copy and pasted the documentation into a literate document and tangle that into a function to do what I want:

When I can’t figure out how to write a function to do what I want then I record a macro of what I want to do and then “decompile” it to Elisp using elmacro. This is a super-power package if you want to figure out how something works.

When you run Bash under shell in Emacs on macOS then update_terminal_cwd is never defined and after every command you get the error message bash: update_terminal_cwd: command not found making the shell unusable.

The simplest solution is to define update_terminal_cwd when it isn’t defined.