Questions tagged [zsh]

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

367 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
23 votes
1 answer
2k views

Zsh tab completions not working as desired for partial paths

I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with: zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:...
Resigned June 2023's user avatar
18 votes
1 answer
3k 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 ...
dosentmatter's user avatar
6 votes
1 answer
2k 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/....
mike's user avatar
  • 181
6 votes
0 answers
3k 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 ...
bdesham's user avatar
  • 1,337
4 votes
0 answers
904 views

zsh/oh-my-zsh: how to make tab completion add no trailing space for non-folder files?

I installed zsh and oh-my-zsh. By default, when using tab completion zsh adds a trailing space for non-folder files. For demonstration I created the following folders/files in a folder named ...
user3716849's user avatar
4 votes
1 answer
430 views

How to write zsh completion function for wrapper commands

I'm attempting to write a completion function for a custom wrapper around SSH called myssh. myssh takes command line arguments in either of the following forms: myssh [myssh options] [ssh args] or ...
Sora Minazuki's user avatar
4 votes
2 answers
3k views

zsh: locking failed for ~/.cache/zsh/zsh_history: file exists

I have a bind mount ~/.cache/zsh folder between multiple hosts with rw and defaults when doing mount. When I start both machine and zsh trying to lock zsh_history, it gives error zsh: locking failed ...
Tuyen Pham's user avatar
  • 1,785
4 votes
0 answers
370 views

Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS

Is there a way to make the CORRECT option aware of AUTO_CD and CDABLE_VARS? In this example, I would expect correction to not be triggered. Could this be a bug? > setopt autocd > setopt ...
cambunctious's user avatar
4 votes
0 answers
400 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 ...
Jeff Tratner's user avatar
3 votes
0 answers
103 views

Most recents files/directory suggested results by TAB completion with zsh

I would like to get with TAB suggestion on zsh to get the more recent file as first suggestion after a second TAB pushing. For the moment, I have with a first TAB pushing the list of the more recent ...
guizmo133's user avatar
3 votes
0 answers
79 views

Are there any Linux distros with a preconfigured user-friendly shell environment?

I see so many Linux distros all around, and they all come with different look & feels and their own set of pre-installed GUI tools for most standard tasks. The default shell environment, however, ...
carlfriedrich's user avatar
3 votes
2 answers
702 views

How can I save a text file with all command line inputs and outputs without saving the ANSI characters?

I am running the latest mac OS and using zshell, and having trouble writing a shell script. I do most of my work from the command line, and wanted to have a bash script automatically save and log all ...
Nicole I.'s user avatar
3 votes
0 answers
214 views

How to add the expanded version of commands involving fzf to history?

Say I would like to edit a file ./long/path/to/my/file/test.py with Vim, but I do not remember the path to the file. In this case, I would run vim `fzf` to use fuzzy search to find and edit the file. ...
Matt's user avatar
  • 171
3 votes
0 answers
121 views

Why do backgrounded commands in Zsh functions not show correctly in jobs?

In Bash 5.2, the output of jobs after either of the following is identical modulo job numbers: sleep 3 # press C-z s() { sleep 3; } s # press C-z In both, jobs produces something like [1]+ Stopped ...
D. Ben Knoble's user avatar
3 votes
0 answers
282 views

Can you please explanation why ssh hostname on zsh for macOS requires a script?

I have an M1 MacBook Pro running macOS 12.1. I'm using the default zsh shell. I've configured my /etc/hosts and my ~/.ssh/config just like I had done when macOS was using bash. When I go to ssh into ...
VanBantam's user avatar
  • 131
3 votes
1 answer
324 views

How to do smart backups of terminal history

Trying to implement smart backups of my zsh terminal history (~/.zsh_history). Same goes for bash no difference just the file is called .bash_history. So far I have decided to create a private git ...
dobro's user avatar
  • 31
3 votes
1 answer
976 views

zsh in tabby separate history for each tab

I want to keep history separated for each tab (even for split windows within one tab). I therefore found a solution to add these two lines after source $ZSH/oh-my-zsh.sh: source $ZSH/oh-my-zsh.sh ...
Arie's user avatar
  • 131
3 votes
0 answers
58 views

Scope zsh history to current file tree if a file exists

I would like to have the following behavior for zsh history: If the current directory has a .zsh_history file, then treat that file as the history If the current directory does not have a ....
Jessica's user avatar
  • 331
3 votes
1 answer
353 views

Same command sequence produces different results in command-line and script

