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

learn more… | top users | synonyms (1)

0
votes
0answers
15 views

How to loop over users?

How can I loop over all users in a shell script? I am writing a shell script to perform cleanup on a system. And if the script is run as root, I want to perform the requested actions in all users' ...
1
vote
1answer
23 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
0
votes
3answers
35 views

read command in zsh throws error

In zsh, running the command read -p 'erasing all directories (y/n) ?' ans, throws the error, read: -p: no coprocess But in bash, it prints a prompt. How do I do this in zsh?
2
votes
1answer
16 views

Vim and unified diffs

In my daily work, I only deal with unified diffs, so I would like to define the alias alias diff='diff -puN' in my .zshrc. This alias is not respected when I use the shell from the vim command ...
16
votes
1answer
267 views

Why does exporting vim as EDITOR in zsh disable keyboard shortcuts?

My .zshrc looks like this: export EDITOR="/usr/bin/vim" Now when I open a terminal and enter a keyboard shortcut like ctrla to go to the beginning of the line, it doesn't work. Instead, the string ...
2
votes
1answer
23 views

zsh case-insensitive mid-word completion

I have the following in my .zshrc for case-insensitive tab completion. I encountered a situation where the tab completion fails, and I can't figure out why. autoload -U compinit && compinit ...
1
vote
0answers
39 views

changeshell -chsh (to zshell) asks for password often [closed]

I use ubuntu 14.04 in my Desktop. I switch to zsh using the command chsh -s /bin/zsh from .bashrc. And when i open a new shell prompt, it always asks for a password. When i do source .zshrc, it ...
4
votes
3answers
478 views

Echo command with AND operator doesn't exit

echo hai && echo bye prints hai bye while echo hai && echo $? prints hai 0 When the first echo command's return value is 0, how does the echo statement after AND operator ...
-2
votes
2answers
47 views

autocomplete weirdness as a result of ugly hack for zsh prompt

I currently have the following line in my .zshrc: export PROMPT=$(printf "\e[38;5;6m")%m$(printf "\e[m")%d-%h:" " Which is supposed to show the hostname in blue and history and current working ...
2
votes
2answers
103 views

zsh keeps forgetting PATH vars

I'm using [oh-my-zsh] in iTerm on MacBook running Mavericks. I have iTerm set to source my .zsh file on load, and mostly that works. cd && source .zsh Except when it doesn't. Sometimes, ...
3
votes
1answer
36 views

Shell glob - substitute file path arg with file's contents

In curl command, there is --data option, which substitutes the file contents when the option value is prefixed by @ symbol like, curl -X POST --data @abc.json hostaddr.com abc.json file contents ...
1
vote
3answers
98 views

Bash long string, no word splitting?

I want to tidy up some script with long commands, so that for example: { somecheck || somecomand "reallyreallyreallyreallyreallyreallylongstring" } &> /dev/null & becomes something like: ...
0
votes
1answer
34 views

zsh parse error after alias do=…

I have the following .zshrc file in my home directory: # modify the prompt to contain git branch name if applicable git_prompt_info() { current_branch=$(git current-branch 2> /dev/null) if [[ ...
2
votes
1answer
33 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
4
votes
0answers
43 views

How to make zsh correct remember my decision

