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

learn more… | top users | synonyms (1)

0
votes
1answer
315 views

How to setup Mac OS X Terminal on bash and iTerm2 on zsh

I attempted to setup bash shell by default on Mac OS X (Yosemite) Terminal app and zsh shell by default on iTerm2 app. However, it is either bash shell or zsh shell for both the apps. $ chsh -s /bin/...
7
votes
3answers
113 views

'switch' based on shell

I would like to source (i.e. not call) a script from any shell (bash/csh are the primary targets, but fish, zsh, ksh, and rc would also be interesting). I would like if the script can be a single ...
2
votes
0answers
30 views

How to view current settings for all options?

I know that setopt with arguments will show the options that are set to values different from the default; e.g. % setopt interactive login monitor norcs shinstdin zle If you have memorized all the ...
0
votes
2answers
88 views

Unexpected prompt in zsh

Can someone explain to me why I am getting this shell prompt when I'm in the /home directory, and how to get rid of it?  I am using zsh. I want it to display only the following: user@host ~ % but ...
1
vote
1answer
43 views

What does the + do in $+commands[…]?

Here's another question that is impossible to search for: how to interpret $+commands[foobar]? I assume that it is a variant of $commands[foobar], but who knows. (With zsh, at least I never know.) ...
2
votes
1answer
56 views

How to interpolate ${:-=cat} within a double-quoted string?

(In the following cat is a stand-in for "any command in $PATH".) Consider this example: % TMP=${:-=cat} % FOO="blah blah blah $TMP blah blah blah" % echo $FOO blah blah blah /bin/cat blah blah blah ...
1
vote
1answer
763 views

Installing powerline fonts for zsh + Prezto theme

I am currently using Zsh + Prezto for my scripting shell configuration. I have been using the sorin theme but am a little dissatisfied with it. I'd like to switch to the paradox theme! It is supposed ...
6
votes
7answers
282 views

How can I apply `cut` to several files and then `paste` the results?

I often do operations like paste <(cut -d, -f1 file1.csv) <(cut -d, -f1 file2.csv) which is very tedious with more than a few files. Can I automate this process, e.g. with globbing? I can ...
3
votes
1answer
50 views

How to trace parameter parsing and expansion?

The example below illustrates the sort of "Daily WTF" that I take zsh scripting to be. I've pretty much given up hope of ever understanding zsh's voluminous rules well enough to be able to figure out ...
1
vote
1answer
204 views

Is there a built-in (or at least simple) way to check for the existence of a function accessible through $FPATH?

I want to define a function foo in a script (intended to be sourced), but only on the condition that some executable, shell built-in, function, or alias of that name doesn't already "exist". The ...
2
votes
4answers
103 views

Copy files to new directory only if name of file is in an array

I'm not much of a zsh buff but I imagine this should be an easy layup for someone: I can bulk copy files from sourcedir to targetdir with the following: $ find sourcedir -type f -exec cp {} ...
1
vote
2answers
569 views

Changing directory color with zsh + Prezto

I am using Prezto + zsh as my shell. I would like to change the color of directories when I ls my directory. For instance, here is what I currently have: Obviously, this is no fun, as I'm hardly ...
2
votes
2answers
103 views

How to create hyphen alias for zsh?

I am using zsh and oh-my-zsh on Ubuntu. To change into the recent directory in the past there was an alias set to - which is the same as cd -. Somehow the alias disappeared at my machine. This might ...
3
votes
4answers
390 views

How to remove the last command (or current command for bonus) from zsh history

Sure there's a super simple smart way to do this, but since history in zshell seems to be aliased to fc, there's no way to use the tricks mentioned in How to remove a single line from history?. Any ...
2
votes
1answer
474 views

How to pass environment variables to a new ssh-initiated login session?

Suppose that some variable FOO is defined (and export-ed) in the current environment. Let me call this environment E0. Now, I log into some other Unix system using ssh. % ssh frobozz@for.example....
2
votes
2answers
53 views

Command behaving differently when saved in a *.sh file

I was not able to find an answer to this question, so maybe one of you guys can help me out :) I wrote some shell scripts to help me automate things, and they work. However, what doesn't work is ...
1
vote
2answers
111 views

Passing variable definitions to specific shells in ssh

I would like to ssh to a machine with a pre-defined setting, specifically in zsh. To do so, I have tried doing the following from the client (inspired by this answer): $ ssh -t machine@domain "...
1
vote
2answers
111 views

How do you manage your bash/zsh Aliases?

