Zsh is a shell with many advanced command-line and scripting features.

learn more… | top users | synonyms (1)

0
votes
1answer
42 views

Why is cd appending dirs like pushd?

I am using zsh in Babun (Cygwin with oh-my-zsh and some extras). I noticed some odd behavior, it looks like cd is behaving like pushd? { ~ } » mkdir foo { ~ } » pushd foo ~/foo ~ { foo } » popd ~ ...
0
votes
1answer
17 views

How can I get a variables datatype in zsh?

For example zsh uses the variable $fpath to define include directories. How can I tell what type of variable $fpath is? i.e. is fpath a string number numeric array associative array
3
votes
1answer
55 views

zsh: Tab completion for function with Git commands

In zsh I am using the following function to delete a local and a remote branch with one command: gpDo () { git branch -d "$1" && git push --delete origin "$1" } Currently, auto-...
0
votes
2answers
57 views

Range arrays with custom step-size in Bourne shells

Say I want to create a range array of integers in a shell such that the array: Starts in $START_VALUE Ends in $END_VALUE Elements are $STEP_SIZE apart, starting from $START_VALUE. For anyone ...
0
votes
1answer
34 views

How to increase history in oh-my-zsh?

I just installed oh-my-zsh for the first time. I just want to know how can I modify the number of past commands that are remembered in history? Where can I set this setting?
3
votes
1answer
59 views

On passing arguments to programs through array variables

