Zsh is a shell with many advanced command-line and scripting features.
21
votes
3answers
1k views
How to use `which` on an aliased command?
Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance,
alias vim='vim -X'
alias grep='grep -E'
alias ls='ls -G'
The problem is ...
63
votes
1answer
9k views
Difference between nohup, disown and &
What is the difference between
$ nohup foo
and
$ foo &
and
$ foo &
$ disown
15
votes
2answers
1k views
Display stuff below the prompt at a shell prompt?
Lets's say my prompt looks like this (the _ represents my cursor)
~ % _
Is there any way I could make it look like this
~ % _
[some status]
The question was originally about zsh, but now has ...
6
votes
1answer
242 views
What is the best way to detect (from a script) whether software is installed?
I've been frustrated before with differences in output from the which command across different platforms (Linux vs. Solaris vx. OS X), with different shells possibly playing into the matter as well. ...
2
votes
1answer
565 views
zsh equivalent of bash show-all-if-ambiguous?
In bash, if you hit tab when there are multiple possible completions you get a list of matches that keeps reprinting if you repeatedly press tab. In tcsh, setting autocomplete to enhanced also ...
26
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 ...
6
votes
2answers
1k views
Force title on GNU screen
By default, the title of a screen session is the name of the last command entered, which is fine for me, but in some cases I'd like to change it. I know the command Ctrl-A A, but it only changes the ...
6
votes
3answers
3k 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.
6
votes
3answers
889 views
How to delete part of a path in an interactive shell?
Is there a shortcut in bash and zsh to delete one component of a path? For example, if I type ls ~/local/color/, and the cursor is at the end of line, is there a shortcut to delete the color/ at the ...
2
votes
1answer
329 views
Wrapping a command that includes single and double quotes for another command
I recently learned about watch, but am having trouble making it work with relatively sophisticated commands.
For example, I would like to ask watch to run the following command on zsh every three ...
25
votes
4answers
2k views
Is there any way to keep a command from being added to your history?
Is there any way to keep a command from being added to your history? I have a command that I want to keep out of my history file, and I really don't care to have it there when I search the history ...
10
votes
3answers
3k views
make my zsh prompt show mode in vi mode
I use bindkey -v (for bash-ers set -o vi I think that works in zsh too) or vi(m) mode. but it bugs me that I don't have any visual cue to tell me whether I'm in insert mode or command mode. Does ...
7
votes
2answers
1k views
Testing LS_COLORS in zsh
A few years ago I found an interesting code snippet that prints each type of file in its corresponding color according to the colors set up in LS_COLORS. Unfortunately, I can't remember the link ...
6
votes
1answer
245 views
Can I have my shell history record how wildcards expanded?
If I run:
$ ls *
foo bar buzz
$ history | tail -1
ls *
You can see that in my shell history it remembers that I ran ls * rather than ls foo bar buzz. Ideally, I'd like to record both in separate ...
2
votes
1answer
204 views
zsh history - full path
Suppose I do the following in zsh
cd ~
cd dir1
cd dir2
cd dir3
evince foo.pdf
zsh writes exactly the same in its history file.
Now my question is whether it is possible to have
cd ~
cd ~/dir1
cd ...