Questions tagged [zsh]

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

204 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
1answer
636 views

zsh can't input to terminal when piping stdin and stdout with variable command that has tty output

System info: macOS Sierra 10.12.6 zsh 5.4.2 (x86_64-apple-darwin16.7.0) GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0) Scroll to the EXAMPLES at the bottom if you just want to dig ...
6
votes
0answers
406 views

How to capture the xtrace output (only) in a file?

I know that I can redirect the xtrace output to some_file with something like this: exec 2 >> some_file set +x ...but this sends to some_file not only the xtrace output, but also any other ...
4
votes
0answers
79 views

zsh tab complete . to ./

Not a duplicate: I'm not looking for a way to complete directory names or execute scripts from a fixed directory. The issue I'm trying to solve is to get completion for the current directory without ...
4
votes
1answer
148 views

Case insensitve tab completion zsh without increasing startup time significantly

So I wanted to get away from oh-my-zsh because it made my shell startup lag noticeably (>0.1s). Indeed, after removing oh-my-zsh the startup time went to 0.02s but now I started adding features ...
4
votes
0answers
110 views

zsh keybinding: ignore given command in insert-last-word

In zsh, I have alt+. bound to insert-last-word. When I press alt+., I can list through the last word of previous commands. How can I exclude some words from being shown when I cycle through ? ie, ...
4
votes
0answers
195 views

How to teach zsh when not do autocorrect?

I love the autocorrection feature of ZSH, but sometimes it gets in the way: If I have a cli directory, it will be suggested when I try to run npm run ci. When running the Docker command docker run -...
4
votes
0answers
132 views

How do I wrap the zsh completion list with a fixed line of text before and after?

Specifically, I'd like to arrange for all completion lists (under the :completion:* context) to be preceded and followed by a fixed string (say "ABC" for the moment) on its own line. I have tried a ...
4
votes
0answers
340 views

custom zsh autocomplete

I'd like to write a zsh completion for pytest. Where do I Start? I'm using oh-my-zsh. in .zshrc: fpath=($HOME/.mycompletions $fpath) autoload -U compinit && compinit -u in $HOME/....
4
votes
0answers
112 views

Manual tab completions in zsh

I would like nm[TAB] to expand to node_modules in zsh. Is this possible? How can it be done? Ideally, it wouldn't be triggered if there is another completion available, such as an already existing nm ...
3
votes
2answers
50 views

zsh completion for media player

In my .zshrc, I have menu select disabled globally, except for mpv/mplayer: zstyle ':completion:*' menu select=0 zstyle ':completion::complete:mpv:*' menu yes select This works as expected, but I ...
3
votes
1answer
155 views

XFCE - Blank text in terminal

I've just performed a fresh install of Arch Linux on my laptop (ThinkPad A485, though that's probably not relevant here), and installed XFCE4. Everything seems to be working with the exception of one ...
3
votes
1answer
110 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 ...
3
votes
0answers
64 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}"...
3
votes
0answers
175 views

Text gets messed up in history search(ctrl-r)

I using zsh. However, the command search history feature(ctrl-r) is giving me issues. Specifically, the text gets garbled. Everything executes correctly regardless, but UX it's a bad experience. ...
3
votes
0answers
162 views

Use colon as filename separator in zsh tab completion

I have many programs which take filename arguments as one(or more) of path/to/file scp:path/to/file.ext ark:/abs/path/to/file.ext Is it possible make zsh complete filenames after some keywords ...
3
votes
1answer
115 views

Don't try to correct a command that exists now

I like zsh's autocorrect for commands. It has an annoying feature, however: sometimes I try to run a command, notice it doesn't exist, install it, then try to run it again, and zsh still wants to make ...
3
votes
0answers
41 views

How to customize the look of currently selected(highlighted) completion in zsh?

Main question I would like to add powerline characters at the start and at the end of the selected completion, like this: Started the completion menu by inserting c and pressing the TAB key. Moved ...
3
votes
0answers
1k views

Powerline Fonts for zsh in TTY

I'm using UBUNTU 16.04. In graphical terminals like "Terminal" "guake" and "terminator" I am using zsh with Powerline-Fonts. I looked around a bit but found no proper solution to activate powerline ...
3
votes
0answers
231 views

