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

learn more… | top users | synonyms (1)

2
votes
1answer
40 views

zsh tcsh-like history navigation

In tcsh, the \eP and \eN commands take into account the whitespace-normalized prefix of the current line, not just the first word. For instance if my history contains git pull upstream feature-...
0
votes
1answer
46 views

Zsh: hash directory completion

I have configured some directories alias via hash -d hashname=/path/to/directory command. Completion for that aliases works for a long time like this: % hashn<TAB> # becomes hashname, pressing &...
3
votes
2answers
75 views

Move to the previous line of a multi-line command

When editing multi-line commands, with escaped newlines, I cannot move up lines. For example, suppose I enter echo \ one one line, then I press Enter, and then I want to edit the echo \ part of the ...
3
votes
2answers
38 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with >(...
2
votes
1answer
33 views

How can I get a help message for zsh builtin's?

If I want to get a brief usage message for a bash builtin, I can use help <builtin> at a command prompt, e.g. $ help export export: export [-fn] [name[=value] ...] or export -p Set export ...
2
votes
0answers
26 views

Sometimes my zsh messes the end of lines

I have this strange issue, that I cannot find the source of, nor a solution to solve. "Sometimes" my zsh gets messed up and start display end of lines in a funny way: As you can see, the newlines ...
9
votes
0answers
66 views

Completion for the first argument of cd OLD NEW

In zsh, the cd command has a two-argument form: cd OLD NEW changes to ${PWD/OLD/NEW}. With the new-style completion system, zsh is capable of completing NEW: the second argument is completed based on ...
2
votes
1answer
25 views

Why is a daily .zshrc reload required using an alias containing $(date -u +%Y%m%d)? [closed]

Each morning I run the following command that tails a log file created daily: ssh -t server@55.555.55.55 tail -f development/abc/$(date -u +%Y%m%d).log This works just fine and each morning the log ...
1
vote
1answer
14 views

How to include all PIDs in tab completion?

When I enter a command that takes a process ID (such as kill and strace -p), ZSH's tab completion offers what looks like the PIDs of the processes running in my current shell session. How can I make ...
0
votes
2answers
18 views

ZSH function to edit a file based on an input at the cli

I need to set up a function in zsh that would edit a different file based on some input at the command line. I want to simplify my aliases so I don't have multiple aliases to do the same thing but ...
2
votes
1answer
48 views

Pasting text in zsh in vi mode

I changed input mode in zsh to vi with set -o vi, but that created problems with pasting text. While trying to do cmd-v (MacOS) in the insert mode, zsh is pasting only a fraction of the clipboard ...
2
votes
1answer
66 views

How do I run multiple commands together in the background?

I know I can run a program in the background using &. command & However, I want to run multiple commands, and cd into a different directory while they are running. The multiple commands ...
0
votes
0answers
14 views

Reading error output string in oh-my-zsh

I am using oh-my-zsh to automate some of the Unix tasks i do. One of the task require making a call, and if successful, echo a message. However, if there is a failure, I dont wan't to echo the success ...
18
votes
5answers
9k views

How can I search history with what is already entered at the prompt in zsh?

In zsh, I know that I can search history with Ctrl+r. However, oftentimes I start to type a command directly at the prompt, but then realize I should be searching history. When I hit Ctrl+r, it brings ...
1
vote
1answer
66 views

zsh fails at path completition when command is vim

When I try to autocomplete files (with vim as argument 0): vim ~/.conf <TAB> It shows: _arguments:450: _vim_files: function definition file not found _arguments:450: _vim_files: function ...
2
votes
2answers
73 views

Relationship between zsh custom completion script and compsys/zstyle configuration

I have written a simple completion script for a command cheat so that when using cheat at a prompt zsh will autocomplete arguments. (obviously) this needed to be setup in a compinit / compsys ...
3
votes
0answers
29 views

How can I use a key other than <ENTER> to exit zsh's completion menu/widget?

Like alot of zsh users I have completion configured so that when I am at a command prompt and I invoke completion a menu appears that can be navigated with the directional arrow keys. i.e. in my ~/....
8
votes
2answers
2k views

Are there problems with hyphens in functions, aliases, and executables?

In my testing (in Bash and Z Shell), I saw no problems with defining functions or aliases or executable shell scripts which have hyphens in the name, but I'm not confident that this will be okay in ...
12
votes
2answers
3k views

is there a way to set coloring for cd tab complete?

I use ubuntu 11.04. Is there a way to set coloring for output after tab completion listing of a cd, ls, or etc. ? i.e. myshell@root$ cd ~/user/files/ I hit tab... myfile myfoo mybar <-- this ...
2
votes
3answers
2k views

Update process name in shell, is it possible?

In C/C++ it is in general possible to do strcpy(argv[0], "new process name"). It's a hack used in malicous software to hide real process name. Is such operation possible via shell? What I want to do ...
8
votes
6answers
2k views

Serialize shell variable in bash or zsh

Is there any way to serialize a shell variable? Suppose I have a variable $VAR, and I want to be able to save it to a file or whatever, and then read it back later to get the same value back? Is ...
1
vote
0answers
18 views

Can I get zsh to include the directory stack in tab completion for tilde (~)?

I have autocd, autopushd and pushdminus enabled. When I try tab completion with ~: $ ~<Tab> avahi ftp mail redsocks systemd-coredump systemd-timesync bin gdm nm-openvpn ...
0
votes
2answers
38 views

Problem with understanding keys bindings

I have a settings and a zsh session ~ bindkey | grep help "^[H" run-help "^[h" run-help Why when i press "Control + [ + h" word under cursor removes and nothing happens, but if i press "Alt + h"...
2
votes
1answer
45 views

alias ? not working in zsh

I was lead to believe that there were no differences between aliases in zsh and bash, however that appears to not be the case. I had an alias that would help me familiarize myself with the command ...
1
vote
1answer
24 views

Can I selectively disable zsh completions?

I'm using prezto with zsh, and find it a little slow to launch a new shell. (N.B. I'm attempting to optimise on a fast-ish system, before moving my configuration to other, slower systems.) ...
3
votes
1answer
32 views

