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

learn more… | top users | synonyms (1)

3
votes
2answers
144 views

How change prompt of subshell

I'm trying to create a simple script that, among other things, will create a subshell: #!/bin/sh # setup "${@:-$SHELL}" # teardown The question is: I need to change the default prompt, so for ...
2
votes
2answers
522 views

Zip folder without including path to folder and require only one argument

I'm trying to make a zip function that'll do all the steps I typically do when zipping a file or folder. Say my current directory is ~, and I want to zip a folder named Folder1, whose file path is ...
3
votes
3answers
143 views

Persistent shell arguments

I often find myself running a series of commands on a single set of arguments. For example: $ nmap -Pn -sS 192.168.1.5 $ ssh 192.168.1.5 $ curl 192.168.1.5 $ wget -r 192.168.1.5 This can be sped ...
3
votes
2answers
137 views

bash equivalent of zsh's $@[2,$#]

(NB: the motivation for this question is only to improve my bash programming know-how.) I want to know the bash equivalent of zsh expressions such as $@[2,$#], which directly address a range of a ...
1
vote
2answers
149 views

zsh expand-or-complete for all files regardless of command/context

zsh has a feature where command line tab-completion performs context-aware completions, so you can do things like: # Good: $ wget g<tab> # becomes: $ wget gopher:// $ wget --hea<tab> ...
3
votes
4answers
459 views

Round/truncate digit in string in zsh (or with external tool)

I'm trying to do an interface to bc so it can be used intuitively and without the annoyance of getting "stuck" in it. I haven't got around to test it that much, because I got stuck on another detail, ...
5
votes
1answer
116 views

can you make zsh autocorrect smarter?

I like zsh autocorrect, but it keeps asking me about things that don't need correcting. dzil build zsh: correct 'build' to '.build' [nyae]? % .build is a directory created by the build (or any ...
4
votes
1answer
1k views

Why is zsh (oh-my-zsh) completing directories that don't exist?

UPDATE 3 I've worked out that these annoying autocomplete options are actually usernames. I.e. they exist in /etc/passwd I have users such as _kadmin_admin and _kadmin_changepw and many others ...
3
votes
1answer
225 views

zsh adds tab character when autocompleting

I have zsh 4.3.10 installed on a RHEL 6.4 box. I'm not sure why this happens, but when I but Tab to autocomplete things, it also adds a tab character. For example: rocket@rhelbox www % vim vim ...
5
votes
3answers
316 views

Getting relative links between two paths

Say I have two paths: <source_path> and <target_path>. I would like my shell (zsh) to automatically find out if there is a way to represent <target_path> from <source_path> as ...
4
votes
1answer
220 views

Zsh completion, enabling shift-tab

When zsh shows you a menu of possible completions, I'd like it to let me use shift-tab to access previous completion entries--is there an option that controls what key is used to access previous ...
5
votes
2answers
458 views

Preventing zsh from using aliases in CWD (prompt)

I have the following personalized theme activated with oh-my-zsh (latest version of zsh and oh-my-zsh): local return_code="%(?..%{$fg[red]%}%? %{$reset_color%})" local ...
4
votes
4answers
2k views

Double and triple substitution in bash and zsh

Follow-up to the background part in this question. In bash I can use {!FOO} for double substitution, in zsh ${(P)FOO}. In both, the old-school (hack-y) eval \$$FOO works. So, the smartest and most ...
2
votes
2answers
347 views

Why is `kill -s INT <zsh PID>` behaving differently from `Ctrl-C`?

Starting with: % donothing () { echo $$; sleep 1000000 } % donothing 47139 If at this point I hit Ctrl-C at the same terminal that is controlling the shell, then the function donothing does indeed ...
6
votes
2answers
467 views

Directory shortcuts in emacs buffer

So I asked this question about directory shortcuts in a shell. The idea is I'd like to be able to open a file in /home/Documents/foo, say, by typing C-x C-f ~foo/file. So, is there a way to emulate ...
3
votes
4answers
387 views

zsh is in /usr/bin, but also in /bin, what is the difference?

The /etc/shells says it has zsh installed in /bin/zsh, but also in /usr/bin/zsh. brgr@envy17:~$ cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash /usr/bin/tmux ...
1
vote
1answer
38 views

difference between omz “plugins” and “themes”?

What exactly is the difference, operationally, between plugins and themes in oh-my-zsh? I.e. how would things break (if at all) if a plugin were instead put among the themes, or a theme among the ...
1
vote
1answer
76 views

How to make ZSH tab completion work with two tabs

I saw a question like this on here, but the answer didn't work for me. I'm trying to set up tab completion and I want it that if I have two files fileA and fileB and I type fil<tab> it first ...
5
votes
2answers
113 views

Is there a less convoluted way to set the $path array locally within function?

Is there a less laborious way for setting a local version of the $path array than what's shown in the following snippet? foo () { local holdpath holdpath=($path) local path ...
3
votes
2answers
107 views

Refer to an item in `dirs`

I use pushd to work with multiple directories in bash and zsh. I've aliased dirs to dirs -v so that I get an ordered list when I want to see what's on the directory stack: chb$ dirs 0 ...
3
votes
1answer
106 views

How to use parameter substitution in glob pattern (zsh)

I want to process a bunch of files ending in some suffixes, so I wrote the following zsh script but it did not work. EXT=(.jpg .png .gif) EXT=${(j.|.)EXT} # EXT becomes '.jpg|.png|.gif' for f in ...
31
votes
2answers
4k views

Rebuild auto-complete index (or whatever it's called) and binaries in $PATH cache in zsh

After installing new software, an already opened terminal with zsh won't know about the new commands and cannot generate auto-complete for those. Apparently opening a new terminal fix the problem, but ...
1
vote
1answer
89 views

How can I use bindkey to run a script?

In the Z shell, how can I use bindkey to bind a key sequence to a script?
4
votes
2answers
224 views

cd to directory of a symbolically linked file

Before I write a script, anyone know an easy way to do the following: $ pwd /foo/bar $ ls -l lrwxr-xr-x 1 username admin 48 Apr 17 2012 foo.sh -> /bar/foo.sh $ cd /bar $ ls foo.sh i.e., in ...
7
votes
1answer
107 views

Change zsh completion to put completions above the prompt

I'm a long-time tcsh user that finally decided to try out zsh. I've been toying around with completion, but one thing I don't like is that when I hit tab for a completion that might have a lot of ...
2
votes
4answers
108 views

$PATH duplication issues

If I do echo $PATH I get the following: ...
4
votes
3answers
3k views

Bash Auto-Completion feature for SSHing into Different Hosts

I have big list of servers which I normally ssh to all the time. Is there any way using bash or zsh so that I can keep the list of hostname and bash auto-completion goes through the file and gives me ...
4
votes
1answer
217 views

Disable the configuration tool in Zsh

When there is no .zshrc file in a user's home directory and zsh is started, an interactive configuration utility is run instead of directly giving access to the shell prompt. I set up zsh to be the ...
2
votes
1answer
1k views

export PATH only once per login in zsh

I need to alter my PATH variable so I put export PATH=$PATH:somedir in my $HOME/.profile which is sourced by my $HOME/.zshrc. This works, yet whenever I open a new terminal (urxvt in X11), .zshrc ...
2
votes
2answers
627 views

Tmux Terminfo problem with Zsh key bindings

Zsh in Emacs edit mode comes with the default key binding ALT + Backspace to delete a word on the right side of the cursor and ALT + D to delete a word on the left side. I would like to add the latter ...
5
votes
2answers
1k views

Disk usage summary per user

Is there a way to get the disk usage per user under a given path? du doesn't seem to have an option to aggregate disk usage per user, and df only seems to report how much disk is left on the drive. ...
2
votes
2answers
198 views

Unable to concatenate files with find ./subdir/* -print0 | sort | xargs -0 cat > merge.txt

I am trying to concatenate thousands of files that result from processing the pieces output by split with find ./subdir/* -print0 | sort | xargs -0 cat > full_merge.txt The files under subdir ...
3
votes
2answers
1k views

Errors after installing oh-my-zsh

I just tried to install oh-my-zsh. I get the following error when I try to run rvm: zsh: command not found: rvm I also get the following error when I try to open a new tab: ...
9
votes
2answers
555 views

How do I stop bash from syntax checking sourced files?

I have the following code in a file that is sourced by both zsh and bash. if test $SHELLNAME = zsh ; then lss() { l -l ${1:-.}/*(s,S,t); } laf() { l ${1:-.}/.*(.); } lad() { l -d ...
3
votes
2answers
166 views

Passing quotes and full strings to bash -c or zsh -c

When I am in Perl and I call system(some_command), this invokes some_command on /bin/sh. I would like it instead to run some_command in another shell such as bash or zsh. One way of running ...
1
vote
0answers
97 views

Zsh: quickly bookmark commands

I just had an idea, I'm sure it must exist though I could not find anything on the web. This topic gets close to my idea but not enough: How to quickly store and access often used commands? I'd like ...
5
votes
2answers
146 views

Passing glob expressions to functions/scripts

The following script is supposed to concatenate multiple csv files in a path specified in the first argument into a single csv file specified in the second argument #!/bin/zsh set -x set -v ...
1
vote
2answers
104 views

Logging all input and output in zsh on demand

Is there any way to activate/deactivate the logging of all input and output on a zsh session? I am using oh-my-zsh with a customized prompt with colors, etc. and I would like to preserve all of these ...
0
votes
1answer
45 views

Weird behavior when sourcing .zshrc

I'm using zsh 5.0.2 (x86_64-apple-darwin12.3.0) on the latest MacOSX. If it makes any difference, I have also enabled oh-my-zsh. The shell seems to be missing the .zshrc file when I want to source ...
11
votes
2answers
2k views

zsh wants to correct vim to .vim

I'm using zsh on Gentoo x64, and when I type sudo vim /path/to/file from my home folder, zsh asks: zsh: correct 'vim' to '.vim' [nyae]? I want to run vim not my .vim folder. How do I fix this? ...
3
votes
1answer
80 views

Ignore files for zsh's completion for SVN

I managed to configure zsh such that it does not suggest LaTeX temporary files when I use autocompletion for emacs by adding this line to my ~/.zshrc: zstyle ':completion:*:*:emacs:*:*files' ...
0
votes
1answer
1k views

oh-my-zsh theme doesn't seem to update unless I re-launch zsh

I've begun making my own oh-my-zsh theme, but I've run into a bit of a problem. I'm trying to change the color of the git output based on the name of the branch, and it works fine except for one ...
0
votes
1answer
187 views

Issues using sublime text to edit command line in VI mode

I am using the following to edit the current command line in Sublime Text 2 (using a working subl alias) .zshrc set -o vi EDITOR='subl'; export EDITOR bindkey -M vicmd v edit-command-line ...
2
votes
0answers
101 views

zsh: Echoing every statement?

I have an odd problem with zsh when I switch between shells in a particular way: Option 1 (works well): I start a zsh shell. I switch to tcsh with /bin/tcsh, and I switch back to zsh with /bin/zsh ...
2
votes
2answers
2k views

/usr/bin/env: zsh -: No such file or directory

I get the error /usr/bin/env: zsh -: No such file or directory ...when I run an executable zsh script that starts with the following shebang line: #!/usr/bin/env zsh - Also, FWIW, replacing - ...
2
votes
0answers
116 views

Is there a postexec/predisplay hook for ZSH?

I know zsh has a preexec hook that fires before the command is executed, but is there one that fires after the command has been initiated but before the output is displayed to the screen? I ask ...
4
votes
3answers
333 views

How to save current command on zsh? [duplicate]

I am typing a command, I remember I have to check something, if I press Ctrl+U the command disappears and I can type something else, but then the command I was typing is not in the history. Is there ...
5
votes
2answers
380 views

Wrap command in the prompt

Is it possible to insert a separator after the command in a prompt? This is an example: ~/Desktop: ls -al ------------------------------------- total 80 drwx------+ 6 eddie staff 204B Apr 29 ...
6
votes
4answers
1k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
2
votes
1answer
104 views

What does %\/ do (zsh prompt expansion)?

What does the sequence %\/ do in zsh prompt expansion? man zshmisc doesn't contain the string %\, which is where the rest of the prompt-specific expansions are. The sequence can be seen in Holmans ...