Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
6 votes
1 answer
170 views

How can I force zsh to write automatically complete path to history?

Suppose I did some time ago cd /path/to/foo/bar and then evince file.pdf. Now if I want to open file.pdf again I have also to do both steps again (using history). However I would do it in a single ...
student's user avatar
  • 18.5k
-1 votes
1 answer
75 views

"$-" Returns 569X During ZSH Invocation [duplicate]

Background While studying the shell parameter, $-, for sh, bash, and zsh, I discovered that it returned current option flags, hBc, for both sh and bash but 569X for zsh. SUSE >> bash -c 'echo &...
Майкл Шодеке's user avatar
4 votes
3 answers
1k views

Looping through command line parameter options until next parameter

In a new addition to a script I am working on, I want to loop through parameters associated with a flag until zsh reaches the next flag in the command. For instance, when the user enters the following:...
Karie's user avatar
  • 53
1 vote
1 answer
1k views

If no argument is given to mandatory option, zparseopts takes next option as the argument

I am using zsh 5.4.2. The function that is causing issue is: function zp () { zparseopts -E -watch:=o_watch -show=o_show echo "show : $o_show" echo "watch ...
Ahmad Ismail's user avatar
  • 2,738
1 vote
1 answer
1k views

How do I make an option (not argument of the option) mandatory in zparseopts?

In the example bellow: function zp () { zparseopts -E -walk:=o_walk echo "walk: $o_walk" } I get the following output: $ zp --walk "Walking" walk : --walk ...
Ahmad Ismail's user avatar
  • 2,738
4 votes
1 answer
2k views

Is there a simple way to get array of all arguments that do not begin with a hyphen?

Zsh includes a powerful utility for parsing command line options,zparseopts. Is there an easy way to extract the array of all the command line arguments that don't begin with a hyphen?
kjo's user avatar
  • 15.7k
3 votes
1 answer
5k views

How to run a specified codeblock with getopts when no options or arguments are supplied?

So I am writing a script that mixes options with arguments with options that don't. From research I have found that getopts is the best way to do this, and so far it has been simple to figure out and ...
MaQleod's user avatar
  • 2,644