I have enabled correction (I wouldn't call it autocorrection specifically because of this issue) in zsh by enabling setopt correct in my .zshrc. Now, when I type dtae in a terminal, I get: dtae ...
0
votes
1answer
52 views

What does $'text' do exactly in Bash? Can it be used in Zsh?

I recently run into the following proposed solution: cat results.csv | tr $'\x01' \\t > result.csv to convert a malformed csv file (one that uses \x01 unicode as a separator) into a correct one. ...
1
vote
0answers
40 views

Making zsh filename completion case-insensitive everywhere

I have the following line in my zshrc to make filename completions case-insensitive: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' This works most of the time but I’ve noticed that if I ...
3
votes
3answers
55 views

Is there a nice way to set directory/project local environment variables?

I have been working on several projects, and they require different environment variables (e.g., PATH for different versions of clang executables, PYTHONPATH for several external modules). Whenever I ...
4
votes
2answers
60 views

Coming back to a command I have partially written [duplicate]

Often I find myself partway through writing a long command (or chain of commands) and realise I need to run another command before I can finish typing out this current one. Examples Sometimes, I... ...
2
votes
1answer
238 views

alias -g '${1+“$@”}'='“$@”', what does it do?

Most makefile have this strange set of symbols '${1+"$@"}'. $@ is the makefile target filename. But why does, people try to use the complex symbol like '${1+"$@"}'?
8
votes
1answer
129 views

Why does brace expansion range use two dots instead of three (ellipsis)?

I finally understood/discovered why I never got to using bash's (and also zsh's) brace expansion range properly: the syntax is {1..10} instead of what I assumed to be an ellipsis, i.e. {1...10}. May ...
4
votes
5answers
163 views

How can I use a wildcard to match just files, not directories?

I have a folder called home/homeLife I have a file called home1 home2 and home3 stored in /home I want to move all files that start with home* to home/homeLife/.. I typed mv home* /home/homeLife ...
3
votes
1answer
40 views

Zsh gpg2 autocompletion