ZSH custom completion from command output

I am creating a custom completion for my command ipadd which will automatically complete all the network devices for OS X. It has a parameter --device which allows you to specify the network devices ...
3
votes
1answer
425 views

Zsh clear command line from zsh/sched call

I try the following: clear-cmdline() { zle && zle kill-buffer sched +3 clear-cmdline } sched +3 clear-cmdline After I run this code, I enter a few letters at prompt, and wait. ...
3
votes
0answers
28 views

Testing that disk is parked

I run a command in zsh's preexec(), i.e. before every other command entered and accepted for run. Would like to skip doing this when I detect that the disk of current $PWD is parked. Can I do proper ...
3
votes
1answer
46 views

zsh fail to keep unquoted `$*` and `$@` equal

All shells tested do the same for the (quoted) pair "$*" and "$@" with this code: c='set a b @ c; IFS=:,@ ; a=$(printf "<%s> " "$*"); b=$(printf "<%s> " "$@"); printf "%-20s and %-20s\n" "...
3
votes
1answer
399 views

history shows only current session

This is what I see in my terminal in a fresh session: Agent pid 6847 Identity added: /home/eric/.ssh/id_rsa (/home/eric/.ssh/id_rsa) ➜ ~ history 1 history ➜ ~ I'm using Linux Mint 17.3 64 ...
3
votes
0answers
52 views

How do I write a custom filename completer for specific directories in zsh?

I've found that file names with dates before the title are difficult to tab-completion. I'd like to write custom completion functions for these directories. How do I specify that the completer should ...
3
votes
0answers
1k views

Making zsh filename completion case-insensitive everywhere

I have the following line in my zshrc to make filename completions case-insensitive: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' This works most of the time but I’ve noticed that if I ...
3
votes
0answers
325 views

Call vared and complete files from a different directory

