Questions tagged [zsh]

Zsh is a shell designed for interactive use, although it is also a powerful scripting language.

Filter by
Sorted by
Tagged with
65 votes
9 answers
60k views

Change iTerm2 window and tab titles in zsh

I want to label the window tabs of terminal sessions. I'm using the zshell in iterm2 on OSX. Is it possible to change the label of a window tab dynamically in the terminal?
bneil's user avatar
  • 2,077
290 votes
5 answers
233k views

Zsh not hitting ~/.profile

I've just installed zsh on my Ubuntu system. It seems zsh isn't executing ~/.profile on init. To my best understanding, this should be an automatic behavior. What am I missing?
shmichael's user avatar
  • 3,263
57 votes
5 answers
52k views

invoke zsh, having it run a command, and then enter interactive mode instead of exiting

i'd like to start zsh similar to zsh -c 'my_prog option1 option2' but instead of exiting after running that command, leaving me at the propt of the invoked zsh (not wherever it is being called from)....
Autoplectic's user avatar
  • 1,268
47 votes
11 answers
35k views

Open a new tab in the same directory

Say you are in /very/cool/and/deeply/nested/folder . And you want to open a new terminal tab in the same folder. How would you do that? I use Mac OS and Zsh.
Nerian's user avatar
  • 1,297
47 votes
2 answers
60k views

zsh config - to export or not to export?

When setting variables in my ~/.zshrc I can either use export export PATH=/some/path or not PATH=/some/path How do these differ and which should I use?
jordelver's user avatar
  • 2,271
36 votes
7 answers
9k views

Separate up arrow lookback for local and global ZSH history

Is it possible to... Step up local ZSH shell history (actions only happened in that prompt) Step up global ZSH history (shared history is on) - default what happens when you press UP arrow when ...
Mikko Ohtamaa's user avatar
31 votes
4 answers
22k views

How can I do Ctrl-Z and bg in one keypress to make process continue in background?

I follow this pattern of suspending the task and then letting it to continue too often with the Ctrl-Z bg sequence. I was wondering is there any way to compress that to single keypress? My shell is ...
Ev Dolzhenko's user avatar
25 votes
4 answers
20k views

How do I customize zsh's vim mode?

Ok, so I finally made the great change. In my .zshenv, I changed my EDITOR: export EDITOR=vim There are a couple of questions I have that are so minor that I didn't want to start separate questions ...
Jason Baker's user avatar
  • 8,612
23 votes
2 answers
9k views

Writing shell scripts that will run on any shell (using multiple shebang lines?)

I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
swrobel's user avatar
  • 365
17 votes
2 answers
9k views

Resume Zsh-Terminal (OS X Lion)

OS X Lion has "Resume" feature, i. e. when you reopen an app it restores all windows and their contents. That works for Terminal as well. But if you use Zsh instead of Bash it doesn't restore opened ...
Simon Perepelitsa's user avatar
7 votes
1 answer
5k views

How to suppress error messages in zsh?

In zsh rm foo.bar prints rm: foo.bar: No such file or directory. rm foo.bar 2>/dev/null prints nothing, as I expect. But if the command contains pattern matches, the error is not suppressed by 2&...
Dr. Gut's user avatar
  • 578
1 vote
1 answer
3k views

Zsh grep with glob * is not working

The same command was working fine with bash git show --pretty="" --name-only HEAD | grep -i .*py zsh: no matches found: .*py Bash git show --pretty="" --name-only HEAD |grep -i ....
Knight71's user avatar
  • 113
1 vote
1 answer
2k views

Running ssh-agent doesn't appear to set environment variables

What am I not understanding? I run ssh-agent and it appears to set some environment variables but when I echo them, I don't get back what I expect. ❯ ssh-agent SSH_AUTH_SOCK=/var/folders/pn/...
skube's user avatar
  • 249
223 votes
12 answers
188k views

How can I make tmux use my default shell?

On a new setup, tmux is using bash instead of my default (zsh). How can I force it to use zsh?
re5et's user avatar
  • 2,343
159 votes
10 answers
222k views

How can I do a recursive find and replace from the command line?

Using a shell like bash or zshell, how can I do a recursive 'find and replace'? In other words, I want to replace every occurrence of 'foo' with 'bar' in all files in this directory and its ...
Nathan Long's user avatar
  • 26.5k
104 votes
3 answers
54k views

What exactly is <() in bash (and =() in zsh)?

I'm pretty comfortable with bash, but recently I ended up in a substitution I didn't know. What exactly is <(command) in bash? How does it compare to the =(command) in zsh? I understand that this ...
Henrique Barcelos's user avatar
72 votes
3 answers
77k views

Zsh says "no matches found" when trying to download video with youtube-dl

I downloaded youtube-dl using pip on CrunchBang (a Debian Wheezy distro). When I run youtube-dl {video URL} I get zsh: no matches found: {video URL} I guess it has something to do with zsh, ...
Lynob's user avatar
  • 5,360
