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

learn more… | top users | synonyms (1)

5
votes
2answers
112 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 ...
1
vote
2answers
126 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
71 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
vote
1answer
90 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
votes
1answer
487 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 ...
1
vote
1answer
67 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, ...
1
vote
0answers
108 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 ...
2
votes
2answers
674 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
56 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 ...
9
votes
3answers
3k views

Switching to `zsh`: Are all bash scripts compatible with `zsh`?

I'm looking to switch from bash to zsh but concerned about compatibility of bash scripts. Are all bash scripts/functions compatible with zsh? Therefore, if that is true is zsh just an enhancement to ...
4
votes
1answer
145 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 ...
9
votes
1answer
3k 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 ...
5
votes
3answers
725 views

Silently start task in background

I know that you can use this to start a process in the background, without getting the notification when the process is put in the background and when it is done like so: (command &) &> /dev/null ...
8
votes
2answers
941 views

How can I run a command in zsh without pushing it onto the current session's history?

Both bash and zsh support a shorthand of not placing a command in history if you prepend it with a space. This works great across sessions (if you've setopt histignorespace). However, the command is ...
1
vote
1answer
70 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
604 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
302 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 $ ...
6
votes
4answers
1k 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 ...
3
votes
3answers
155 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
167 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
122 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 ...
1
vote
2answers
149 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
68 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
195 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
119 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 ...
7
votes
1answer
1k views

How to enable ctrl-R in zsh

I recently switched to zsh (finally) and am loving it! So far one thing that I am missing is ctrl-R to do incremental history search. I have the history set up properly HISTSIZE=10000 ...
0
votes
1answer
863 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 ...
1
vote
2answers
112 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 ...
2
votes
2answers
81 views

Expand less-than sign when using multios and brace expand

With zsh multios set (setopt multios) it's possible to do things like: < in1 < in2 > out and: < in > out1 > out2 which is very convenient. I want to combine this feature with ...
2
votes
1answer
179 views

Distributing thousands of files over subfolders

I have a folder A with hundreds of thousands of files. I would like to move these files to new subfolders S_i, with, say, 100 files in each (the last folder may have less than 100 files) In other ...
2
votes
2answers
315 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
27 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 ...
2
votes
2answers
297 views

Screen: “Cannot exec /my/path/to/zsh” with local shell

Whenever I try to run screen under a Zsh shell that I compiled under my home directory, I get the following error: > screen Cannot exec '/my/path/to/zsh/bin/zsh' The Z shell is perfectly ...
3
votes
1answer
138 views

How can I configure zsh to let it explain to me where I can retrieve an executable instead of saying file not found?

In the default configuration of bash in ubuntu, when you type the name of a software which is not installed, bash explains how to install it if the executable if it exists, or how to install an ...
0
votes
1answer
96 views

Combining parameter expansion with modifiers in zsh

Say I have the following $f1=/some/path $f2=/some/subpath $f3=/some/other/subpath If I try: test1=${$f1/$f2/${f3:t}} zsh complains with bad substitution. However: test2=${f3:t} works well. ...
1
vote
1answer
105 views

How to more easily specify tasks for batch, using command prefix tool?

The tool batch that comes with the atd daemon is pretty useful in principle, running commands only when the system utilisation falls below a certain level (by default, 1.5). However, using it (and ...
1
vote
1answer
97 views

zsh completion: getting file names from a specific directory

OK, a little background: I use a Mac, and I do as much as possible in the CLI. In particular, I frequently pop in a USB stick, cp or mv a file over, and then immediately wish to eject (unmount and ...
1
vote
2answers
429 views

OS X setting environment variables

I have OSX 10.8.2 with ZSH as my shell and iTerm as a terminal (don't know if the last thing is relevant). I have to mention that I'm relatively new to OSX. I'm trying to set up some environment ...
2
votes
2answers
151 views

Aliasing 'python' to 'ipython' only when 'python' is run without args

I thought it would be nice to have an alias (in ~/.zshrc) to have 'python' aliased to 'ipython' ONLY when 'python' is run without args (otherwise, programs won't launch). First of all, how to express ...
4
votes
1answer
152 views

Is there a command for switch to vicmd mode in zsh?

I have mapped alt-k and alt-j for browsing history, but I would like to switch vicmd automatically whenever I call up a history entry, because most of the time I need to move the cursor to a certain ...
8
votes
1answer
399 views

What is the difference between which and where

What is the difference between where and which shell commands? Here are some examples ~ where cc /usr/bin/cc /usr/bin/cc ~ which cc /usr/bin/cc and ~ which which which='alias | ...
3
votes
2answers
194 views

Avoiding temporary files in zsh [duplicate]

Possible Duplicate: Shell programming, avoiding tempfiles Say I have the file data.txt, and the command cmd. cmd takes one argument, a file. Or, you could use stdin. Now, say data.txt is ...
0
votes
2answers
381 views

Comparison of shells? [closed]

Do shells have any actual advantages or disadvantages? They can all run any binary, they all support pipes and > (output to file). Why would one choose bash over sh, or sh over ksh, etc? Why does ...
7
votes
4answers
436 views

mv * folder (avoiding 'cannot move' error) [duplicate]

Anytime I want to move thousands of files to a new folder, I always encounter the same problem. > mkdir my_folder > mv * my_folder mv: cannot move 'my_folder to a subdirectory of itself ...
2
votes
2answers
138 views

Picking a random file from each subfolder

Inspired by the accepted answer to this thread: List X random files from a directory, I tried to put together two lines that would pick one file from each subfolder of my current directory, with no ...
2
votes
1answer
85 views

zsh autocompletion for symlinks

Say I have a folder parent with a subfolder, subfolder and a symbolic link symbolic_link. I noticed that if my current working directory subfolder and I try to do cd ../sym[TAB], it will not ...
3
votes
2answers
449 views

Upgrade zsh on red hat 5 x86_64

My machine is running RHEL 5 x86_64 I'm facing a problem with oh-my-zsh The zsh version on my machine is zsh --version zsh 4.2.6 (x86_64-redhat-linux-gnu) There are no upgrades available via yum. ...
1
vote
1answer
199 views

How to make HOME, END to work on terminal without X

my current keys config is: typeset -A key key[Home]=${terminfo[khome]} key[End]=${terminfo[kend]} key[Insert]=${terminfo[kich1]} key[Delete]=${terminfo[kdch1]} key[Up]=${terminfo[kcuu1]} ...
12
votes
1answer
480 views

Dynamically update completion list in zsh

I find zsh's result lists for Tab completion quite useful, however I'd like to tweak their behaviour a bit: They should appear when I Tab for the first time and afterwards dynamically update with ...
2
votes
1answer
472 views

Select text in urxvt terminal using Shift+Arrow or Ctrl+Shift+Arrow

I'm using zsh + rxvt-unicode as a terminal simulator in Archlinux. I've successfully setup navigation in the terminal using Ctrl+Arrow keys, but I can't setup the terminal to be able to select text ...