I'm writing a utility script to help me delete Git branches in zsh. Currently, it looks like this: git for-each-ref --format="%(refname:short)" refs/heads/ | while read -r line; do ...
Omar Sharaki's user avatar
3 votes
0 answers
227 views

Zsh: Is it possible to disable history expansion inside double quotes?

Is it possible to disable history expansion inside double quotes? I do not want history expansion to be completely disabled, as I still use it, but I see no reason to expand the history inside a ...
HappyFace's user avatar
  • 1,533
3 votes
0 answers
417 views

Change zsh tab size

I wanted to change the tab size (the amount of spaces a tab uses) used in my terminal, but it didn't work. I then found out, that my shell (zsh) inserts a fixed amount of 8 spaces instead of a tab. I ...
weisbrja's user avatar
  • 131
3 votes
1 answer
951 views

Can I make shell consider NBSP a whitespace character?

This seems like a common issue: you paste a simple command from somewhere into the terminal and it's not being understood by a shell: $ echo test $ zsh: command not found: echo test The reason is ...
Eugene Yarmash's user avatar
3 votes
0 answers
167 views

zsh _arguments completion that gradually reveals options

I have at the moment a completion function that looks something like this (except way more entries) _arguments \ '-check[do a check]' \ '-play[play a specific song]:songnumber' \ '-test.n=[run ...
pseyfert's user avatar
  • 868
3 votes
1 answer
552 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 ...
user avatar
3 votes
0 answers
113 views

Is there any way to change $? from a zle widget?

I have a widget for mapping ^Z to fg: function ctrlz() { [[ $(jobs | wc -l) > 0 ]] && { zle -I fg } } However, since widgets can't change $?, the exit status of ...
Kyuuhachi's user avatar
  • 243
3 votes
1 answer
664 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 ...
Ryan Hawdon's user avatar
3 votes
1 answer
853 views

Cannot recover from sleeping tmux during SSH session

I've tried searching this on google but have been very unsuccessful so I've resorted to trying to get someone's help with this. On my local machine I do the following: $ tmux CTRL+b CTRL+z $ fg and ...
Cody's user avatar
  • 245
3 votes
1 answer
111 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" "...
user avatar
3 votes
0 answers
650 views

Can I prevent zsh slowing with a large history?

I've just migrated from bash to zsh. I converted ~/.bash_history for use in zsh. It's 150 000 lines long. bash is almost instantaneous to start up, but zsh is now fairly slow, taking half a second to ...
Sparhawk's user avatar
  • 19.8k
3 votes
0 answers
1k views

Byobu - New window with same ssh session?

Is there a way to configure Byobu to use same ssh session in a new window. For e.g. Open Byobu window ssh into a remote host Press 'F2' to open a new window. This opens the terminal with my ...
RandomQuestion's user avatar
3 votes
1 answer
529 views

Why does select-word-style stop me from using backward-kill-word for leading whitespace?

If I have just some whitespace at be beginning of my zsh prompt, I can usually ^W (backward-kill-word) it away. However, as soon as I load select-word-style - even if I don't select any special style -...
ThiefMaster's user avatar
  • 2,317
3 votes
0 answers
1k views

Powerline bash prompt not colorized in tmux

The bash/zsh commandline prompt is not displaying colors in tmux, even though I managed to get the powerline itself working (with colors). The prompt works fine in pure bash/zsh. I am getting the ...
Enuy's user avatar
  • 139
2 votes
0 answers
22 views

Prevent ZSH from saving $PREBUFFER into history after interrupt

In a continuation context ($PREBUFFER is not empty) like below: $ echo 1 \ $ Right after I type Ctrl+C to interrupt the input, ZSH will save $PREBUFFER into the history file: ... : 1676711302:0;echo ...
QuarticCat's user avatar
2 votes
0 answers
727 views

Autocomplete of diff command not working in zsh / oh-my-zsh

On MacOS I am using oh-my-zsh with no customization that I know of. Autocompletion is mostly working quite nicely and I'm very happy with it. But for some reason the diff command is different. ➜ ls ...
Tom Aldcroft's user avatar
2 votes
1 answer
140 views

zsh zpty does not work on macOS, does work on Linux?

zsh module zsh/zpty seems to work perfectly well on my Linux virtual machine running on Apple M1 macOS machine. But the same does not work on macOS (even on the same host machine). I have tried this ...
codepoet's user avatar
  • 576
2 votes
1 answer
64 views

In Linux shell, have Ctrl-W / ^W send EOF when input is empty like Ctrl-D / ^D does?