55 votes
4 answers
33k views

How to remove zsh alias?

I have an alias which is predefined by an oh-my-zsh plugin. -> % alias gcm gcm='git checkout master' I'd like to remove it, i.e. I'd like alias | pcregrep "\bgcm\b" return 1. I've tried with ...
Gabor Marton's user avatar
44 votes
2 answers
23k views

What's the ZSH equivalent of BASH's $PROMPT_COMMAND?

BASH supports a $PROMPT_COMMAND environment variable that defines a command to be executed before any first-level interactive prompt. I'm looking for a ZSH equilvalent of that. The documentation says ...
Shnatsel's user avatar
  • 542
36 votes
2 answers
33k views

Shell SIGKILL Keybinding

How can I setup a keybinding to send a SIGKILL to the current foreground job? I already know that Ctrl+C is SIGINT and Ctrl+\ is SIGQUIT. I would like a more severe option. Is there anything ...
drewrobb's user avatar
  • 881
34 votes
6 answers
12k views

What zsh features do you use? [closed]

I do a lot of work in the terminal so I have learned a lot about my shell of choice, zsh. What features of zsh do you use to make yourself that much more productive at work? One of my favorites is ...
Frew Schmidt's user avatar
  • 1,261
24 votes
3 answers
4k views

Binding Fn-Delete in zsh on Mac OS X

In zsh, whenever I press Fn+Delete (which is forward delete) a tilde (~) gets inserted. This indicates zsh doesn't have the key bound. How do I bind it, and make it behave normally (delete in front ...
Thomas R's user avatar
  • 443
19 votes
3 answers
6k views

How to make Zsh not store failed command

Problem I'm using oh-my-zsh and Antigen to manage my Zsh. Sometimes I will accidentally enter a wrong/failed command into Zsh and it is very annoying when the zsh-autosuggestions plugin throws up ...
lightalchemist's user avatar
18 votes
4 answers
6k views

Locating the source of a function in zsh

I have this annoying issue in my zsh shell where a function is being declared somewhere and that function is named "cp" so it's overriding the normal cp behavior. I'm trying to locate the function ...
asolberg's user avatar
  • 383
17 votes
2 answers
5k views

ZSH: how to call ZLE widgets directly?

The documentation says in section 18.4 Widgets, that a "widget’s job is simply to perform some small action". But I cannot find a general description how to invoke these actions, i.e. how to call a ...
lumbric's user avatar
  • 848
7 votes
1 answer
5k views

How do I change my default shell on a remote server?

I tried changing it the way recommended in How do I change my default shell on a AWS instance?, as shown below: chsh -s $(which zsh) but that gave me an error. The system asks me to use ypchsh ...
Jakob Weisblat's user avatar
5 votes
2 answers
1k views

Access Finder's "Open With" menu from the commandline (for tab completion)

On Mac OS X, I know one can open a file from the commandline with its default application with open, and with other applications with open -a <application name>. Thus, open movie.avi open -a ...
ShreevatsaR's user avatar
5 votes
2 answers
3k views

Strange zsh autocomplete behaviour

Every time I use tab autocompletion with zsh instead of completing the current string, it gives me a new string + options to complete. It's hard to explane, so here is an example. This is what would ...
Leda's user avatar
  • 431
5 votes
2 answers
2k views

zsh: What does hist_find_no_dups mean?

HIST_FIND_NO_DUPS When searching for history entries in the line editor, do not display duplicates of a line previously found, even if the duplicates are not contiguous. However, when I ...
aosho235's user avatar
4 votes
1 answer
3k views

npm commands not working on WSL with zsh

I've recently started using WSL, I've installed zsh and done some config. I am however unable to use npm commands in the WSL bash window. I can happily use npm in Git Bash Cygwin, Command Prompt, etc....
SGouws's user avatar
  • 143
4 votes
2 answers
2k views

How do I handle multiple quotes in an alias (for bash or zsh)

I am using zsh, and I am trying to use python as a simple calculator. I'm very familiar with python, but can't seem to get the alias (or function) to work properly. So far I've got: pycalc() { ...
AtHeartEngineer's user avatar
3 votes
1 answer
612 views

Different behavior of $( … $RANDOM … ) in zsh and bash functions

