Zsh is a shell with many advanced command-line and scripting features.
5
votes
1answer
1k views
Executing a script in zsh - file permissions
I'm confused about execute file permissions not behaving as I expect. Probably because my expectations are wrong. Anyway:
I have a script file, for simplicity is just called s, located in ~/bin. For ...
1
vote
1answer
662 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 ...
11
votes
2answers
217 views
Can I make `rm` interactive only when using globbing? (in either bash or zsh or both)
Whenever I rm multiple items at once with shell globbing and there's even the slightest possibility that the pattern expands to more than I expect it to, I always try to remember to add -i, but (of ...
4
votes
2answers
173 views
Zsh: Automatically modify executed command
I've recently installed grc (generic colorizer) to my system via MacPorts, giving me the ability to get colorized output for plenty of commands which by default don't support it (see screenshot ...
3
votes
1answer
105 views
ZSH, vcs_info, Mercurial, and Trac: weird branch and revision
I'm using zsh with vcs_info and it works nicely except when browsing a repo which is set up for Trac/Mercurial. Specifically, the hgrc for the repo has the following line in [hooks]:
changegroup = ...
1
vote
1answer
370 views
Do shells support recursion?
I'm trying to write recursive functions in my shell scripts.
Consider the following code:
function printA {
if [[ "$1" = 0 ]]; then
return
else
echo "a$(printA $(("$1" - 1)))"
...
2
votes
2answers
220 views
Executing zsh rehash after build
I have a build script that can change what binaries are in my $PATH (it doesn't edit $PATH itself, but it adds/deletes files to folders that are already in $PATH). zsh's autocompletion doesn't update ...
5
votes
2answers
127 views
gvim pipes not reading zshrc when started from desktop
I'm using zsh as my default shell and using .zshrc to modify my environment variables. When I start gvim from terminal everything is fine however if I start gvim with the desktop icon, my env ...
0
votes
1answer
170 views
Checking existence of file with underscore in file name in zsh
I am writing a very simple script which will link shared configuration files. For some reason it does not behave as i expected for file with underscore in name. Does _ (underscore) means something ...
2
votes
1answer
388 views
oh-my-zsh completion on home directory names
I recently switched to zsh from bash, and I'm using oh-my-zsh. There's a completion behaviour I don't want: in any directory, the list of autocompletion candidates seems to include the names of all ...
2
votes
1answer
115 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
1answer
152 views
zsh notification of email (in maildir)
How can I modify the following so that it reads maildir and not just mailbox format?
typeset -a mailpath
for i in ~/Mail/Lists/*(.); do
mailpath[$#mailpath+1]="${i}?You have new mail in ${i:t}."
...
28
votes
4answers
2k views
What features are in zsh and missing from bash, or vice versa?
As a Linux user, I've always just used bash because it was the default on every distro I used. People using other Unix systems such as BSD seem to use other shells far more frequently. In the ...
1
vote
1answer
92 views
zsh delete part of the prompt
When I use reverse history search, then it "eats" a part of my prompt. Sometimes when I type a long command which spans to multi lines, my prompt is also lost.
Have anyone experience this situation? ...
7
votes
1answer
1k views
How do I perform a reverse history search in ZSH's vi-mode?
I use vim for essentially all my editing needs, so I decided to once again try vi-mode for my shell (currently ZSH w/ oh-my-zsh on OS X), but I find myself trying (and failing) to use Ctrl-R ...
2
votes
0answers
82 views
Completing avfs fake directories in zsh
How can I tweak zsh's completion system to complete “fake” files in some circumstances?
More precisely, the AVFS filesystem exposes archives as directories by creating a “fake directory” next to ...
4
votes
1answer
87 views
How to list all styles in zsh
How an I list all of the styles defined in a zsh session using the zstyle command? I would like to know this so I know what configuration options are available to me.
2
votes
1answer
43 views
Start new application instance instead of continuing a suspended one
If i for example start top. suspend it with Ctrl+Z, then enter top again the previously started instance will be continued in the foreground. How can i avoid this behaviour and just start a new ...
2
votes
1answer
65 views
Restoring an option at the end of a function in zsh
I'm writing a zsh shell function (as opposed to a script) where I would really like the extended_glob option to be enabled. But since the function runs in the caller's context, I don't want to clobber ...
6
votes
1answer
168 views
Ksh features incorporated into Zsh?
I have been a user of Bash for some time. I want to learn at least one other shell now, so I have been picking up the Korn Shell. However, it doesn't look like Ksh has had major updates for almost ...
1
vote
1answer
107 views
How to find/correct error in a path
It's often that a long path is mistyped or you get a log file entry that a path does not exist. Is there a command or shell function that navigates the path hierarchy until it finds a matching path?
...
2
votes
1answer
112 views
prepend digit to filenames which begin with digits (with zmv, please)
I have a directory with files named like 19.png, 20.jpeg, and README00.txt
I want to rename these to 119.png, 120.jpeg, and README00.txt.
I would like to do this with zmv as it works well in so many ...
3
votes
3answers
1k views
Having tmux load by default when a zsh terminal is launched
My current workflow is:
CTRL+SHIFT+T to launch a new terminal window. That starts a new zsh terminal.
Type tmux to start tmux.
How can I have tmux load by default with a new terminal window?
7
votes
2answers
334 views
Shell Script for going through a dir recursively and chmodding based on conditions of file type
Can anyone point me to either code or a tutorial for writing a shell script that can recursively go through an entire directory structure (starting at the current working directory, or given an ...
1
vote
3answers
154 views
Reevaluate the prompt expression each time a prompt is displayed in zsh
I'm adjusting my zsh prompt, based upon the dallas theme and the dstufft theme from oh-my-zsh. I love how dallas has various sections of the prompt contained in variables, which makes it much easier ...
1
vote
2answers
731 views
path_helper and zsh
I read that Apple, instead of jamming more and more PATH variable variations to the end of shell profile file, created path_helper binary so that it could expand PATH variable automatically by reading ...
2
votes
1answer
328 views
Zsh - alias -s with parameter
In zsh, I can specify default program to open which file extension like alias -s {mkv,mpg}='mplayer' . I runs fine but what I really want is to run mplayer <filename> & so it won't produce ...
4
votes
1answer
1k views
Running chsh does not change shell
I want to change my shell from bash to zsh.
I have tried running the following while logged in as user zol:
$ chsh -s /bin/zsh
$ sudo chsh -s /bin/zsh zol
$ su -c 'chsh -s /bin/zsh zol'
# The above ...
4
votes
2answers
936 views
zsh kill Ctrl + Backspace, Ctrl + Delete
How to configure zsh such that Ctrl+Backspace kills the word before point? How to achieve that Ctrl+Delete kills the word after point?
I use urxvt as terminal emulator.
1
vote
1answer
213 views
Cancel zsh tab completion
Is there a way to cancel a completion once it has been started? I sometimes foolishly press tab to autocomplete make targets (only from sheer indolence) and then end up having to wait for a longer ...
5
votes
5answers
329 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 ...
3
votes
1answer
153 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 ...
0
votes
1answer
351 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/...
...
...
...
1
vote
2answers
294 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 ...
3
votes
3answers
448 views
Expanding variables in zsh
The script below works in bash but not in zsh. I think it is because in the variable OPTS, I am "expanding" (not sure if this is the right word) the variable $EXCLUDE, and this syntax doesn't work in ...
2
votes
1answer
109 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 ~+ ?
11
votes
1answer
774 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
343 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 ...
2
votes
3answers
6k 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
182 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
140 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
92 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 ...
2
votes
1answer
92 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 ...
3
votes
4answers
216 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 ...
4
votes
2answers
1k 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
2answers
410 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 ...
7
votes
3answers
382 views
Can I highlight the current prompt line in zsh?
Is it possible to highlight (set a background colour) for the whole line of the prompt in zsh? In my emacs config I have the line on which the cursor sits a slightly different colour to the window ...
4
votes
0answers
150 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
161 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 ...
1
vote
2answers
151 views
Auto correct path when running a command from history?
I perform a recursive search to find a command I executed few days back and I want to run it. However that command should run from the path from where I ran it previously from and not where I ...