Is there any way to have ^W behave the same way as ^D with empty input in a shell? I use zsh, but this should apply to bash as well. It otherwise does nothing (if the input line is already cleared) ...
radu242's user avatar
  • 21
2 votes
0 answers
47 views

how to change prompt of zle widgets (history-incremental-backward-search)?

Is there a way to change the prompt of zle widgets such as history-incremental-backward-search? For instance I wonder if we can colorize "bck-i-search:" or change the string, or colorize the ...
jds's user avatar
  • 21
2 votes
0 answers
310 views

Replicate backward search with fzf in zsh

I've been struggling to find a simple answer to this and it seems like it is not trivial to customise the default integration of fzf/zsh (would like to understand if I'm wrong here). I am looking for ...
rbhalla's user avatar
  • 121
2 votes
0 answers
141 views

How to override builtin Completion file?

I have made some modifications in _stow completion file. I want to override /usr/share/zsh/functions/Completion/Unix/_stow with $HOME/.dotfiles/.resources/zsh-dotfiles/zsh-custom-completions/_stow I ...
Ahmad Ismail's user avatar
  • 2,560
2 votes
0 answers
323 views

How to paste selection from vi-mode to clipboard

I want to access the content of what I copied in the buffer with the vi-mode of the clipboard via the command ctrl + v or ctrl + shift + v in the terminal. I copied in my .zshrc the following: (from ...
ecjb's user avatar
  • 383
2 votes
0 answers
95 views

Prevent the line `load:... cmd:... running ...` upon SIGINFO

Issuing SIGINFO (e.g. by pressing ^T) while a terminal process is running usually results in a printout of a line load: 2.93 cmd: sleep 7826 waiting 0.00u 0.00s If I have written the tool that's ...
Bubaya's user avatar
  • 121
2 votes
0 answers
221 views

Preview Oh My Zsh completion

I would like to preview what, if anything, would be completed using oh-my-zsh suggestions. In other words, a visual indicator that pressing TAB will insert what I think it will. in different color (...
jaskij's user avatar
  • 170
2 votes
2 answers
809 views

Chsh Enterpise login

I installed Fedora 34 and did the Enterprise Login (domain user). I can't use chsh for change the user default shell to zsh because user does not exists. (It's not present in /etc/passwd because is ...
Michele Giulietti's user avatar
2 votes
0 answers
82 views

zsh: Make getting the value of a variable invoke a function

I like to use a "getter" function for some variable foo, such that using "$foo" is equivalent to "$(foo-getter)". It think this should be possible, as $EPOCHREALTIME ...
HappyFace's user avatar
  • 1,533
2 votes
1 answer
513 views

Queue multiple jobs after current one in shell

On previous questions similar to mine, the proposed solutions are all involved suspending the current foreground task with Ctrl+Z and then running fg && ... or fg ; ... (and maybe sending the ...
Philipp's user avatar
  • 21
2 votes
1 answer
843 views

wine-platform-5-staging & wine-platform-runtime not found by shell

I'm running Kubuntu 20.04 64-bit with zsh as my shell. I installed wine-platform-runtime and wine-platform-5-staging as snaps. However, zsh doesn't recognize it's installed. The following 3 commands ...
Gal Grünfeld's user avatar
2 votes
0 answers
421 views

zsh some unicode input shown as code in angle brackets in prompt line (but not output)

In my cygwin / mintty setup, when I have the unicode characters and U+1F60C (😌 relieved face) in my Windows clipboard, type echo ', paste, type ' and enter, zsh displays it as inverse video <d83d&...
EndlosSchleife's user avatar
2 votes
0 answers
402 views

User defined functions in zsh prompt

I'm trying to use a functions that returns the number of commits in a given branch in the zsh prompt. This is what I have now: setopt PROMPT_SUBST autoload -Uz vcs_info precmd() { vcs_info } zstyle ':...
noibe's user avatar
  • 387
2 votes
0 answers
2k views

How can I enable colours in ZSH for root user?

I'm trying to move from Bash to ZSH, whichc is the new default shell on Mac OS Catalina. I have some bash settings in my profile, and I'd like to translate these settings into the ZSH, including my ...
Apollo's user avatar
  • 121
2 votes
1 answer
160 views

How to fix path typos?

When typing quickly, I often mistype cd ~/myfiles as cd ~?myfiles, resulting in: zsh: no matches found: ~?myfiles Is there a way ZSH can autocorrect such mistakes?
Flux's user avatar
  • 2,770

1
2 3 4 5
8