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

learn more… | top users | synonyms (1)

2
votes
1answer
16 views

align rprompt with top of prompt

I've recently been getting really excited about zsh, and making myself an extravagant prompt, but I'm stuck trying to align my RPROMPT. I have an output like this: | [14:59:44] git:(master) ...
3
votes
2answers
37 views

Looking for a convenient way to create a “constant array”

In zsh, is there a convenient way to create an array of n copies of the same integer? Context: In a shell script, I need to create an array, tile_lengths, consisting of two longish constant blocks. ...
1
vote
1answer
13 views

Alias folder of executables with prepended keyword

I have several executable files in a folder /opt/chefdk/embedded/bin/. Examples are ruby bundler chef. Ideally I want to be able to run these files by simply prepending the keyword chef-$1 or chef ...
1
vote
2answers
61 views

forward aliases to child process

I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there. I want to start an interactive shell from a shell which avoids the $PATH ...
8
votes
4answers
6k 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 ...
1
vote
3answers
23 views

How to remove a zsh keybinding if I don't know what it does?

How do I disable a keybinding if I don't know what it is or what it's triggering? I have my zsh key mode set to vi-mode, through bindkey -v. To do a history search, I press Esc to get to "command ...
14
votes
4answers
5k views

ZSH: search history on up and down keys?

Currently, I have the following in my .zshrc: bindkey '^[[A' up-line-or-search bindkey '^[[B' down-line-or-search However, this only seems to match the content of my current input before a space ...
1
vote
1answer
36 views

Shell Font Over SSH

I have a Linux machine (CentOS 7) in which I frequently SSH into from multiple devices. I have installed ZSH and Oh-my-zsh on the remote machine. I would like to install the following theme: ...
2
votes
4answers
96 views

Copy files to new directory only if name of file is in an array

I'm not much of a zsh buff but I imagine this should be an easy layup for someone: I can bulk copy files from sourcedir to targetdir with the following: $ find sourcedir -type f -exec cp {} ...
4
votes
4answers
217 views

Prefer file types in command line

Often I have to annotate multiple pdf documents using xournal. If I start with a directory of "fresh" pdf files, I just open them all with xournal: for f in *pdf; do xournal $f&; done When I ...
5
votes
2answers
97 views

How can I use the output of a command without using the mouse?

Imagine you issued a find command and now you want to use one line of the resulting output as an argument. $ find .. fileA fileB $ vi <CURSOR> # now do what to achive: $ vi fileB ...
0
votes
0answers
15 views

Unable to execute the rest of my shell script after installing Oh My Zsh [on hold]

I thought that here it will be better to ask for help with my problem. In a nutshell: I'm creating my custom shell script to simply customise my Mac. To make a short example: 1) I install OMZ using ...
1
vote
0answers
14 views

zsh auto completion certain parts of directory

I currently have zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' which will ignore the case when auto completing directories. However is it possible to type a certain part of the directory and ...
2
votes
1answer
33 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 ...
0
votes
1answer
26 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
66 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
37 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 ...
1
vote
1answer
17 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
23 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 ...
8
votes
0answers
33 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
24 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
17 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
34 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
61 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
13 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 ...
17
votes
5answers
8k 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
34 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 ...
1
vote
2answers
48 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
25 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
1k 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 ...
11
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
15 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
31 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 + ...
2
votes
1answer
33 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
15 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
31 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
63 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
381 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 ...
5
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
29 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
31 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
96 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
38 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 ...
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 ...