This: woof() {         /usr/bin/woof -p $(expr $RANDOM % 32768 + 1024) $@ } Always returns same number for parametr -p on zsh. In bash $(...) is evaluated on every call. Replacing $( ... ) with $[ .....
korda's user avatar
  • 178
2 votes
1 answer
1k views

Having your shell commands run after consecutive ssh

I have a function in my zsh source file ~/.zshrc: function cr() { ssh -p 5022 [email protected] ssh servername2 screen -ls } However, everything after the first ssh seems to be ...
JKHA's user avatar
  • 181
2 votes
2 answers
2k views

On OS X, how do I start Cocoa emacs *and* bring it to front?

I wrote a little zsh function to allow me to run emacs from the command-line: function emacs() { /Applications/Emacs.app/Contents/MacOS/Emacs $@ & } This works perfectly, but it seems to ...
Jason Baker's user avatar
  • 8,612
0 votes
2 answers
676 views

How can I run a bash script in zsh?

I want to run a script written for bash in zsh. If I run which bash, I get /usr/bin/bash Following this answer I have created the following script #!/usr/bin/bash echo 'Hello' The file hello is in ...
Psionman's user avatar
  • 153
0 votes
2 answers
2k views

^C not working in zsh on Mac OSX

Ctrl-C stopped working for me at the terminal when using zsh (on mac osx). I didn't notice the exact moment that it happend so I can't be sure what caused it. I didd't update zsh in a while though. ...
Vitaly Kushner's user avatar
161 votes
5 answers
1.2m views

Where is the .zshrc file on Mac?

I’m using iTerm and wanted to customize the look of my terminal window using Oh My ZSH!. And according to the documentation I need to change the ~/.zshrc file and add a ZSH_THEME value: Once you ...
Leon Gaban's user avatar
  • 2,555
109 votes
6 answers
97k views

scp with zsh : no matches found

when I try scp over zsh, I get scp hostA:Descargas/debian-6.0.4-* [email protected]:Escritorio/Software/ zsh: no matches found: hostA:Descargas/debian-6.0.4-* the same command work in bash
juanpablo's user avatar
  • 7,134
100 votes
15 answers
78k views

zsh starts incredibly slowly

ZSH takes about a second and a half from creating a new terminal window to being ready. I'm pretty sure that the culprit is compinit. I haven't been able to find good documentation on compinit, but ...
Eli's user avatar
  • 1,103
59 votes
2 answers
48k views

oh-my-zsh history completion

I have recently switched to zsh, using robbyrussell's oh-my-zsh. Before that i used bash with a lot of custom stuff and i am only missing one thing because zsh is trying to be 'too smart': If i type ...
Patrick Oscity's user avatar
56 votes
3 answers
44k views

Command history in zsh

Currently I have zsh set up in such a way that command history is shared between all sessions immediately. Say I have a terminal emulator open with two tabs, each with a zsh session, A1 and A2. If I ...
Art's user avatar
  • 1,251
48 votes
1 answer
27k views

How can I make zsh tab completion fix capitalization errors for directories and files?

I switched to zsh completely on a previous arch install and I LOVED it mainly because arch is one of the distros that capitalizes your Documents, Downloads, Music and such directories in your ~ ...
Aaron's user avatar
  • 481
48 votes
4 answers
40k views

UTF8 characters in windows 10 bash terminal

I have installed the new bash shell on windows 10. I'm using it together with ZSH. However, none of the utf8 characters work, they appear as square blocks. How do I enable utf8 character encoding in ...
Ortix92's user avatar
  • 1,011
44 votes
4 answers
20k views

Tmux and ZSH custom prompt : bug with window name

I have customized my ZSH prompt with oh-my-zsh to make it more readable and add information about git if I'm in a repository. Example : bob@inf [~/docs] % bob@inf [~/src/nicest] master % (in a git ...
Adrien Coquio's user avatar
44 votes
3 answers
100k views

How can I configure the color of 'ls' directory under zsh

I am using 'zsh'. In some directory, when I do ls --color=tty. I see some directories have 'blue text' with 'green background', which makes them hard to read. Can you please tell me how to configure ...
michael's user avatar
  • 5,945
42 votes
2 answers
19k views

Iterating over keys (or k/v pairs) in zsh associative array?

In zsh, I want to iterate over an associative array. I need both keys and values. But when I iterate over the associative array normally (for x in $assoc_array), I get only values. All examples I'...
Philip's user avatar
  • 1,595
40 votes
6 answers
28k views

ALT+arrow moving between words in zsh and iTerm2

I logged in on one of hosting provider servers and noticed ALT + left and ALT + right moved between words in a shell prompt in GNU Screen. What kind of key bindings I need to configure and where to ...
Mikko Ohtamaa's user avatar
36 votes
5 answers
31k views

How to change the default shell in Cygwin?

I am trying to change my default shell from bash to zsh in cygwin. The normal unix command chsh isn't available on cygwin The etc/passwd file it seems isn't used anymore in existing versions of ...
gyaani_guy's user avatar
33 votes
2 answers
86k views

In zsh on mac OS, where is the source of $PATH? I cannot find it in .zshrc

When I run echo $PATH, my output is: /usr/bin:/bin:/usr/sbin:/sbin But in my .zshrc, $PATH is commented out: # If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/...
OkBeat9's user avatar
  • 431
33 votes
2 answers
9k views

zsh, up arrow only repeats unique commands?

I'm looking for a setting that will make it so that when i hit the up arrow, zsh shows commands i have recently edited. The catch is, i only want unique commands. Currently, if i type echo "hello ...
Lee Olayvar's user avatar