2
votes
2answers
360 views

Zip folder without including path to folder and require only one argument

I'm trying to make a zip function that'll do all the steps I typically do when zipping a file or folder. Say my current directory is ~, and I want to zip a folder named Folder1, whose file path is ...
3
votes
2answers
130 views

bash equivalent of zsh's $@[2,$#]

(NB: the motivation for this question is only to improve my bash programming know-how.) I want to know the bash equivalent of zsh expressions such as $@[2,$#], which directly address a range of a ...
5
votes
3answers
173 views

${#array} vs ${#array[@]}

As far as I can tell both ${#array[@]} and ${#array} evaluate to the number of elements in $array. Is there any reason for preferring the longer form (${#array[@]})?
5
votes
2answers
110 views

Is there a less convoluted way to set the $path array locally within function?

Is there a less laborious way for setting a local version of the $path array than what's shown in the following snippet? foo () { local holdpath holdpath=($path) local path ...
2
votes
2answers
1k views

/usr/bin/env: zsh -: No such file or directory

I get the error /usr/bin/env: zsh -: No such file or directory ...when I run an executable zsh script that starts with the following shebang line: #!/usr/bin/env zsh - Also, FWIW, replacing - ...
6
votes
4answers
901 views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
1
vote
1answer
101 views

Frequent command “template”: remove parameter expansion escape characters

zsh newbie here... I find myself using a handful of long commands over and over again with slightly different arguments. For example: rsync -havu --progress --rsh='ssh -l mylogin' ...
3
votes
3answers
304 views

Converting a history to a script?

Often times I've typed in a bunch of commands when I realize that I am going to keep typing them in and that I would really like a script. Now I understand that no matter how I save my history, I am ...
6
votes
2answers
2k views

List elements with spaces in zsh

I've been studying zsh scripting for all of 2 hours at this point and I've hit a wall. I want to go through a list of files that may have spaces in them. I'm open to completely different approaches ...
1
vote
1answer
160 views

How to access user's fpath as opposed to system's fpath with a script?

test.zsh: #!/usr/bin/env zsh for f in ${fpath}; do echo ${f} done outputs: ...