I am using zsh with oh-my-zsh on OSX. I installed gnupg2 from homebrew giving me the executable gpg2. Unfortunately zsh auto completion appears to only support gpg (even though that executable is not ...
0
votes
0answers
39 views

zsh git command auto-complete add extra origin to the git branch name

After I clone a git repository locally, I want to switch branch to, says, 'ABCD'. $ git branch -a * master remotes/origin/ABCD remotes/origin/HEAD -> origin/master remotes/origin/master $ ...
1
vote
0answers
17 views

Is there a better to find out the script location which is part of a zprezto module?

I am writing a custom module to extend the zprezto framework for myself. The goal is to be able to start a tmux with proper configuration by name. Here is the code of the init.zsh of my custom module: ...
3
votes
1answer
58 views

Combining zsh’s tab completion with case insensitivity

I have zsh 5.0.7 configured to use case-insensitive tab completion with zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' The problem I’m having is that this case insensitivity often leads ...
0
votes
1answer
65 views

How to turn on tab completion in zsh/prezto?

I have installed prezto and trying out zsh. However tab completion is not on by default. What is the best way to enable tab completion in prezto?
2
votes
0answers
29 views

Why does select-word-style stop me from using backward-kill-word for leading whitespace?

If I have just some whitespace at be beginning of my zsh prompt, I can usually ^W (backward-kill-word) it away. However, as soon as I load select-word-style - even if I don't select any special style ...
3
votes
1answer
88 views

Why is `setopt nohup` required to make `nohup watch` work in zsh?

In zsh, setopt nohup seems to be required to make nohup work, as follows: # nohup does not work without setopt nohup ➜ /tmp zsh ➜ /tmp nohup watch ls & [1] 31556 nohup: ignoring input and ...
0
votes
1answer
28 views

Is there a valid way of exporting a variable across different shells?

For some reasons, Im using ksh and zsh in my scripts and returning to -bash, I need to use already set variable values in the spawned shells, writing it to some temp file and using that didn't look ...
1
vote
0answers
43 views

How can I complete a -N numeric parameter?

I'm writing an autocomplete script for supervisorctl. Is it possible to complete a numeric parameter such as -6, -999 etc? Currently my call to _arguments looks like, which doesn't work: _arguments ...
1
vote
1answer
64 views

Ctrl-Arrow does not work anymore after installing Prezto

I have this in my .inputrc: "\e[A": history-search-backward "\e[B": history-search-forward set show-all-if-ambiguous on set completion-ignore-case on # mappings for Ctrl-left-arrow and ...
3
votes
1answer
63 views

Filename expansion from date ranges

Consider dates in the ISO 8601 format i.e. ‘YYYY-MM-DD’, e.g. 2015-01-28, and say we have a folder with files of the form: AAAA_<date>_BBBB I am looking for a glob pattern in zsh (or Bash) ...
2
votes
1answer
75 views

terminal converts first letter to uppercase

After a $ vagrant ssh into a Centos 7 VM, - If I type a command in the VM terminal that uses zsh shell, the first letter gets uppercased. How can I stop this behaviour? I briefly looked at $ stty ...
2
votes
1answer
75 views

Multi-month view in calendar (cal) in OS X

I am hoping to run some of the commands listed in this article, e.g.: cal -3 which is supposed to show me the last month, this month, and next month. This command does not work in OS X. $ cal -3 ...
2
votes
2answers
102 views

Export Command History into a Shell Script

Often I have complicated installation procedures to follow, like having to build dependencies for buildtools, to build dependencies for the application I wish to install from source. Once I have done ...
1
vote
2answers
53 views

Why does zsh allow name to be null in ${name:-word}?

From zsh documentation: ${name-word} ${name:-word} If name is set, or in the second form is non-null, then substitute its value; otherwise substitute word. In the second form name may ...
1
vote
2answers
68 views

ls .. doesn't work properly with symlinks

I have directories set up a bit like this ~/code ~/code/src ~/code/build -> /path/to/somewhere/else That last one's a symlink. If I do this cd ~/code/build ls .. then I get the listing for ...
1
vote
1answer
83 views

Every time I run tmux, new ssh-agent child process is started (zshell)

Every time I start tmux or split tmux, new instance of ssh-agent is started ("Agent pid XXXX" appears on the top), which is quite annoying because I have to type the key password every time I want to ...
3
votes
2answers
111 views

Compatibility scripting: Save $? for use later

I would like to write a small part of a script that saves the error status, executes some other code, and sets the error status to the original error status. In Bash it looks like this: << some ...
4
votes
1answer
137 views

Tab autocompletion of accented characters with oh-my-zsh doesn't work

I am not able to properly display autocompleted filenames that contain accented characters like ã in my shell configuration of zsh and oh-my-zsh. I've created a filename cão.txt to demonstrate this ...
1
vote
2answers
79 views

Zsh completion on the second command or after an alias?

I have changed my OS X Yosemite shell to Zsh and configured with "oh my zsh" plugins, recently i installed proxychains-ng to proxy command line tools, but i found zsh completion does not work on the ...
1
vote
3answers
357 views

How could I reach root after switching from bash to zsh?

It's very weird that after switching to zsh from bash, I can't access root. I normally use 'su' to login as root after I login as a normal user (username is normalusername) with less privileges. And ...
0
votes
1answer
21 views

Why urxvtc doesn't accetp zsh functions when called with a “-c” argument?

In order to launch a new terminal and run a zsh function on it, I am trying to run the following command from within an urxvtc terminal (the urxvtd is running as a systemd service) urxvtc -e zsh ...
4
votes
2answers
248 views

Running commands stored in shell variables

The following works in my shell (zsh): > FOO='ls' > $FOO file1 file2 but the following doesn't: > FOO='emacs -nw' > $FOO zsh: command not found: emacs -nw even though invoking emacs ...
1
vote
2answers
119 views

Passing a command with arguments to a script

I am trying to write a shell script that receives as an input a command with arguments and runs it. As an example, I am hoping to use this in cron as follows: 0 11 * * * my_wrapper.sh "task_name" ...
1
vote
1answer
157 views

Redirection differences between &> >& and 2>&1

On this SO thread and a few other threads I have seen the following commands for redirecting stdout and stderr to a file. Are they all equivalent? Is there any difference between them? command1 ...
0
votes
1answer
70 views

how to find file defining an alias

I am having a problem I'm not sure how to get around. Somehwhere on my system, I have an alias defined as such: alias subl=\''/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'\' I ...
8
votes
3answers
368 views

How can I list all shell variables?

Reading about this question: In zsh how can I list all the environment variables?, I wondered, how can I list all the shell variables? Also, does the distinction between shell variables and ...
1
vote
1answer
25 views

Switching shells for one cron job

Say I have the following in my crontab: * * * * * command1 -option A; command2; command3; etc. I would like cron to run the commands I have in that line with a specific shell. How can I do that? ...