NB: though the question below features rsync, it is not a question about rsync; it is a question about zsh arrays. If I initialize the variable EXCLUDES like this EXCLUDES=( --exclude=/foo --...
2
votes
1answer
33 views

Possible redirection bug in zsh 5x

[This post's title needs some work; suggestions welcome.] The following command produces different outputs in zsh v. 4.x and 5.x: { ( printf "X\nY\n" printf "WARNING: foo\nWARNING: bar\n"...
2
votes
1answer
65 views

How can I configure zsh completion to launch a menu - for command options?

If I am cd'ing into a directory, there is a setting in my ~/.zshrc that tells zsh to always launch a menu when I hit tab on an ambiguous completion, e.g. ~% cd /etc/a tab will immediately cause a ...
3
votes
1answer
45 views

How to split a string on a control character?

I know how to split a string on a printable separator character; e.g. if the separator is ,: FOO='x,y,z' printf "%s\n" ${(s:,:)FOO} x y z But what if the separator is a control character, such as \...
3
votes
2answers
38 views

How do I set the editor command to use *only* for edit-command-line in zsh?

When I hit Ctrl+x, Ctrl+e in zsh, I can edit the current command line in by $EDITOR or $VISUAL. However, I'd like to use nano, and to get syntax highlighting for shell syntax there, I have to pass -Y ...
2
votes
2answers
64 views

How to store the printout of the last command in a shell variable in urxvt/zsh?

I'd like to have the printout (stdout and stderr) of the last command run within zsh available in a variable ready to use grep, etc on it.
1
vote
0answers
27 views

highlighting of zsh correction

When zsh's autocorrection suggests a change in long filename, it may be hard to spot which change is actually suggested: The example is of cause artificial as tab completion would've done the job (...
0
votes
1answer
49 views

Zsh's standard completion works fine, so why do people recommend to load compinit module?

If I put these lines and nothing else in my ~/.zshrc I get all the completion features I expected. # For autocompletion with an arrow-key driven interface zstyle ':completion:*' menu select # ...
1
vote
1answer
119 views

zsh HISTFILE - still read from ~/.zsh_history

I set my $HISTFILE env var to something custom, and my zsh is indeed writing to the new histfile. But when using up-arrow or other history-searching capabilities, it still reads from ~/.zsh_history. ...
5
votes
3answers
192 views

Why zsh and ksh93 chose to be non-compliant in pattern matching?

POSIX documentation for pattern matching said that: An ordinary character is a pattern that shall match itself. It can be any character in the supported character set except for NUL, those ...
7
votes
1answer
357 views

How can I pipe only stderr in zsh?

In bash: $ echo hi 2>&1 1>/dev/null | cat $ While in zsh: $ echo hi 2>&1 1>/dev/null | cat hi $ Is there a way to pipe only standard error while redirecting standard out?
1
vote
3answers
102 views

On `fork`, children processes, and “subshells”

This post is basically a follow-up to an earlier question of mine. From the answer to that question I realized that not only I don't quite understand the whole concept of a "subshell", but more ...
1
vote
1answer
21 views

On the relationship between shell initialization and desktop apps after a “graphic login”

I am very (zsh)/somewhat (bash) familiar with the shell's initialization sequence when the user logs in through a text interface. But what about the case of a "graphic login", IOW, when the user logs ...
2
votes
2answers
132 views

How to switch to root and use same dotfiles as my normal user?

I run zsh on Mac OSX, and sometimes want to switch in the terminal to the root user. I'd like to keep all my dotfiles, and environment path configuration and scripts from my regular user, and just do ...
0
votes
1answer
38 views

echo {Z..A}; out {Z..A};Why? [duplicate]

I'm a new Ubuntu user. I am reading this book "The Linux Command Line: A Complete Introduction" and practicing the code. That's fun, but I have trouble in Chapter 8: ➜ ~ echo {1..10} 1 2 3 4 5 6 7 8 ...
1
vote
1answer
52 views

How to split a string at some non-printable-character delimiter?

I know that if $VAR contains some string, I can split this string at, say, periods, to produce an array, like this: % VAR=$ZSH_VERSION % parts=(${(s:.:)VAR}) % printf '%s\n' $parts 5 0 7 What must ...
0
votes
1answer
135 views

How do I inform the rest of the system my shell has changed from zsh to bash?

I installed zsh because I thought I might prefer it over bash. I don't, and to revert it I have used chsh -s /bin/bash, which as myself gives You may not change the shell for 'cat'. I also changed ...
2
votes
1answer
206 views

sudo: nocorrect: command not found

I am using zsh and oh-my-zsh on Arch Linux. I am not able to make directory using mkdir edward@ArchLinux ~ $ sudo mkdir -p /samba/raspberry [sudo] password for edward: sudo: nocorrect: command ...
4
votes
0answers
55 views

Calling zsh completion function and obtaining its results

I'm trying to make use of zsh's completion widgets in my own scripts. At one point I'd like have access to the result of every completion that is active in zsh, or rather I want to obtain the final ...
0
votes
1answer
50 views

watch equivalent in zsh

In bash, watch (e.g. watch -n 5 ls -l) could be used to repeat the command at fixed intervals. This command seem to be missing on zsh. Is there an equivalent?
1
vote
0answers
10 views

Can I bind single keys in zsh when in vi normal mode? [duplicate]

I use urxvt with zsh and vi keys (bindkey -v). Is there a way to bind custom commands to single keys when in normal mode? For example, I'd like p to run xclip -o -sel clip and insert the result at the ...
0
votes
1answer
30 views

Execute a function before specific programs

This began with the want of adding SSH keys to ssh-agend on demand, but because this isn't possible with OpenSSH, I came up with this zsh script instead. But for a reason I can't figure out, instead ...
3
votes
1answer
234 views

(2x) zsh: command not found

I've finally decided to take the plunge and try out zsh...Running on a CentOS 7 machine. The only thing I find strangely aggravating is that for some reason each time I enter an unknown command, I get ...
1
vote
1answer
63 views

How can I get zsh's completion working in the middle of the filename?

This works Normally, zsh's tab completion works well. $ touch foo-1-bar foo-2-bar $ touch f<Tab> $ touch foo--bar ^ cursor here Pressing Tab again brings up a menu from which I ...
4
votes
1answer
147 views

Append (alter) each array element via parameter expansion (i.e. without printf)?

Let the script below exemplify my quandary.. #!/bin/zsh STUFF=( moose-hoof ovary clydsedale ) echo ${MINE=$(printf "MY-%s " $STUFF)} echo ${MINE_EXP=${STUFF/^/MY-}} MY-moose-hoof MY-ovary MY-...
3
votes
2answers
87 views

Move to the previous line of a multi-line command

When editing multi-line commands, with escaped newlines, I cannot move up lines. For example, suppose I enter echo \ one one line, then I press Enter, and then I want to edit the echo \ part of the ...
1
vote
0answers
43 views

Can I prevent zsh slowing with a large history?

I've just migrated from bash to zsh. I converted ~/.bash_history for use in zsh. It's 150 000 lines long. bash is almost instantaneous to start up, but zsh is now fairly slow, taking half a second to ...
0
votes
1answer
96 views

How can I delete to a slash or a word in zsh?

Bash behaviour I've just migrated from bash to zsh. In bash, I had the following line in ~/.inputrc. "\e\C-?": unix-filename-rubout Hence, Alt+Backspace would delete back to the previous slash, ...
1
vote
1answer
93 views

copy&paste in zsh

I've build myself this little script for zsh, to copy & paste within zsh to the system clipboard (basically got everything from here: zsh copy and paste like emacs) x-yank() { zle copy-region-...
4
votes
1answer
385 views

How to trigger a 2nd command when a specific command is run in the shell?

I'll explain my question with example. I run $ python manage.py to perform some action. I want to run another command $ xyz , just when any user runs the previous command. Thus, from now on, ...
1
vote
1answer
17 views

zsh jump to the end of copy from X clipboard

I would like to get Ctrl + V and Ctrl + X to paste / copy from zsh to X11. I found the following snippet to work but zsh does not jump to the character after paste. How could I do that. copy-to-...
3
votes
1answer
110 views

No zsh-syntax-highlighting within tmux

I experience proper zsh-syntax-highlighting (see here) when first opening a shell session, but as soon as I enter tmux, the syntax highlighting no longer appears. I found this Github issue ...
3
votes
2answers
72 views

Remapping Ctrl-P to Ctrl-O for getting the previous command?

I am using zsh with tmux and I like to have Ctrl-P as a shortcut to 'previous pane'. I would however still keep the original 'previous command' functionality of Ctrl-P and map it to Ctrl-O. How can I ...
3
votes
4answers
78 views

Sticky entries in shell history

Is there a way one could make some commands "sticky" in a shell history? I want to save some favourite commands that would be searchable with Ctrl+R, like the rest of the history, but they should ...
1
vote
1answer
154 views

How to programatically send break signal (Magic SysRq) through serial terminal

I have following setup - I have 2 computers connected by serial connection (null modem) emulating vt220. I'd like to send break signal (Magic SysRq) from shell script - is it possible without writing ...
1
vote
1answer
46 views

zsh glob pattern to match all files except one, does not work, despite EXTENDED_GLOB being set [duplicate]

I have a directory containing several files: $ ls tdir xx yy zz I'm looking for a zsh glob pattern, which expands to all (non-dot)-files except xx. This is what I tried: $ set -o EXTENDED_GLOB $ ...
1
vote
0answers
47 views

tmux start process if not already running

In my .zshrc, I have a bit of logic that will automatically start a tmux session or, if sessions are already running, prompt to attach to one of them or create a new one and attach to that. This all ...
0
votes
2answers
21 views

Looking for a (preferably “all-zsh”) alternative to printenv that can handle Unicode in variable names

zsh supports variable names with Unicode characters (if the multibyte option is set), but printenv (at least GNU's version 8.23 thereof) doesn't seem to be able to handle such variable names. For ...
0
votes
1answer
29 views

Why don't subshell expressions in ~/.zshenv lead to infinite regress?

I understand that ~/.zshenv gets sourced every time that an instance of zsh starts. This implies that having the following line ~/.zshenv would result in an infinite regress: (echo "$$ $(date)" >&...
5
votes
4answers
643 views

Why does `==` behave differently inside `[ … ]` in zsh and bash?

I get what I expected when doing this in bash: [ "a" == "a" ] && echo yes It gave me yes. But when I do this in zsh, I get the following: zsh: = not found Why does the same command (/...
3
votes
1answer
38 views

Looking for a map of the xinit/startx rabbithole

Can someone point me to an authoritative guide to the X11 initialization sequence that also explains how it dovetails with the shell's initialization? I'm trying to figure out how to make some ...
4
votes
0answers
29 views

How do I write a custom filename completer for specific directories in zsh?

I've found that file names with dates before the title are difficult to tab-completion. I'd like to write custom completion functions for these directories. How do I specify that the completer should ...
10
votes
3answers
652 views

How to implement “generators” like $RANDOM?

The special variable $RANDOM has a new value every time it's accessed. In this respect, it is reminiscent of the "generator" objects found in some languages. Is there a way to implement something ...
0
votes
1answer
71 views

bash-like last command in history using up-down arrow keys in zsh [duplicate]

In bash, we can use the up and down arrow keys to get the last or nth previous command in history. Can we do this in zsh?
4
votes
2answers
136 views

How can I kill my backticked yes process?

I was playing around in my terminal, which runs zsh. I typed the following: $ ` bquote> yes bquote> ` And then, yes started to run in the background, I think. Neither Ctrl + C nor Ctrl + \ ...