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

learn more… | top users | synonyms (1)

1
vote
1answer
21 views

reset for loop counter

Simple question: if I have a for loop (zsh) over an unreliable list, by which I mean the list contains entries that can't be predicted beforehand, then can I reset the for loop counter? This ...
0
votes
1answer
28 views

Must pass urls in quotes

I'm trying pass a URL to mpv for it to play it as a network stream. This can be done in bash with the following syntax: $ mpv http://myvideosite.com However, zsh wants to evaluate the URL as ...
15
votes
6answers
682 views

How to type several file names with fewer key strokes

If I want to convert a pdf to a png image with imagemagick I do something like: convert -trim -density 400 this_is_a_very_long_filename_of_my_pdf_file.pdf ...
2
votes
1answer
44 views

Why do some letters or escape sequences not render correctly in urxvt?

With a special combination of shell (zsh w/ syntax hightlighting), terminal (urxvt) and configuration with Xresources, I noticed a strange issue with font rendering that only seems to occur with some ...
0
votes
2answers
483 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 ...
2
votes
2answers
38 views

how to filteri by asterisk or similar expression by rsync in zsh

I have a lot of files named like: /var/log/foo/2014-07-06-01.log ... /var/log/foo/2014-07-20-04.log Everyday I have several log files and I want to download specified day's log files: $ rsync ...
4
votes
0answers
442 views

Gnome-terminal and Zsh: keep current directory on new tab/window

I'm running gnome 3.10.1 on Arch with Zsh. I'm facing that problem that when I create a new tab or window from a terminal window, it resets the current dir to my home dir. I've already tried this: ...
4
votes
1answer
34 views

How can I get back into “normal” edit-mode after pressing esc in zsh (vi mode)?

I'm using zsh in vi-mode. When I go to normal mode with ESC and then back into insert mode (for example using i, a or s), the line editor kind of "protects" the part of the line in front of the char, ...
8
votes
5answers
824 views

Portable way to get script's absolute path?