zsh: menu completion for glob

In zsh, if I type vim *.txt then Tab, it expands to vim f1.txt f2.txt f3.txt. How can I make it show a completion menu listing files matching the pattern, so I can select a single file?
0
votes
1answer
81 views

Find not working

The find command is not working as expected on my OSX with oh-my-zsh. A few examples: $ find . -name test find: .: Invalid argument $ find usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [...
7
votes
2answers
3k 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 ...
11
votes
2answers
3k views

Zsh completion of brew formulas

In OS X, is there any way to have Zsh (I'm using Oh-my-zsh) tab-complete formulas? E.g. $ brew install em<TAB> could expand to: $ brew install emacs
2
votes
3answers
400 views

How to sort filenames with spaces in them and concatenate the files?

I have the misfortune of dealing with filenames that contain spaces. I want to concatenate files of which filenames contain spaces. I also want to sort the filenames numerically. Obviously the ...
6
votes
2answers
3k views

Double rm verification in zsh

When I do a rm * in zsh, I get something like this: 2014-06-08 10:14:23 $ rm * zsh: sure you want to delete all the files in /home/assay/assay/log [yn]? y rm: remove regular file `development.log'? y ...
1
vote
1answer
34 views

How can I get a persistent dirstack with unique entries in zsh?

The Arch Wiki has this interesting bit of zsh configuration: DIRSTACKFILE="$HOME/.cache/zsh/dirs" if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then dirstack=( ${(f)"$(< $...
1
vote
0answers
35 views

Disable Oh-My-ZSH Completion of Beginning of Filename

I'm starting to use the directory stack in ZSH, but I've run into a problem. In an ideal directory, typing cd -<TAB> gives me the output of dirs -v. However, in some others (i.e. my Downloads ...
2
votes
1answer
97 views

Directory stack order discrepancy in zsh

I am working on Zsh 5.0.2 (latest stable version), and I noticed that: dirs -v and cd -<TAB> show a different list of directories (or at least directories in different order). Moreover, ...
14
votes
8answers
3k views

How to cd automatically after git clone?

I want to automatically cd to the directory created by the clone command after I git cloned something. Important: I don't want to alter the syntax for the command (e.g. use an alias/function) because ...
3
votes
1answer
43 views

Standard/canonical way to test whether foregoing pipeline produced output?

The situation I have in mind has the following structure: % some_command | [PRODUCED OUTPUT] || echo 'no output' >&2 Here [PRODUCED OUTPUT] stands for some as-yet-unspecified testing command,...
16
votes
1answer
1k views

Why does this ffmpeg command work in bash and not zsh?

Today I got home from work (run bash on an Ubuntu box) and tried to run some code on my local arch box with my beloved zsh and the commands were failing? The command is below with the personal info ...
1
vote
0answers
35 views

Issue in activating environment on UAT server

I was working on a script that logs in to UAT server, reroute to necessary folder and activates the virtual environment. Following is the script: function gotouat(){ branch=`getBranchName`; ...
7
votes
3answers
543 views

Per-directory history in zsh

I am happily using zsh since a while now, and I am quite satisfied with my history settings, which are: # Write to history immediately setopt inc_append_history # History shared among terminals ...
1
vote
1answer
101 views

Execute a command in zsh vim mode

In zsh in vim mode, I write something foo foo bar bar Then I hit Esc to go in normal mode and type : foo foo bar bar execute: _ Then, I assume I can do that, I want to search and replace bar ...
3
votes
3answers
54 views

All files in a directory that do not end in a specific string?

I want to find all text files in a directory that do not end with the string: hello world How can I do this?
0
votes
1answer
59 views

PATH not getting exported from ~/.profile until manually sourced

I am trying to modify my PATH in ~/.profile: export PATH=$PATH:/opt/jdk1.8/bin echo "Path is exported." I will always login via SSH so that's why I have it in ~/.profile. I am using zsh (oh-my-zsh) ...
1
vote
2answers
173 views

Specifying numeric ranges in zsh history

According to the docs I can tell the zsh history to print lines in a range. The docs say "history [first [last]]" I've tried "history a b" but that gives a too many arguments error. I've also tried ...
2
votes
2answers
60 views

Prompt: replace custom path with a short word like ~ for home

When I call cd /Users/mu3/apps the prompt simplifies it like this: mu3 [~/apps]: Is this possible to do the same for custom path like cd /Users/mu3/Development/Web/test: mu3 [DEV/test]: I'm ...
2
votes
2answers
61 views

How to store the printout of the last command in a shell variable in urxvt/zsh?

I'd like to have the printout (stdout and stderr) of the last command run within zsh available in a variable ready to use grep, etc on it.
0
votes
1answer
41 views

How to find latest file and delete old files in a group of files in zsh scripting? [duplicate]

I am facing problem in zsh scripting. I have group of files in a directory such as: 001_20160223.txt /delete 001_20161102.txt /delete 001_20161209.txt /keep 005_20160502.txt /delete 005_20161105....
0
votes
1answer
67 views

ZSH, concatenate passed in arguments into a single string

I would like to create a simple bash function to use for my convenience. Following the answer given at: Joining bash arguments into single string with spaces I've been able to mash up this small piece ...
1
vote
0answers
27 views

How to have full completion in a run application dialog?

I've configured XFCE to execute gmrun as run dialog (Alt-F2). It works great with completion on commands but does not propose completion on arguments. How to set up a run dialog with full bash/zsh ...
2
votes
0answers
61 views

zsh theme doesn't work on a remote server [closed]

Here is a screenshot from the author of a theme: And this is what I have: What am I doing wrong?
2
votes
1answer
133 views

pushd, popd vs cd, cd- in bash and zsh

Is there a difference between the behavior of pushd/popd in bash vs zsh? It seems in zsh cd, cd- behaves exactly the same as pushd/popd (which adds/pops directory automatically when cd) while in bash ...