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

learn more… | top users | synonyms (1)

1
vote
1answer
12 views

tmux/zsh messes up pasted text

When I paste text into a tmux shell running zsh by select it with a mouse and then hitting 3rd mouse button, it prefixes the text with "200~" and adds a "~" at the end. For example, if I have the ...
0
votes
0answers
18 views

Text appears twice in zsh prompt [on hold]

I use virtualenv, which updates the zsh shell prompt when you run the activate script. It has a line that looks like this: PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" I expect to see a prompt like ...
2
votes
1answer
32 views

ssh/mosh to a remote interactive shell and run specific function

I have the following alias on my local machine: alias gom='mosh -- user@host "/path/to/specific/zsh"' I use it to connect to a remote machine with an interactive shell. I would like to modify this ...
2
votes
1answer
28 views

What files were sourced, zsh

I use oh-my-zsh with zpretzo, and I keep forgetting the zsh files it sources that I want to edit. How can I ask the shell what source files it sourced?
1
vote
0answers
7 views

Global [multiple sessions] directory stack

For the current zsh session I use dirs -v command to print the directory stack. I'd like to have an analogous tool that shows me the directory stack of all sessions, also the closed ones. Or if not a ...
0
votes
1answer
41 views

Silently timeout command in zsh

This is an oft-asked question: Superuser/loop-start-program-and-kill-after-time-out SO/bash-script-that-kills-a-child-process-after-a-given-timeout SO/bash-run-a-process-for-limited-time-period ...
1
vote
1answer
45 views

How do I test if a file exists using ZSH? [duplicate]

