Questions tagged [zsh]
Zsh is a shell designed for interactive use, although it is also a powerful scripting language.
122
questions
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?
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?
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)....
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.
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?
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 ...
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 ...
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 ...
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 ...
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 ...
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&...
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 ....
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/...
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?
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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() {
...
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 $[ .....
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 ...
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 ...
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 ...
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. ...
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 ...
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
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 ...
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 ...
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 ...
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 ~ ...
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 ...
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 ...
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 ...
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'...
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 ...
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 ...
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:/...
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 ...