Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [zsh]

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

-1
votes
0answers
20 views

Issue when editing multiline commands

I am using zsh 5.0.5 and have oh-my-zsh installed. When I want to edit a multiline command I noticed the following issue: When I go the parts of the commands in the previous line for editing the ...
1
vote
1answer
11 views

ZSH completion depending on the provided argument

Is there a way to access already provided argument as a variable in a ZSH completion scripts? here is the example: #compdef test _test_comp(){ t=($(cat /tmp/file_with_opts)) _wanted t expl "...
0
votes
0answers
12 views

Why zsh in OS X autocomplete ssh host while there are more hosts in the ssh config?

I have added bunch host names to ~/.ssh/config. And when I want to go to a server I just use tab in order to complete the host like ssh mongo.host.com. The problem is that I have recently added ...
-2
votes
0answers
22 views

Zsh: compare speed of print vs echo

From zsh doc: http://zsh.sourceforge.net/Guide/zshguide03.html I don't find related info that indicate print better over echo, but echo is older than print. I don't find useful link about speed ...
0
votes
0answers
15 views

Zsh: force file/folder obey new umask

Default zsh shell uses umask 0022, when changing to new umask, e.g: 0077. Only new file/folders after changing to new umask are applied. How to use zsh/or-else to force old file/folder create under ...
-1
votes
0answers
22 views

Zsh: simple and elegant extract function

There're buch of bash extract functions and one from oh-my-zsh How to have it in simple and elegant way of extract function?
2
votes
1answer
47 views

How to pass very many options to ImageMagick?

I am using ImageMagick to compose many images. for counter in {1..$limit} do partial=... x=... y=... convert $canvas $partial -geometry "+$x+$y" -composite $canvas done Basically I ...
0
votes
2answers
23 views

Zsh: add folder to $path recursively

I have ~/bin folder that contains multiple subfolders with arbitrary directory levels. This folder only for executable files that need to be added to path when start zsh, how to recursively add all ...
5
votes
1answer
128 views

Zsh: source scripts recursively

I have ~/scripts/ folder that contains multiple subfolders with arbitrary directory levels. This folder only for scripts that need to be sourced when start zsh, how to recursively source all files ...
1
vote
0answers
11 views

Customize ZSH history search in vi mode

I want to replace default history search widget in vi mode with my own (binding it the the default key, i.e. / in command mode). Here's what I tried putting in my .zshrc: custom_command() { ...
2
votes
2answers
24 views

Need optimal code for .zshrc to source file after curl

I am having issues with my .zshrc file setting up my zplugin for a first-time run. Its purpose is to fetch the installer from zplug github, run the shell install, then source it. This is my .zshrc ...
3
votes
1answer
54 views

Zsh: consistent history between machines

Use case: distribute zsh's history between machines in source control. Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to ...
4
votes
1answer
60 views

How can I source a bash script containing BASH_SOURCE from zsh shell?

I have a bash script that looks like this: ... SOME_VARIABLE=$(readlink -f $(dirname ${BASH_SOURCE[0]})) export SOME_VARIABLE ... I need to source it from a zsh shell as I need to have all the ...
2
votes
1answer
30 views

Zsh: condition if/then in prompt

Doc: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html doesn't seem to work in this use case. Use case: if prompt contains localhost then remove hostname from prompt, if not prompt ...
3
votes
0answers
45 views

Why does a failed filename generation make zsh stop processing a script?

