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

learn more… | top users | synonyms (1)

3
votes
1answer
205 views

zsh !! and !$ auto execute as it does in bash

I recently made the switch from bash to zsh. I discovered two minuscule issues and differences between zsh and bash. I was slightly disappointed when my favorite two shortcuts !! & !$ don't behave ...
1
vote
2answers
564 views

Weird zsh grep -P behaviour

I connect to server with PuTTY from Windows. I have a long yet not touched (I suppose) by hands of local admin config: $ cat /opt/jira/.subversion/config ... ### must be enabled, which is ...
12
votes
3answers
3k views

Switching to `zsh`: Are all bash scripts compatible with `zsh`?

I'm looking to switch from bash to zsh but concerned about compatibility of bash scripts. Are all bash scripts/functions compatible with zsh? Therefore, if that is true is zsh just an enhancement to ...
2
votes
1answer
110 views

When is using ~+ useful?

As I understand it, ~+ means the same thing as "the current working directory". So echo ~+ should print the same as pwd. What is the purpose of this tilde expansion ~+ ?
12
votes
1answer
1k views

How to disable autocorrection for sudo [command] in zsh?

I have zsh and oh-my-zsh with default values and can't figure out how to turn off autocorrection for specific commands, that I often use, such as: sudo mc or sudo gem update. The thing is that I have ...
0
votes
1answer
484 views

How to disable autocompletion for sudo …?

I am new to zsh and I like it a lot, especially with oh-my-zsh plugin. I installed oh-my-zsh with its default values and can't figure out how to turn off autocompletion for specific commands, that I ...
4
votes
3answers
15k views

Change font in echo command

Is it possible to change the font attributes of the output of echo in either zsh or bash? What I would like is something akin to: echo -n "This is the font: normal " echo -n $font=italic "italic," ...
2
votes
1answer
233 views

How ignore PATH with `source` completion

I can't find any 'detailed enough' documentation about zstyle, and I'm surprised that no one faced this problem before: here is what I get with tab completion: source l<TAB> l2ping* ...
4
votes
1answer
263 views

printing a string's “canonical print-escaped form”

I'm trying to write a function, I'll call it escape, that will behave like this: % IFS=$' \t\n\000' % escape FOO $IFS FOO=$' \t\n\000' In other words, escape takes two arguments, and then, taking ...
1
vote
1answer
126 views

Load command parameters from upper level file

I've come across an interesting problem that I have not yet been able to solve satisfyingly. Consider a note taking command that takes two arguments: note $project $note That simply files the ...
3
votes
4answers
330 views

Run a given command on every subpath of a long path