What is a portable way for a (zsh) script to determine its absolute path? On Linux I use something like mypath=$(readlink -f $0) ...but this is not portable. (E.g., readlink on darwin does not ...
3
votes
2answers
31 views

Is there a way to bypass .zshrc on login?

I'm enjoying learning ZSH, but one thing's bugging me. If I put something in my .zshrc that renders the shell useless (I'm playing with something that affects the way the keyboard is interpreted), ...
2
votes
1answer
46 views

Issue with zsh segfaulting: how to further assess the issue?

I'm using Linux arch 3.15.2-1-ARCH x86_64. I don't use zsh (zsh-5.0.5-1) every day, otherwise I would have noticed it segfaults, when I launch it from the bash cli: arch kernel: zsh[2187]: segfault ...
2
votes
3answers
1k views

Ctrl + left/right arrow keys issue

After the last system update the ctrl + left/right arrow command on zsh terminal doesn't do anything. Also ctrl+ u has something wrong because usually that command erase from the cursor to the ...
3
votes
2answers
175 views

Thousands separator in printf in zsh

I have been trying to define a thousands separator in printf for a while now and I have discovered that zsh has some problems with it. In bash I can use something like: $ printf "%'d\n" 1234567890 ...
11
votes
0answers
350 views

How to fix tab completion so it doesn't hide entries?

I'm using oh-my-zsh on Mac OS X with homebrew'ed zsh 4.3.12. I stumbled recently on a weird problem. In scripts/not-used I have several .R files: breakdowns.R eventloop.R ...
5
votes
3answers
293 views

How to cd automatically after git clone?

I want to automatically cd to the directory created by the clone command after I git cloned something. Shell: ZSH if that matters.
1
vote
1answer
86 views

zsh: set TERM=screen-256color in tmux, but xterm-256color without tmux

I need my $TERM to be xterm-256color outside of tmux (in "plain" terminal with zsh), but screen-256color inside tmux. First I tried: add export TERM='xterm-256color' to my ~/.zshrc. add set -g ...
2
votes
2answers
35 views

zsh completion - show more options than just the alias

I am trying to modify the behaviour of zsh completion and its menus. I'm stuck, and I've read so much documentation it's making my head spin. The following is only an example; I'd prefer answers that ...
0
votes
0answers
48 views

zsh/Prezto: difficulties with right prompt alignment

This may be stupidly simple, but... I am trying to make my own prompt for Prezto. I have been using numerous prompts for reference (I can post a list if necessary). My RPROMPT and cursor are refusing ...
4
votes
2answers
159 views

Completion of words on the screen as in VIM (Bash or Tmux)

How can I configure Bash, Zsh or Tmux to complete the last matching identifier on the screen? Consider this common scenario: $ git fetch remote: Counting objects: 16, done. remote: Compressing ...
2
votes
1answer
59 views

List directories with dot directories last, then dot files

I'm aware of the ls option --group-directories-first but that's not exactly what I want to achieve. The output should be: (sorted by name ASC) Directories Hidden Directories Hidden Files
2
votes
2answers
86 views

Killing subprocesses after the script has finished or is killed

Say I have a script like the following #!/usr/bin/env zsh ./subscript.sh & # do stuff ... # do more stuff I would like the process running subscript.sh (and any processes initiated by it) to be ...
1
vote
2answers
241 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 ...
55
votes
9answers
2k views

Remember a half-typed command while I check something

I often find myself in the following position: I've started typing a long command at the bash prompt, but half-way through I find out I need to check something with another command. This is a problem ...
5
votes
5answers
207 views

Serialize shell variable in bash or zsh

Is there any way to serialize a shell variable? Suppose I have a variable $VAR, and I want to be able to save it to a file or whatever, and then read it back later to get the same value back? Is ...
3
votes
3answers
192 views

How do you “disable” oh-my-zsh (and zsh) without uninstalling it?

I was trying new dev environments including zsh and oh-my-zsh. Now that I have installed oh-my-zsh, it starts by default on my terminals (iTerm2 and terminal) always start with zsh and with the ...
3
votes
3answers
81 views

Can't open shell after changing default shell

I changed my default shell to zsh from bash in Ubuntu. I used the steps explained in http://github.com/sorin-ionescu/prezto and ran chsh -s zsh. After this, I couldn't able to log in to any shell as ...
5
votes
2answers
93 views

Command re-assigned

I found a Bash script snippet earlier with which to echo a string to stderr: echoerr() { echo "$@" 1>&2; } echoerr hello world This remained in my clipboard, and when I wanted to edit a file ...
4
votes
2answers
2k views

Spaces as line breaks from inline for loop command

Someone care to enlighten me as to why the spaces in the first command seem to be interpreted as line breaks? Also occurs substituting print for echo. $for l in $( find *.txt -exec head -1 {} \; ); ...
7
votes
5answers
233 views

Making zsh default shell without root access

I am using my school's computers and would like to use zsh instead of bash. I'd like to make it default, but I cannot run a command such as $ chsh -s $(which zsh) because I don't have admin ...
3
votes
0answers
27 views

How to combine zsh autocomplete for wrapper function arguments and existing command

I work mostly in gvim and many terminals. Originally, I preferred to open all my files in a single vim instance. To that end I used an alias to open files from my terminals in the current 'vim ...
2
votes
1answer
73 views

Double rm verification in zsh

When I do a rm * in zsh, I get something like this: 2014-06-08 10:14:23 $ rm * zsh: sure you want to delete all the files in /home/assay/assay/log [yn]? y rm: remove regular file `development.log'? y ...
1
vote
1answer
57 views

Send copy of a script's output to a file

Say I have a Zsh script and that I would like to let it print output to STDOUT, but also copy (dump) its output to a file in disk. Moreover, the script starts with the following option set -o xtrace ...
12
votes
1answer
798 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 ...
0
votes
1answer
62 views

Ruby Version Prompt (Oh My ZSH) not working outside of TMUX

I am working on some Ruby development, and I installed RVM on my Mac. I regularly use TMUX. I have Oh My ZSH configured to show the Ruby version in my prompt. When I am in TMUX it shows my ruby ...
5
votes
2answers
772 views

is there a way to set coloring for cd tab complete?

I use ubuntu 11.04. Is there a way to set coloring for output after tab completion listing of a cd, ls, or etc. ? i.e. myshell@root$ cd ~/user/files/ I hit tab... myfile myfoo mybar <-- this ...
3
votes
0answers
100 views

git completion with zsh: filenames with spaces aren't being escaped properly

Git completion: I'm having difficulty with git's filename autocompletions on my system. I'm using zsh (5.0.5) with git (1.9.3) on OS X (10.9.3). Both zsh and git have been installed via homebrew. ...
2
votes
0answers
45 views

Corrupt files after extracting with Cygwin's GNU tar

I have a bunch of tarball backups which I just restored onto my new Windows 8.1 + Cygwin system using GNU tar: zsh$ for file in **/*.tgz; do tar xvzf $file; done To my surprise a lot of these ...
3
votes
2answers
100 views

Start zsh with a custom zshrc

I want to be able to start zsh with a custom rc file similar to the command: bash --rc-file /path/to/file If this is not possible, then is it possible to start zsh, run source /path/to/file, then ...
3
votes
1answer
133 views

Why does this command to copy files in a for loop work in bash but not in zsh?

I'm trying to copy a bunch of files with the same name, but in different subdirectories, to a single directory, changing the names to ones based on the paths to the original files. I use a for loop ...
1
vote
1answer
29 views

Using a zsh function in find?

I'm on OS X and have defined a function called finderpackage that tries to determine if a folder is in fact a "package" (also, somewhat erroneously, known as a "bundle") according to the Finder. My ...
2
votes
1answer
389 views

zsh completion installations (autojump) - How to use them?

I just installed autojump and have oh-my-zsh installed in my system. I have included the log of the installation at the bottom of this post. Note that at the end it says: zsh completion has been ...
16
votes
4answers
767 views

Path independent shebangs

I have a script that I want to be able to run in two machines. These two machines get copies of the script from the same git repository. The script needs to run with the right interpreter (e.g. zsh). ...
2
votes
1answer
36 views

Globbing fails in zsh, but works in bash

I have an alias in bash, that I'm trying to port over to zsh. I thought it may have been the alias itself, but now it seems it's just the globbing. grep -irl --exclude=\*.{log,class,fuegoclass,dat}* ...
2
votes
1answer
30 views

scp wildcard not working in zsh

I have switched over to zsh, and it is working fine. One strange thing, when I try to scp with a * wildcard, it does not work, and I have to drop into bash. The second command below works fine. Any ...
4
votes
3answers
729 views

Passing named arguments to shell scripts

Is there any easy way to pass (receive) named parameters to a shell script? For example, my_script -p_out '/some/path' -arg_1 '5' And inside my_script.sh receive them as: # I believe this ...
0
votes
0answers
24 views

zsh completion doesn't correct ? (question mark) in paths

So, I've been pretty happy with my zsh completion and correction configuration for a while now, with this being a major exception. Configured as I have it, the shell routinely catches and corrects ...
7
votes
2answers
202 views

alias vs export for simple commands

For simple commands like less, is it better to make an alias or to export the options? Is there any benefit of one over the other? For example, if I want less to always use the -R option to show raw ...
37
votes
4answers
3k views

What features are in zsh and missing from bash, or vice versa?

As a Linux user, I've always just used bash because it was the default on every distro I used. People using other Unix systems such as BSD seem to use other shells far more frequently. In the ...
7
votes
4answers
1k views

How to silently get an empty string from a glob pattern with no matches

Say I have a folder with three files: foo1 foo2 bar 1. If I run list_of_files=$(print foo*) echo $list_of_files I get: foo1 foo2 2. If I run list_of_files=$(print bar*) echo $list_of_files ...
5
votes
2answers
64 views

How do I set Zsh autocompletion rules for second argument (of function) to an existing command's rules?

I have a custom Zsh function g: function g() { # Handle arguments [...] } Within it, I handle short arguments that execute Git commands. For example: g ls # Executes git ls-files ... g g # ...