How do you manage your bash/zsh Aliases? Is there a tool to do this more easily and less "think of an alias -> open .zshrc-sourced-file -> edit -> close, reload .zshrc -> use alias"?
1
vote
2answers
70 views

What does the `set — $args` line do here, and why does it behave differently between Zsh and Bash?

In the manpage for the version of getopt that comes with Mac OSX, an example is given that uses the construction args=$(getopt optstring $*); set -- $args. What does set -- $args do here? Furthermore,...
1
vote
1answer
50 views

Can I use Zsh's built-in wildcard matching to replace the use of `find` here?

This is a follow-up to another question I posted I use a script to automatically rename files according to a particular order: #!/usr/bin/env zsh pages=($(sed -n '/page_order/,/^$/ p' _config.yml | ...
3
votes
1answer
710 views

Exiting terminal running “nohup ./my_script &” => “You have running jobs”. OK to exit?

Say I run the following on a remote box with the idea of preventing killing the job when I disconnect the terminal. nohup ./my_script.sh & When I try to exit my terminal, I got the following ...
1
vote
0answers
153 views

Strange Highlighting Color In ZSH Menu

I am using Arch Linux and zsh. When selecting options from a menu in zsh the color appears to be off when moving down in the list. For example after pressing the tab key twice after typing cd results ...
5
votes
2answers
82 views

how do I call git commands without 'git ' in front?

How do I tell my zsh to automatically try a command with git in front, if the command is not found? E.g. I want to run $ status and if there is no status in $PATH, my zsh should try git status.
2
votes
1answer
153 views

Bash/zsh tab autocomplete: Given initial command, ignore certain files in directory with autocomplete

What I'm asking is a little bit specific, and might be a different than other autocomplete questions on Unix Stackexchange. Suppose I have a directory that looks like this -rw-r--r-- 1 hlin117 staff ...
1
vote
1answer
56 views

How to manage configurations across multiple computers and shells?

I am a traveling technologist who does not always have a reliable connection to a home server. I tend to jump between zsh and bash on a few of my own machines. What advice or recommendation would you ...
0
votes
1answer
158 views

Where is zsh storing my history?

I have two terminals open, both running zsh. The history options which I currently have set are these: export HISTFILE=~/.histfile export HISTSIZE=10000 export SAVEHIST=10000 setopt ...
2
votes
0answers
174 views

How to setup zkbd (zsh keyboard bindings) in a server?

I have zsh shell in a Linux server, and connect to the server from screen sessions in different computers. I'm trying to get control keys, such as home and end, to function correctly. Because zsh ...
0
votes
1answer
88 views

Expand parameter in quotes in zsh

(Not sure the title is adequate, at least I tried my best…) I want to pass function arguments to zsh’s emulate to evaluate a command in bash emulation: $ .bash() { emulate bash -c "$*" } $ .bash '...
1
vote
1answer
120 views

Can up arrow command history for oh-my-zsh narrow down history by options/parameters given to the command

Not sure I'm wording the question very well, but an example is worth a thousand words of mine. eg., using oh-my-zsh : git <up arrow> Will cycle up all the git commands I have used... git ...
2
votes
1answer
17 views

Is it possible to use two characters (e.g. ^tm) in insert mode in zsh for a command binding?

in my current .zshrc file I have bindkey -M viins -s '^tm' '^[Iman ^[Ela ^[d$' and this doesn't work, however when I remove m from the shortcut and it is now only ^t the shortcut is working. I'd ...
1
vote
1answer
101 views

zsh capture and pipe output to another command

I had the zsh script printf '%s\0' www/scripts6/lib/* | xargs -0 -I{} -P 50 babel {} > {} and it worked (i think.). But I needed to actually copy the files to the scripts directory instead of ...
2
votes
1answer
155 views

zsh wait for jobs to complete

When I type the following in my terminal running zsh (each line is a command) babel www/scripts6/lib/data.js > www/scripts/lib/data.js & babel www/scripts6/lib/user.js > www/scripts/lib/...
2
votes
1answer
106 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 ...
2
votes
1answer
177 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 ...
5
votes
1answer
77 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
11 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
186 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 SO/...
2
votes
1answer
1k 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
47 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
170 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
372 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 ...
6
votes
2answers
361 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
239 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
176 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 ...
6
votes
5answers
718 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 "$SHELL")...
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
43 views

Backward and forward search are reversed 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 produces a / and the reverse. Is it normal? How can I change this behavior?
1
vote
2answers
53 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 ...
2
votes
1answer
359 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 ...