Say I have a long path such as: /a/b/c/d/e/f I would like to run a command only on each of the subpaths of the path: e.g. If my command is cmd, I am looking for a one-liner that can do (perhaps ...
2
votes
1answer
107 views

Complete only at the beginning of the word

I've got an issue with ZSH autocompletion, and I can't find the right keyworks to get rid of it. For instance, with files like $ ls Accelion, titi toto tata I would like to write: $ ls ...
4
votes
2answers
717 views

Zsh — more intelligent autocorrection

Is it possible to make Zsh stop trying to correct arguments that are not meant to be files with files from the current directory without turning off correction completely or limiting it to setopt ...
6
votes
1answer
282 views

ZSH host name completion behaviour change?

I have been using ZSH to do host name completion, and want to change the default behaviour. When I have multiple hosts with similar names, the completion does stuff that I don't care for. An example ...
2
votes
1answer
230 views

ZSH %m prompt escape not working as documented under Debian Linux

The zshmisc man page on my new Debian Squeeze install states, under SIMPLE PROMPT ESCAPES: %m The hostname up to the first `.'. An integer may follow the '%' to specify how many components of the ...
0
votes
1answer
798 views

rsync with absolute paths and excluding subpaths

Say I have the following structure on path origin_path origin_path/X=1/A/... origin_path/X=1/B/... origin_path/X=1/C/... ... origin_path/X=2/A/... origin_path/X=2/B/... origin_path/X=2/C/... ... ... ...
4
votes
4answers
504 views

Get input from editor (vim/nano/emacs/textmate?)

I was just curious if there's a way to get input not from StdIn but from $EDITOR - be it vim, nano, emacs or even a non-command-line-editor (MacVim/TextMate). What are the ...
2
votes
1answer
165 views

How do i get screen to execute/load .zprofile when starting a new window?

How do i get screen to execute/load .zprofile when starting a new window?
2
votes
2answers
280 views

Shell Prompt Customization? [closed]

I have used oh_my_zsh (and tinkered with bash_it) on multiple systems and have generally been happy with it, though I hate it's auto-correction feature and generally turn it off. My usual shell is ...
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? ...
13
votes
1answer
955 views

zsh Interpret/ignore commands beginning with '#' as comments

In bash, if I type a command beginning with a '#', bash ignores it as a comment. Ie, the following is ignored at the bash prompt: > # Hi there! Whereas in zsh: > # Hi there ! zsh: bad ...
12
votes
1answer
538 views

Dynamically update completion list in zsh

I find zsh's result lists for Tab completion quite useful, however I'd like to tweak their behaviour a bit: They should appear when I Tab for the first time and afterwards dynamically update with ...
0
votes
2answers
498 views

ls outputs multiple columns even if piped to grep with grml's zsh config

I just decided to give zsh a go against Bash and came across some unhandy behaviour about which I couldn't find anything on the net: If you do a ls | grep foo in Bash, the ls only contains one file ...
10
votes
4answers
5k views

How to define and load your own shell function in zsh

I am having a hard time defining and running my own shell functions in zsh. I followed the instructions on the official documentation and tried with easy example first, but I failed to get it work. ...
1
vote
1answer
80 views

List all the matched files starting from an index

In zsh, there is the [m,n] glob qualifier which works as follows: [beg[,end]] specifies which of the matched filenames should be included in the returned list. The syntax is the same as for ...
2
votes
0answers
268 views

Physical Terminal (DEC VT220) issues with ZSH

I recently purchased a VT220 and all the hardware necessary to hook it to my macbook pro. After several hours of fiddling I got it working with a shell - my only problem is my shell of choice, ZSH, ...
4
votes
3answers
326 views

Converting a history to a script?

Often times I've typed in a bunch of commands when I realize that I am going to keep typing them in and that I would really like a script. Now I understand that no matter how I save my history, I am ...
3
votes
2answers
880 views

zsh: excluding files from a pattern

Say I have the following files: |-- bar `-- foo |-- type_A_1 |-- type_A_2 |-- type_B_1 |-- type_B_2 |-- type_B_xx |-- type_B_xx `-- something_else I thought the ...
5
votes
2answers
356 views

How to specify timeout for tab completion in zsh?

Zsh's completion feature is great except for this one. When I try to complete in a folder with lots of files/network folder, it takes a couple of minutes and prints this error. example.com:~$ ls ...
7
votes
2answers
2k views

16 Colors in ZShell

I only seem to be able to call 8 colors in my zshell prompt. Example: PROMPT="[%n@%{$fg[magenta]%}%m%{$reset_color%} %.] %# " Works fine. However, ...
0
votes
2answers
259 views

pwd not being set correctly in zsh prompt

If I type this in my PROMPT in my .zshrc file: PROMPT="`pwd` >" I expect that it will print the current working directory. However, pwd always prints /Users/kevin. Why doesn't it show my current ...
3
votes
1answer
1k views

Set variables in ZSH precmd and reference them in the prompt

Is there a way to set variables in the precmd function of zsh and then echo them in the prompt? Something like function precmd { GREETING='Hi Kevin!'; } PROMPT="$GREETING";
3
votes
1answer
315 views

ZSH takes two tabs to complete filenames

I love Zsh's tab completions, but it's frustrating when there is only one possible option and I have to tab twice to tab complete the filename. For example, if this is a list of files in a directory: ...
2
votes
1answer
141 views

Files with no .sh extension not considered for autocompletion in zsh

I have noticed that unless I add an .sh extension to my shell scripts, Zsh does not suggest them for autocompletion for execution despite having them in my PATH. I have the same problem if I cd into ...
4
votes
1answer
715 views

How do I filter a glob in zsh

Basically I can use a glob in zsh to a list. Often, it turns out, I would like to filter that list, grep'ishly I'm wondering though, if I need to do that. Does zsh have a method to filter a list? ...
8
votes
4answers
3k views

Adding paths to PATH using a multi-line syntax

As far as I understand, the usual way to add a path to the PATH environment variable is by concatenating paths separated by the : character. For example, if I want to add three paths to it ...
2
votes
1answer
2k views

Terminal does not source .zshrc with custom colors for ls and cd command

I customized the directory and file colors for ls and cd + TAB. Here is my configuration. My configuration My system environment. Ubuntu 10.10 zsh 4.3.10 (x86_64-unknown-linux-gnu) oh-my-zsh // ...
11
votes
2answers
4k views

In zsh how can I list all the environment variables?

I want to get a list of all environment variables (shell variables? exported variables?) and their values at a given time, in zsh. What is the proper way to do this?
5
votes
5answers
500 views

I messed up my zshrc on a remote server and now I can't run any commands!

On a remote machine I changed my zsh settings and it is now broken, for every keypress it says: "url-quote-magic:1: url-quote-magic: function definition file not found " I don't have another ...
5
votes
1answer
84 views

What is Bash's string{ending1,ending2} construct called and what is the equivalent in zsh?

I've been trying to switch to zsh. Something I've missed so far is this: #!/bin/bash mv /very/long/path/to/file1.conf{,.old} #bash expandes that to: mv /very/long/path/to/file1.conf ...
5
votes
1answer
283 views

zsh - fully expand binary path on <tab>

In my current zsh behaviour, hitting tab after typing "sudo" just adds a space. $ sudo ... What I really want is for the tab to fully expand to the path of the binary it is about to execute when I ...
9
votes
1answer
2k views

How to enable reverse search in zsh?

I recently switched to zsh (finally) and am loving it! So far one thing that I am missing is Ctrl+R to do incremental history search. I have the history set up properly HISTSIZE=10000 SAVEHIST=10000 ...
9
votes
3answers
570 views

What is the main problem someone migrating from bash to zsh should face?

A few times I have had problems in bash that other using zsh didn't have and they were gloating about how smart they are. Also I have seen zsh users among people that I admire, and I have tried a ...
14
votes
3answers
3k views

How to properly collect an array of lines in zsh

I thought the following would group the output of my_command in an array of lines: IFS='\n' array_of_lines=$(my_command); so that $array_of_lines[1] would refer to the first line in the output of ...
4
votes
2answers
314 views

zsh autocomplete directory

I'm new to zsh and one thing that I do quite often is execute shell scripts that are in a directory of mine called Scripts. I'm not always inside of the Scripts directory, however... I may be in ...
6
votes
2answers
2k views

List elements with spaces in zsh

I've been studying zsh scripting for all of 2 hours at this point and I've hit a wall. I want to go through a list of files that may have spaces in them. I'm open to completely different approaches ...
5
votes
2answers
3k views

Screen status bar to display current directory for zsh/bash shell

I use GNU screen a lot with zsh as my shell. It would be a nice feature (I think) to be able to display the current directory name (not the full path) as the tab title. I can do that with CTRL+A ...
3
votes
3answers
2k views

After installing oh-my-zsh: … /.zshrc:source:34: no such file or directory … /.oh-my-zsh/oh-my-zsh.sh

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: ...
1
vote
1answer
169 views

How to access user's fpath as opposed to system's fpath with a script?

test.zsh: #!/usr/bin/env zsh for f in ${fpath}; do echo ${f} done outputs: ...
7
votes
4answers
7k views

How do I reverse a for loop?

How do I properly do a for loop in reverse order? for f in /var/logs/foo*.log; do bar "$f" done I need a solution that doesn't break for funky characters in the file names.