Cannot sudo a custom function in a zsh script
If you're unable to run a custom function with `sudo` in a Zsh script, it's likely due to how Zsh interacts with `sudo` and function scoping. To execute a custom function with `sudo` in a Zsh script, you can use the `sudo` command to run the entire script or call the function explicitly with `sudo`. Here are two approaches: 1. **Run the Entire Script with `sudo`**: You can run the entire script with `sudo` to ensure that the custom function and any other commands within the script run with elevated privileges. For example: ```zsh #!/bin/zsh # This is your custom function my_function() { # Your custom function code } # Call your function with sudo sudo my_function # Other script code ``` Save the script and then run it with `sudo`: ```bash sudo ./your_script.zsh ``` 2. **Explicitly Call the Function with `sudo`**: If you want to call only the custom function with `sudo` while the rest of the script runs with regular privil