I have the following zsh function which lets me edit symbolic links using the vared ZLE builtin. function lned { emulate zsh setopt err_return extended_glob local_options local_traps local -a ...
3
votes
0answers
122 views

ZSH and completion of files with newline characters

I am experimenting with ZSH on nasty file names, especially file names with the newline character in it. Here is how I create them: $ touch "filename<hit return here> 1" $ touch "filename<...
3
votes
0answers
331 views

Git completions for aliases only available after running `git reflog`

I have a few aliases that I want to autocomplete for git, e.g., the following alias gco="git checkout" When I was attempting to add completions for this alias, I looked around in my path and saw ...
2
votes
0answers
40 views

Tab complete global alias names not at the beginning of a line

I have a bunch of aliases like this alias -g foo=cmd1 alias -g faz=cmd2 alias -g fam=cmd3 At the shell (I'm using zsh) I want to be able to type echo fa<TAB> and be prompted for faz or fam ...
2
votes
0answers
42 views

Small delay in sudo

I want my zsh prompt to display whether the session has sudo rights (from a previously run sudo command). After looking at the answers to this question, I arranged to use the exit status of sudo -n ...
2
votes
0answers
156 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 ...
2
votes
1answer
42 views

Generating quoted command arguments

I'm working with a HTTP API that demands a very particular set of signed headers + JSON body. And I really want to cURL it for debugging and sanity in general. So, I've written a small script that, ...
2
votes
0answers
103 views

Debian multi-line prompt in konsole

Sorry if I am wrong here, but I have no idea where to search for my problem. I accidentally upgraded my Debian system to stretch (stable). Since I did so, the konsole isn't working properly anymore. ...
2
votes
1answer
127 views

Does fd number of various shells fixed?

Let's say: xb@dnxb:/tmp$ echo 'ls -l /proc/$$/fd | grep a.sh' > a.sh; \ > while IFS='' read -r f; do \ > echo "$f"; "$f" a.sh; \ > done < <(tail -n +2 /etc/shells) /bin/sh lr-x------...
2
votes
0answers
269 views

zsh: SHARE_HISTORY or INC_APPEND_HISTORY breaks EXTENDED_HISTORY

I would like to both share history across terminals and keep track of elapsed time for history commands. The intuitive way seems to be to use both EXTENDED_HISTORY and SHARE_HISTORY, but this sets all ...
2
votes
1answer
211 views

With zsh how to add autocompletion for a specific script, with autocompletion choices coming from a file?

I have written a small shell script that takes a single command line argument. I'd like to be able to autocomplete when I start writing an argument, the autocompletion choices should come from a ...
2
votes
0answers
95 views

zsh: use setopt AUTO_MENU conditionally, depending on $PWD

generally, I find the zshoption AUTO_MENU annoying, and I disable it in my .zshrc: setopt noautomenu However, there are some directories where I have files with long filenames, with spaces in ...
2
votes
0answers
89 views

How to repeat a zle widget an arbitrary number of times when the completion menu is open?

I'm using the zsh shell, and I'm trying to install a few key bindings to use keys similar to the ones I would use in a Vim buffer, when a completion menu is open. So, inside the menuselect keymap I'...
2
votes
0answers
206 views

zsh is crashing on my linux environment, looking for debug tips

I use tmux and my shell is zsh with a variety of Oh-my-zsh customization. Lately I have started to experience the terminal abruptly closing when finishing executing a program such as git log showing ...
2
votes
1answer
286 views

Color folders in ZSH based off directory depth

I'm currently editing the agnoster theme from oh-my-zsh to my preferences, and was wondering if there is some way to color the names of directories in the status bar based off depth. Something like... ...
2
votes
0answers
90 views

How to control mysql with zpty?

I try to write a wrapper script for the mysql console client. While working on this, I stumbled upon zpty. It seems perfect. My first goal was to retrieve some table contents, but I already fail ...
2
votes
0answers
231 views

“gnome-terminal -e tmux ./” keeps opening terminals forever

I recently asked this question. I won't ever use the first method. gnome-terminal -e tmux ./ if I put that in .zshrc or .bashrc (both shells, same problem). If I use that, the terminal will keep ...
2
votes
1answer
582 views

zle reset-prompt prevents browsing history with arrow keys

I just installed zsh and oh-my-zsh (my previous shell was bash). My .zshrc is completely unmodified from oh-my-zsh's default settings. The "git" plugin is the only enabled plugin (it's enabled by ...
2
votes
0answers
252 views

how to scroll multiple lines in zsh screen completion

Thanks to this question, I was able to configure zsh to properly scroll one line up or down when hitting "pgup/pgdwn" in a autocompletion menu: bindkey "${terminfo[kpp]}" up-line-or-history bindkey "$...
2
votes
0answers
346 views

What does ttyctl -f do, and why does it enable flow control in vim, mutt, etc.?

Background I have the following two lines in ~/.zshrc. setopt noflowcontrol ttyctl -f The first line disables flow control in zsh. I'm unsure what the second does, but I was advised to add it from ...
2
votes
0answers
194 views

Autocomplete flags after a subcommand

There is a program I have called luarocks that features a list of subcommands like build, install, and make, with flags after them. At the end, a command would like like the following: # luarocks ...
2
votes
0answers
149 views

Is there a plugin or tool for multiple “profiles” in ZSH?

I use oh-my-zsh for all of my console goodness. Depending on what I'm working on, there are certain environment variables that I'm often overwriting either manually or through scripts to make my work ...
2
votes
1answer
122 views

Use all hosts completed by zsh for cssh

Is there any possibility to use all completed hosts with cssh? E.g: cssh www* This should establish three connections to www1, www2, www3 If I press Tab after www I get all three possibilities.
2
votes
0answers
505 views

zsh completion by history not working

I read the answer https://stackoverflow.com/a/13614816/4126652 and tried out the history-beginning-search-menu I added the the 3 lines to my zshrc autoload -Uz history-beginning-search-menu zle -N ...
2
votes
1answer
777 views

Python virtualenvwrapper and ZSH prompt

I am using archlinux with zsh and python simha@gauranga ~ % echo $SHELL /usr/bin/zsh simha@gauranga ~ % python3 --version Python 3.5.1 my .zshrc is export WORKON_HOME=~/.virtualenvs source /usr/...