Zsh is a shell with many advanced command-line and scripting features.
3
votes
1answer
47 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
31 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: ...
1
vote
1answer
10 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
26 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
21 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 ...
1
vote
1answer
24 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
16 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
17 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
42 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
162 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
223 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
36 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
18 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
62 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
32 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
25 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
71 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 ...
1
vote
1answer
59 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 ...
3
votes
0answers
41 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
24 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
23 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
48 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
27 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 ...
3
votes
1answer
83 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 ...
3
votes
1answer
40 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
21 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
0answers
30 views
How can get the screen command to work properly?
I'm trying to work out how to use the Unix screen command. I'm using Zsh on Mac OS 10.11.3.
So far, nothing is working as described. (I don't have enough reputation to link to the tutorial I'm ...
0
votes
1answer
22 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
33 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 ...
4
votes
1answer
359 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
15 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.
...
3
votes
0answers
44 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
1answer
35 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
71 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
39 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
21 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
22 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
17 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
25 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
619 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
35 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 ...
3
votes
0answers
25 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
638 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
27 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
50 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 + \ ...
1
vote
1answer
17 views
Can I auto-complete by tab in zsh with regular expression
I use oh-my-zsh configuration. When I want to auto-complete, I need to first type correctly the initial letter. For example
go, then tab will give google-chrome. If I type *le-ch*. It didn't work. How ...
3
votes
1answer
20 views
command-click git commit ID in Terminal, and be taken to that commit in github?
I'm running a Mac and use iTerm with ZSH as my shell.
Currently I can command-click (⌘+click) on links or directories in my iTerm window, and that directory or web link will open.
Is there a way ...
-3
votes
1answer
63 views
Works in Bash but not ZSH? … alias ls='ls -lh' [closed]
alias ls='ls -lh'
Previously used this in bash to achieve default ls arguments
Trying to move to ZSH but have discovered this trick does not work.
Is there a preferred way to do this in ZSH?
...
0
votes
0answers
9 views
Why is zsh seemingly ignoring no_list_beep?
I have zsh (5.1.1) on OS X (10.10.4), and am using oh-my-zsh with various plugins.
When I type e.g. ls z in a directory with multiple items starting with z, zsh beeps and then displays an ...