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

learn more… | top users | synonyms (1)

3
votes
1answer
86 views

Ignore files for zsh's completion for SVN

I managed to configure zsh such that it does not suggest LaTeX temporary files when I use autocompletion for emacs by adding this line to my ~/.zshrc: zstyle ':completion:*:*:emacs:*:*files' ...
0
votes
1answer
197 views

Issues using sublime text to edit command line in VI mode

I am using the following to edit the current command line in Sublime Text 2 (using a working subl alias) .zshrc set -o vi EDITOR='subl'; export EDITOR bindkey -M vicmd v edit-command-line ...
2
votes
0answers
104 views

zsh: Echoing every statement?

I have an odd problem with zsh when I switch between shells in a particular way: Option 1 (works well): I start a zsh shell. I switch to tcsh with /bin/tcsh, and I switch back to zsh with /bin/zsh ...
2
votes
0answers
121 views

Is there a postexec/predisplay hook for ZSH?

I know zsh has a preexec hook that fires before the command is executed, but is there one that fires after the command has been initiated but before the output is displayed to the screen? I ask ...
2
votes
2answers
2k views

/usr/bin/env: zsh -: No such file or directory

I get the error /usr/bin/env: zsh -: No such file or directory ...when I run an executable zsh script that starts with the following shebang line: #!/usr/bin/env zsh - Also, FWIW, replacing - ...
6
votes
4answers
2k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
5
votes
2answers
409 views

Wrap command in the prompt

Is it possible to insert a separator after the command in a prompt? This is an example: ~/Desktop: ls -al ------------------------------------- total 80 drwx------+ 6 eddie staff 204B Apr 29 ...
4
votes
3answers
362 views

How to save current command on zsh? [duplicate]

I am typing a command, I remember I have to check something, if I press Ctrl+U the command disappears and I can type something else, but then the command I was typing is not in the history. Is there ...
2
votes
1answer
109 views

What does %\/ do (zsh prompt expansion)?

What does the sequence %\/ do in zsh prompt expansion? man zshmisc doesn't contain the string %\, which is where the rest of the prompt-specific expansions are. The sequence can be seen in Holmans ...
3
votes
4answers
164 views

Expansion with numbers in human readable format

So, I want to play some MP3s in a console player that takes file names as inputs. I have the following files, as given by ls -1 * where * get expanded by my shell (zsh): 1 - Main title.mp3 10 - End ...
2
votes
2answers
198 views

Stop Git submodule foreach from opening less for each module

I occasionally need to grep through git submodules for which I use: git submodule foreach 'git grep x' However, since switching to zsh I find a less prompt is opened for each submodule, even when ...
5
votes
2answers
158 views

Modifying zsh globbing patterns to use with cp

I'm trying to write a script to copy files recursively from a particular folder except files A.extn, B/*.extn and C/* where B and C are directories and extn is just some generic extension. This is ...
2
votes
2answers
159 views

How can a zsh script test whether it is being sourced?

The accepted answer for a similar question for bash does not seem to work for zsh. In fact, if I copy basically the same code given in that answer, to produce the script #!/usr/bin/zsh - # test.sh ...
2
votes
1answer
92 views

zsh - check arguments of a command before executing it

Question: Is there an easy way how I can teach zsh to check the command line before executing it? I know that I can completely wrap a specific program with an extra script, but this is not what I want ...
-1
votes
1answer
615 views

zsh: Is it worth the switch from bash? Is it the time? [closed]

I have been a bash user for years now. However, I find that zsh is increasingly gaining momentum. I came up with the following questions: Is zsh really becoming that popular? Will it compete with ...
2
votes
1answer
105 views

