Questions tagged [zsh]
Zsh is a shell with many advanced command-line and scripting features.
3,150 questions
0
votes
0
answers
53
views
tmux-resurrect loses CWD and prints command prompts (often) when restoring sessions with pane contents
The problem
In tmux, I use the tmux-resurrect plugin with pane contents restore feature.
The plugin saves the state inc. the pane contents, but when I start the server again, two issues appear:
2 ...
2
votes
1
answer
46
views
separate zsh completions before and after -- (with _arguments)
I'm writing a completion definition for the carbon tool and try to get the carbon compile subcommand right. from the help message, the interesting bits
Subcommand `compile` usage:
carbon [OPTIONS] ...
0
votes
1
answer
31
views
In external command line editor functionality, how to make (n)vim treat the temp file as zsh script?
I have a keybinding ctrl+x ctrl+e which uses a zshcontrib functionality (seemingly loaded by default on my Fedora machine) to edit the current command line in $EDITOR. (That function's name is edit-...
7
votes
3
answers
728
views
Difference between these 2 different ways of extracting files from a zip archive
I am trying to unzip a set of files (3 files). These files contain a lot of random files, duplicate files etc. To do this, I am first unzipping the list of the names of files into a text file, then ...
0
votes
0
answers
95
views
How to change zsh prompt just before the command runs?
del-prompt-accept-line() {
OLD_PROMPT="$PROMPT"
PROMPT="> "
zle reset-prompt
PROMPT="$OLD_PROMPT"
zle accept-line
}
zle -N del-prompt-accept-line
...
1
vote
0
answers
37
views
Exclude files from zsh tab completion based on exit code of external tool
I'd like to use my current zsh autocompletion setup but filter out some of the results. I've set up an autocompletion file and put it in my fpath so that it gets autoloaded. But there's one critical ...
9
votes
1
answer
221
views
zsh: Preserve trailing comma inside brace completion
Why does zsh delete a trailing comma when I type a closing brace?
For example, trying to compare two files foo.txt.bak and foo.txt:
diff foo.txt{.bak,}
When I type that closing brace, the comma is ...
5
votes
1
answer
470
views
zsh - if condition comparison: '-ne' and '!=' have different result
Why these commands lead to opposite comparison results between -ne and !=? Seems != works but -ne does not? I thought they are the same while comparing strings.
% set -o | grep pipe
pipefail ...
2
votes
1
answer
143
views
How to use zmv to add left padding to a number in a filename?
% zmv -n 'Folder One/Image \((*)\).png' folder_two/img_${(l:2::0:)1}.png
zmv: error(s) in substitution:
Folder One/Image (10).png and Folder One/Image (1).png both map to folder_two/img_00.png
Folder ...
0
votes
0
answers
75
views
Sending SIGSTOP to background sleep process does not stop it; it keeps running
I am trying to implement a shell(zsh) based Pomodoro clock and I encountered a problem: sending -STOP signal to background sleep process does not stop it.
WesternGun@MyMacBook-Pro:~ [12:13:49] 0
% ...
1
vote
1
answer
131
views
zsh - Param expansion to join all elements of an assoc array, with separator in between?
If I have the following Zsh assoc array:
declare -Ar assoc_arr=(
[a]="x"
[b]="y"
[c]="z with space"
)
I’m trying to come up with a param expansion to output the ...
1
vote
0
answers
117
views
zsh associative array value data types
In ZSH, how do you set the value of an associative array parameter to an array?
e.g.,
% declare -A a=()
% a[first]=(1 2)
zsh: a: attempt to set slice of associative array
And when I try and append ...
7
votes
1
answer
388
views
Allow unicode characters in zsh shell variable names on MacOS
There seems to be limited/inconsistent support for unusual but legal characters in zsh (and sh, bash) shell variable names on mac. Is there any way to fix this for full or better support?
Perhaps this ...
1
vote
1
answer
132
views
Case-insensitive pattern replacement in Zsh parameter expansion
Please look at this pattern replacement in parameter expansion:
% zsh -c 'echo ${0/%.jpg/.jpeg}' toto.jpg
toto.jpeg
Replacement does not occur here:
% zsh -c 'echo ${0/%.jpg/.jpeg}' toto.JPG
toto.JPG
...
0
votes
2
answers
126
views
What explains the measured overhead when timing a command in zsh?
When timing a command with time, there is inevitably some overhead (from the CPU, operating system, shell and so on).
Running the following code, from a tty text mode virtual console with all ...