I was trying to write a short script which would write all the executable programs found in $PATH: for dir in $(tr ':' ' ' <<<"${PATH}"); do for pgm in $dir/*; do if command -v "${pgm}"...
0
votes
1answer
40 views

zsh `time` doesn't work with `source` [duplicate]

I can use time to get running time statistics: % time zsh --version zsh 5.6.2 (x86_64-pc-linux-gnu) zsh --version 0.00s user 0.00s system 86% cpu 0.005 total How can I time how long a source script ...
1
vote
1answer
28 views

How can I view a cheatsheet/summary of a syntax construct of zsh in zsh itself? [closed]

I want something like the doc function in Clojure; I want to type cheat for and be shown some example usages of for in zsh. I don't mind installing an app for this, and I hope something like this has ...
0
votes
0answers
24 views

Tmux: terminal color is different inside tmux

OS: Arch latest zsh: 5.6.2.1 tmux: 2.8.1 TERM: screen-256color Color of vim both in terminal st-terminal and tmux set correctly. But zsh's color - shell's color changed. e.g: do ls in terminal ...
2
votes
0answers
25 views

How to make zsh pass the manual section to the man command when the `separate-sections` style is set?

When asking for a completion by pressing Tab on the zsh command line, the matches can be grouped according to their tag provided that the group-name style is set to an empty string: autoload -Uz ...
0
votes
2answers
70 views

“kill -l” only returns ZERR

While trying to send SIGQUIT I got this: $ kill -s QUIT 4341 kill: unknown signal: SIGQUIT kill: type kill -l for a list of signals And I was very surprised to see this: $ kill -l ZERR So, ...
1
vote
2answers
64 views

Remove forward slash when tabbing to see a list of directories

Is there a way to remove the trailing forward slashes in the tab-completion output of Zsh when I start writing a cd command and tab to see a list of directories? E.g. ~ cd <tab> Adlm/ ...
0
votes
1answer
22 views

How to auto-update custom plugins in Oh My Zsh?

I've installed Oh My Zsh with a few custom plugins, such as zsh-autosuggestions. Now while Oh My Zsh supports automatic updates, this doesn't apply to custom plugins (installed to the custom/ ...
1
vote
0answers
35 views

How to extend existing zsh completion functions?

I'm trying to add auto-completion for some custom ant parameters. However, it seems to be overwriting the existing oh my zsh ant plugin auto-completions which I'd like to keep. Is there a simple way ...
0
votes
1answer
40 views

Why does zsh replace hyphens with underscores in these functions?

I've got the following function aliases sourced in zsh and bash consoles: compose() { docker-compose $* } run() { compose "run --rm app $*" } rails() { run "rails $*" } In bash, running ...
0
votes
0answers
25 views

How to use zsh compctl with fallback

is there any way to let a programmable completion fall back to path completion? E.g., if the dotnet process doesn’t return any completion suggestions (https://github.com/dotnet/cli/blob/...
0
votes
1answer
37 views

read from stdin works differently in bash and zsh [duplicate]

I'm trying to pipe a command's output to the read builtin of my shell and I get a different behaviour for zsh and bash: $ bash -c 'echo hello | read test; echo $test' $ zsh -c 'echo hello | read ...
2
votes
2answers
67 views

New tmux session only sources .zshrc, and doesn't pick up the $PATH defined in .profile

After reading multiple questions on this topic I still feel lost. I read suggestions that one should set the environment variables including $PATH in .profile instead of specifically in .bashrc or ....
2
votes
1answer
68 views

Change the shell of vim

I change my shell to zsh now.But when I call shell in vim by :! xxx will call the bash.So, how can I call zsh in vim ?
0
votes
0answers
16 views

Run tmux without user process, to just provide its /dev/tty* – is this possible?

In Zsh I can do vared -t /dev/ttys002 ZSH_VERSION and use vared (variable-editor) on a foreign TTY (in this example on OS X /dev/ttys002). I already did this trick with Tmux, first obtaining the TTY ...
0
votes
1answer
28 views

Rip-off (an ncurses term) single bottom line out of /dev/tty terminal, is it possible?

Ncurses allows to separate a single line from screen, at level of physical screen (curscr), to devote it to e.g. a title bar, thus also creating a logical screen (stdscr), devoted to application's ...
0
votes
1answer
22 views

What does `==` do in zsh expansion?

I came upon this code: map () { eval "$initDocs" usage "<lambda-function> [<item>...]" example "'<--- \$1 --->'" a b c d eval "$doneDocs" typeset f="$1" ...
0
votes
0answers
10 views

Unable to source file with aliases in zsh on MacOS [duplicate]

I have created a file with some aliases that I need to from time to time. These aliases are simple kubectl port forwarding commands. For the test purpose, I have left only one alias in the file: ...
1
vote
1answer
41 views

ZSH Prompt printing '[m' instead of '%'

I added a battery function to my vim statusline here's a link. It displays my battery correctly in vim and if I run $ acpi | grep -oP "(\d+)%" it returns some number followed by the percent sign (as ...
1
vote
1answer
40 views

Non-greedy (extended) globs in zsh

I like to do non-greedy globs, but my Google searches hint that this is not supported. Is this the case? If so, why is it the case? For example I'd like to use a non-greedy glob in history expansions,...
0
votes
2answers
50 views

Using flock fails with zsh but works in bash?

Employing the mechanism from the answer at https://unix.stackexchange.com/a/274499/5132 in the Z shell: ( flock -x 200 echo "test"; ) 200>mylockfile2 returns zsh: parse error near `200' While ...
0
votes
1answer
25 views

How to bind a keyboard shortcut in zsh to a program requiring stdin?

This is a follow-up to this question: I'm trying to create a keyboard shortcut for the terminal file manager ranger, in order to jump from the zsh prompt into the file manager with a single keystroke. ...
0
votes
1answer
16 views

Xinit/zsh: jobs control

In .xinitrc, there'll have multiple lines with & to put some commands in background, I'd like to control if a command is completed or not before process to next command. I use zsh in .xinitrc ...
1
vote
4answers
54 views

Floating point numbers in bash [duplicate]

I want to do some arithmetic with bash. They say to use the right tool for the job, and the shell might not be the right tool here. But it is the right tool for what I'm doing otherwise, and this is ...
2
votes
1answer
38 views

Start shell with tmux and attach only to a session if it is unattached

I am currently starting tmux when opening my shell, which the following config for my shell [[ $TMUX == "" ]] && tmux new-session Is there any way to start my shell and attach tmux to the (...
0
votes
0answers
27 views

Zsh wants to correct git hist to git host

On my Mac systems, I have zsh set as the login shell and use oh-my-zsh, and everything works correctly. On our Linux cluster, tcsh is the login shell, and it has to be because our sysadmins have ...
0
votes
0answers
14 views

tcsh tab auto completion to match the MIDDLE part of the file name in the folder?

I have searched through google and So, while there is no hit for the auto completion function for tcsh that can do something similar to zsh that: when doing 'cd' or 'ls' you can match the MIDDLE ...
4
votes
1answer
281 views

zsh and POSIX equivalent of bash's `{var}>&1`

Is there an equivalent of {var}>&1 in zsh? The bash manual says: Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. ...
1
vote
1answer
45 views

Weird behavior in zsh random generator

I have this script to generate $1 digit(s) of mixed random char from the defined charlists as arrays. #!/bin/bash charlist1=(a b c d e f g h i j k l m n o p q r s t u v w x y z) charlist2=(0 1 2 3 4 ...
3
votes
1answer
88 views

How to print all the attributes of a zsh parameter?

I can give the -U attribute to a non-associative array so that it can't contain duplicate elements: % declare -U path % path=( ~/bin $path ) % path=( ~/bin $path ) % echo $path Here, even though I'...
2
votes
2answers
73 views

Expanding variable at function definition in zsh

I'm having some trouble with trying to evaluate/expand a variable when I define a function in zsh - Is this possible? Example: variable=foo mytest(){ echo ${variable} } mytest //outputs ...
0
votes
1answer
37 views

ZSH and GDBM support

I am trying to learn more about ZSH and the way that my shell is setup and operates. I am running OSX and have installed ZSH with HomeBrew so as not to use my standard system ZSH. However, before ...
1
vote
1answer
42 views

Replicate oh-my-zsh directory tab completion selection with arrow keys

With oh-my-zsh they've extended cd tab completion so that, once the directory selection is active, you can move around all the available directories with the arrow keys, rather than just tabbing ...
1
vote
1answer
67 views

Zsh/Tmux: Wait for success of subprocess

Refer to this unanswered question before continuing: Tmux: check exit code of command that was sent by send-keys tmux send-keys just sends the command and exit successfully but repeat 5; do print ...
2
votes
1answer
57 views

Using heredoc in zsh aliases

I would like to use heredoc in a zsh alias, for example: alias runthing="cd ~; date << HERE date HERE" However every time I run this alias, the shell acts as if I have not terminated the ...
2
votes
1answer
42 views

Display “time” of process periodically

A week ago, I launched simulations as follows: make rebuild; time make run Using the command time I recorded the CPU time used in each case. A week later, the simulations finished but, much to my ...