All Questions
10 questions
1
vote
2
answers
119
views
Start interactive function definition from shell-script
Using zsh or bash, I want to run a script that may prompt the user for multiple commands and store them as a function, however I'm finding that eval "function $FNCNAME() {" or echo "...
5
votes
1
answer
2k
views
zsh: pass variable by reference, and modify its value (like bash's local -n namerefs)?
Is it possible to pass a variable to a zsh function, and modify its value without using eval? I came across a bash way to do that: local -n: https://stackoverflow.com/a/50281697
1
vote
1
answer
181
views
zsh parameter substitution
This page has a demo function as follows:
~inews> namedir () { $1=$PWD ; : ~$1 }
But when I try it on my machine, it produces the following error:
namedir: no such file or directory: test=/home/...
1
vote
1
answer
581
views
execute command on all visible shells
I'm currently running a tiling window manager and I want to be able to use a custom function that is equivalent to one I had when I was using tmux that allowed me to run a command in all visible ...
1
vote
1
answer
3k
views
call function by name with arguments
I'm quite new on the shell scripting front and was wondering whether it is is possible to call a function which itself than calls another function with none, one or multiple arguments. The first ...
1
vote
0
answers
3k
views
How to define global functions in zsh (macOS) that are available in scripts? [duplicate]
Since macOS 10.15 (Catalina) the default shell has changed from bash to zsh. One of the things I'm running into is I cannot get my own global functions working. I used to export these from ....
10
votes
2
answers
5k
views
zsh: `source` command doesn't reload functions
(This is on MacOS with zsh 5.7.1)
Here is how I load custom functions in zsh:
# Custom functions
fpath=($HOME/.zfunc $fpath)
autoload -Uz mackupbackup
autoload -Uz tac
autoload -Uz airplane
autoload ...
21
votes
2
answers
9k
views
Test for function's existence that can work on both bash and zsh?
Is there a way to test whether a shell function exists that will work both for bash and zsh?
54
votes
4
answers
26k
views
what is the zsh equivalent of bash's export -f
So I started using zsh. I like it all right. It seems very cool and slick, and the fact that the current working directory and actual command line are on different lines is nice, but at the same time, ...
9
votes
1
answer
1k
views
Restoring an option at the end of a function in zsh
I'm writing a zsh shell function (as opposed to a script) where I would really like the extended_glob option to be enabled. But since the function runs in the caller's context, I don't want to clobber ...