This question is about ZSH, not bash. I have the following lines in my .zshrc file. Whenever I open a terminal I get a no matches found error referencing the line with the if statement. if [[!( -a ...
2
votes
1answer
40 views

Is there any plugin for zsh or bash that does heuristic filename completion?

Such as if $ ls program_v1.21.rb program_v2.01.rb program_v2.01_final.rb so when I $ echo progv2fin[TAB] it completes to $ echo program_v2.01_final.rb Sure there must be something, but I ...
2
votes
4answers
30 views

zsh: map command to array

suppose you have an array a=(foo 'bar baz') is there a more obvious way to apply a command/function to every array element and save the resulting strings into another array than this: b=() for e in ...
10
votes
3answers
237 views

Defining an alias and immediately use it

In zsh this works fine: alias foo=ls foo But this does not: alias foo=ls; foo Pressing enter an extra time is not an issue when running interactively. But when running through ssh it suddenly ...
5
votes
2answers
112 views

In zsh, how can I more quickly disown the foreground process?

My method for disowning the foreground process takes too much effort. Suppose I have a process in zsh's foreground. I want to disown it, so I can close the shell without the process being sent a ...
1
vote
0answers
23 views

Byobu - New window with same ssh session?

Is there a way to configure Byobu to use same ssh session in a new window. For e.g. Open Byobu window ssh into a remote host Press 'F2' to open a new window. This opens the terminal with ...
2
votes
3answers
50 views

Preventing terminal disconnection from killing a running job in zsh [duplicate]

I went through the top answer to this question: Difference between nohup, disown and &, and I read specfically the following: With disown the job is still connected to the terminal, so if the ...
1
vote
0answers
20 views

How to quickly search and navigate to the particular sub directory? [duplicate]

I often find myself in the situation where the directory structure is like: a/b/c/d/f/g/... and I am at a as pwd and wish to quickly navigate to f or g. Is it possible to search and move to the ...
3
votes
5answers
177 views

How do I *reliably* and *simply* get the current shell interpreter name?

I'm looking for a simple and reliable way to get the name of the current shell from inside a script or a sourced file (not from the command line). I would have expected to just do $(basename ...
0
votes
0answers
7 views

How do I edit my directory colors in zsh so directories in a network share aren't so ugly? [duplicate]

The display colors of directories located on mounted network shares are horrid: Local directories look much nicer: As I understand it, these settings are set in these lines in .zshrc: eval ...
1
vote
1answer
22 views

Backward and foreward search are inversed with vi mode in zsh

When I enter in vi mode with set -o vi, I enter in command mode, and I touch the key ? it produce a / and the inverse. Is it normal ? How to change this behavior?
1
vote
2answers
42 views

zsh - complex filename matching [closed]

I have trouble passing a list of file names to a program when utilizing globbing operators. Essentially the problem is that I have files with multi-stage suffixes and I want to match only the master ...
1
vote
1answer
35 views

running screen in a shell can't find sessions but running screen during ssh login can

I am using the RemoteLoginAutoScreen script to start a screen session when I ssh into a host. Differences from linked script: I am using zsh and the RemoteLoginAutoScreen uses bash The problem that ...
1
vote
1answer
58 views

Expanding {a..d} to a b c d in zsh

In bash, {a..d} expands to a b c d. Currently this is not happening for me in zsh, and my googling has returned conflicting results. Some results suggest that {a..d} should work ...
3
votes
1answer
58 views

How do you use variables with values containing spaces in a Z-shell (zsh) script command?

I have the following Z-shell script: compiler=clang++ standard=-std=c++11 warnings="-Wall -Wextra -Wpedantic" ${compiler} ${warnings} ${standard} -o ${1} ${1}.cpp This does not work as the ...
0
votes
1answer
24 views

Run .zshrc when passing command via -c

I have a script that runs a command via zsh -c. However, when zsh runs, it doesn't appear to load ~/.zshrc. I understand a login shell flag exists, but even zsh -lc <command> doesn't seem to ...
3
votes
5answers
125 views

Efficient data extraction from multiple files to a single CSV file

I have a large collection of XML files with the same exact structure: $ cat file_<ID>.xml ... ... ... <double>1.2342</double> <double>2.3456</double> ...
0
votes
1answer
21 views

Determine the tmux session a shell session belongs to?

tmux provides a number of commands in the shell such as rename-session which operate on the session that the invoking shell belongs to. It also provides commands like list-clients which list out the ...
0
votes
2answers
29 views

“Quit and restart” control code?

I find myself frequently (after making some change to source) "Ctrl+C;↑ ing" to restart the program with changes. Is there a way to do this more quickly, without wrapping the program in a loop ...
0
votes
1answer
19 views

Bind tmux prefix to section symbol §

I usually use the backtick key as my prefix, but this keyboard has the section/stanza symbol § where the backtick usually (at least, for me in the UK) is. If I bind to this key, quoted or unquoted, ...
3
votes
1answer
41 views

How can I ignore / remove / exclude autocompletions in zsh?

I usually use rs+[tab] to get rsync but it's showing three options (on a new system): ➜ $ rs rsh rsync rsyslogd I seldom use rsh or rsyslogd - how can I prevent these from appearing ...
4
votes
1answer
96 views

What is this HOME command?

I'm able to run a command named "HOME" which appears to be equivalent to cd && echo "~". But I can't figure out where it's defined: $ pwd /tmp $ which HOME HOME not found $ type HOME HOME not ...
0
votes
1answer
40 views

Can I conditionally turn certain oh-my-zsh plugins off?

This is more of a long shot, but here we go: I use oh-my-zsh with the vcs-plugins git and svn on. I now started on a project where it would be most convenient to use sshfs. The problem that now comes ...
-1
votes
1answer
83 views

What does `zstyle` do?

zstyle seems like it's just a central place to store and retrieve data, like an alternative to export. Is that true, or is there more to it?
0
votes
1answer
29 views

Running a command on different shell

While reading the answers of question Can bash write to its own input stream?, I found following command runs on zsh but not on bash : print -z echo mnciitbhu 1 . Is -z is an extension to print ...
1
vote
1answer
50 views

What is the difference between `autoload` and `autoload -U` in Zsh?

What is the difference between autoload -U and plain autoload? For instance, here it is recommended to run: autoload -U run-help autoload run-help-git autoload run-help-svn autoload run-help-svk ...
1
vote
1answer
72 views

Configure tmux to use zsh

Right now I have my iTerm session configured to use zsh (/usr/local/bin/zsh), but I'm trying to configure tmux to use zsh as well, instead of /bin/bash/, which it's currently defaulting to. So far ...
1
vote
1answer
31 views

How to add a dir to fpath

I'm using zsh and prezto. I've adding the following line at the end of my .zshrc fpath=(/usr/local/share/zsh/site-functions $fpath) But unfortunately, the functions defined in this folder seems ...
2
votes
1answer
54 views

Source .bashrc in zsh without printing any output

In the past, I've used bash consistently, because it's everywhere. But recently I started to try zsh. I don't want to give up updating my .bashrc fil which is rsync'ed to all my servers . So, in my ...
6
votes
1answer
52 views

zsh I/O redirection: redirecting and then piping; what is going on?

Can somebody explain what is going on in this command: echo foo >&2 | grep foo Zsh (5.0.2) prints foo twice. One seemingly to stdout and one to stderr, since running these commands: { echo ...
1
vote
1answer
102 views

zsh: Disable “file exists:” warning with redirection

How can I override the file exists: warning from zsh? > echo > newfile.txt > echo > newfile.txt zsh: file exists: newfile.txt In these cases I prefer my shell to not complain and ...
2
votes
2answers
43 views

How do I find the actual binary/script using 'which' in zsh? [duplicate]

In zsh, when I enter which git it shows: git: aliased to noglob git How do I find out which git binary it actually invokes? (eg: /usr/bin/git vs ~/bin/git). Basically I want to bypass the aliases ...
1
vote
1answer
47 views

Completions stopped working after upgrading zsh

Previously I have been using this handy script with oh-my-zsh to set the tab color whenever I ssh into a machine: # iTerm2 window/tab color commands # ...
1
vote
1answer
48 views

How to edit shell prompt to show time?

I would like to edit my shell prompt to display time. Am currently using zsh, though I would like the customize the shell prompt to show time. I understand an echo $PS1 will give me the environment ...
3
votes
3answers
242 views

How to set HOSTNAME in zsh?

In bash, which sets $HOSTNAME for you, I was able to calculate the total length of prompt line simply by using something like: PS1_length=$((${#USER}+${#HOSTNAME}+${#PWDNAME}+12+${#PS1_GIT})) It was ...
2
votes
2answers
218 views

Zsh: export: not valid in this context

When running this script, I run into an error on this line (relevant snippet below): ... _NEW_PATH=$("$_THIS_DIR/conda" ..activate "$@") if (( $? == 0 )); then export PATH=$_NEW_PATH # If ...
0
votes
1answer
30 views

Should I move my custom commands from the end of ~/.profile to the end of ~/.zprofile when I install zsh and oh-my-zsh?

I am a new user of zsh and oh-my-zsh. Before I installed zsh and oh-my-zsh I configured my ~/.profile to start some programs automatically. For example, my ~/.profile would start guake after a 4 ...
1
vote
3answers
142 views

String comparison in single brackets in zsh [duplicate]

Bash code to print all folders: for f in ~/*; do if [ $f == '/home/sk/.' -o $f == '/home/sk/..' ]; then true else echo "$f" fi done It works on bash. When i ran the code on z ...
2
votes
3answers
55 views

reuse the last command output at the given index/line-num

ls displays: entry1 entry2 entry3 How can I reuse the above output (not all of the entries but the entry at a given line, say n) in the next shell command? Something like: vi $(!!)@3 Must ...
2
votes
3answers
60 views

Local `set -e` for functions

Is there such a feature or can it be emulated reasonably easily? I want the same behavior except it should return where set -e would have caused a call to exit.
2
votes
1answer
104 views

Automatically colorize the output of tree

In plain zsh, tree is set similar to --color=auto by default. However, when I use Oh-My-Zsh, tree doesn't show colors. Since tree does not have a --color=auto option, how can I override the setting ...
1
vote
1answer
39 views

Setting backspace=2 in zsh with vi bindings

I just set my zsh to vi mode as I feel the word/WORD (w/b W/B) skip keybindings will help me work faster than plain ^a ^e in emacs binding mode. However, I'd like to set backspace=2 or set ...
2
votes
1answer
24 views

Overridable functions in Zsh

Consider the following two functions: function slow_git_prompt_info() { if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then ref=$(command git symbolic-ref ...
0
votes
1answer
49 views

Read a line with default input in zsh

This function can be used to help user input a modification of some text. function change { bash -c "read -ei \"$1\" temp && echo \$temp" } What is idiomatic zsh way to do something ...