How to avoid parsing /etc/* files

When starting my shell with e.g. exec zsh from the command line, how can I have it not parse any /etc/ files? I read in the zsh guide that when a user starts a zsh shell, it processes the following ...
1
vote
2answers
114 views

Logging all input and output in zsh on demand

Is there any way to activate/deactivate the logging of all input and output on a zsh session? I am using oh-my-zsh with a customized prompt with colors, etc. and I would like to preserve all of these ...
1
vote
1answer
77 views

Directory stack order in zsh

I am working on Zsh 5.0.2 (latest stable version), and I noticed that: dirs -v and cd -<TAB> show a different list of directories (or at least directories in different order). Moreover, ...
5
votes
2answers
497 views

Preventing zsh from using aliases in CWD (prompt)

I have the following personalized theme activated with oh-my-zsh (latest version of zsh and oh-my-zsh): local return_code="%(?..%{$fg[red]%}%? %{$reset_color%})" local ...
2
votes
2answers
974 views

Excluding a directory name in a zsh recursive glob

I'm running zsh on Linux under setopt extended_glob ksh_glob glob_dots. I'm looking for something easy to type on the command line, with no portability requirements. I'm looking at a source code tree, ...
0
votes
2answers
58 views

Command in a variable [duplicate]

I am trying to run a statement where the name of the command is in a variable. For example: my_command='/path/to/some/command' $my_command -f foo -b bar -s something else But the above does not ...
1
vote
1answer
39 views

difference between omz “plugins” and “themes”?

What exactly is the difference, operationally, between plugins and themes in oh-my-zsh? I.e. how would things break (if at all) if a plugin were instead put among the themes, or a theme among the ...
15
votes
1answer
4k views

What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?

The title says it all. I'm looking for guidelines on what one should and should not include in the various startup files for zsh. I understand the order of sourcing of these files, and the ...
3
votes
4answers
415 views

zsh is in /usr/bin, but also in /bin, what is the difference?

The /etc/shells says it has zsh installed in /bin/zsh, but also in /usr/bin/zsh. brgr@envy17:~$ cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash /usr/bin/tmux ...
4
votes
1answer
232 views

Per-directory history in zsh

I am happily using zsh since a while now, and I am quite satisfied with my history settings, which are: # Write to history immediately setopt inc_append_history # History shared among terminals ...
2
votes
2answers
364 views

Why is `kill -s INT <zsh PID>` behaving differently from `Ctrl-C`?

Starting with: % donothing () { echo $$; sleep 1000000 } % donothing 47139 If at this point I hit Ctrl-C at the same terminal that is controlling the shell, then the function donothing does indeed ...
2
votes
1answer
245 views

preventing the screen from being cleared when exiting an ssh session

I have rdist set up to push out some of my dot files to all the remote machines that I need to ssh into. I also have zsh as my default shell on all of those machines. When I ssh into a machine and ...
1
vote
1answer
80 views

Get zsh to report directory to emacs

From the emacs manual Unlike Shell mode, Term mode does not track the current directory by examining your input. But some shells can tell Term what the current directory is. This is done ...
2
votes
1answer
778 views

dircolors on zsh: Unrecognized keywords: MULTIHARDLINK, RESET & CAPABILITY

I am trying to get the solarized color theme to work in my terminal. I read the instructions here but I get the following dircolors error: dircolors: `/home/avazquez/.dircolors_zsh':90: unrecognized ...
2
votes
3answers
583 views

Treatment of backslashes across shells

How do echo and printf treat backslashes in zsh, bash and other shells? Under zsh I get the following behavior: $ echo "foo\bar\baz" foaaz $ echo "foo\\bar\\baz" foaaz $ echo 'foo\bar\baz' foaaz $ ...
8
votes
4answers
2k views

Is it recommended to use zsh instead of bash scripts?

Can I assume that enough people have zsh installed to run scripts with a #!/usr/bin/env zsh as shebang? Or will this make my scripts un-runnable on too many systems? Clarification: I’m interested ...
12
votes
1answer
947 views

When is double-quoting necessary?

The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of ...
3
votes
3answers
175 views

Delete all but largest file of specific type

I am trying to organise the album art in my music collection so that only one image is assigned to each folder. My directory structure currently looks like: /path/to/music/Album Name/ ...
3
votes
1answer
236 views

How to print apparently hidden environment variables?

Environment variables can be shown with env; but, some are not shown. For example... echo $EUID might produce as result of 1000 yet env | grep EUID produces no result. What is this type of variable? ...
5
votes
1answer
134 views

ZSH: What's the difference between `.` and `source`?

I used to think that the built-ins . and source are equivalent. This question agrees with me when it comes to bash. However I encountered the following using zsh: desktop➜ ~/pst . env ...
4
votes
4answers
2k views

Double and triple substitution in bash and zsh

Follow-up to the background part in this question. In bash I can use {!FOO} for double substitution, in zsh ${(P)FOO}. In both, the old-school (hack-y) eval \$$FOO works. So, the smartest and most ...
3
votes
3answers
196 views

${!FOO} and zsh

${!FOO} performs a double substitution in bash, meaning it takes the (string) value of FOO and uses it as a variable name. zsh doesn’t support this feature. Is there a way to make this work the same ...
1
vote
2answers
171 views

Different shells for interactive and non-interactive work

Due to constraints at my workplace, the default shell for every user is tcsh, and I am required to use tcsh as my non-interactive shell (i.e. we do most of the environment configuration across ...
1
vote
1answer
79 views

Displaying ~ for $HOME in zsh prompt

I have my prompt set to the following: PROMPT=%F{reset}[%F{blue}%2/%F{reset}] which displays two parent directories as [foo/bar] However, when I'm in $HOME or one directory deep in $HOME, I'd ...
0
votes
1answer
322 views

Switching to another shell without copying environment variables

From tcsh, if I try: exec /home/path/to/my/zsh it works (I enter a Zsh shell) but if I try exec -c /home/path/to/my/zsh I get: -c Command not found How do I switch to my Zsh shell and start ...
5
votes
2answers
149 views

[ vs [[ : which one to use in bash scripts? [duplicate]

The zsh man page, in its section on test (aka [), explicitly advises against using it at all, and urges readers to use [[ whenever possible. The relevant section states: The command attempts to ...
1
vote
2answers
268 views

remove a host from the completion list for ssh in zsh

I once had some hosts named 'myhost', 'myhost1', etc. And now all those except 'myhost3' become invalid. I removed those from /etc/hosts and ~/.ssh/known_hosts, but zsh still completes them for me. Is ...
0
votes
1answer
1k views

oh-my-zsh theme doesn't seem to update unless I re-launch zsh

I've begun making my own oh-my-zsh theme, but I've run into a bit of a problem. I'm trying to change the color of the git output based on the name of the branch, and it works fine except for one ...
3
votes
4answers
479 views

Round/truncate digit in string in zsh (or with external tool)

I'm trying to do an interface to bc so it can be used intuitively and without the annoyance of getting "stuck" in it. I haven't got around to test it that much, because I got stuck on another detail, ...
1
vote
0answers
132 views

Navigating through the directory stack in zsh from the command line

In zsh, is there a way to navigate through the history of directories that I have visited (those listed in dirs) when I am typing a command in the command line? For example, say that I start typing ...
1
vote
2answers
122 views

How to get “current glob” in zsh

I want to do something like: $ convert [a,b,c,d,e].png -resize 50% <current_match>_half.png How can I do this? Is there some variable that stores the current match? I couldn't find anything in ...
5
votes
2answers
499 views

How can I create a function in zsh that calls an existing command with the same name?

How can I write a function in zsh that invokes an existing command with the same name as the function itself? For example, I've tried this to illustrate my question: function ls { ls -l $1 $2 $3 ...
4
votes
2answers
427 views

How can I change the umask for one command only?

How can I interactively execute a command in Linux (zsh, if it matters) with a different umask from the default, for one command only? Perhaps a combination of commands combined in a single line? The ...
1
vote
0answers
30 views

Make zkbd ignore $DISPLAY

Is it possible to make zkbd ignore $DISPLAY variable? I have set up when I log in to different X sessions and it is annoying if suddenly I need to reenter/copy configuration (and I have no idea why ...
1
vote
1answer
1k views

tmux exits abruptly right after loading

I just compiled my own version of tmux with libevent. Whenever I run tmux from zsh, tmux starts, but exits quickly returning [exited]. I read here that the problem could be my configuration for ...