Questions tagged [zsh-completion]

Questions about command completion in the zsh Unix shell.

Questions about command completion in the Unix shell.

Resources

243 questions
4
votes
1 answer

ZSH completion from script prompt (like BASH's read -e)

In a bash shell script you can prompt the user for input and enable readline completion for the user with the -e flag. (e.g. read -e -p 'GET YOUR FILE: ' file would allow a the user to use tab-completion to find the file.) ZSH's completion is more…
brent
  • 1,709
  • 2
  • 13
  • 15
3
votes
1 answer

zsh completion: use paths from specific dir, not the current one

I have a custom function and zsh gives me default tab completion for it. It completes paths from current working directory. That's great, but I'd like the completion (only for this particular function) to behave a little bit differently: as if I was…
Maciej Konieczny
  • 285
  • 3
  • 11
3
votes
1 answer

macOS zsh completion for subcommands

I have a script called , that takes a finite set of subcommands. Let's say this set is (foo bar qux). So the following are the acceptable CLI invocations this script: , foo , bar , qux (Each of the above may take further optional arguments to the…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
3
votes
1 answer

zsh: Complete `command1` the same as `command2 ARG`

Given two commands: command1 - which has completions already set up for it commmand2- which is a wrapper function, that in the end calls command1 ARG How do I make command2 complete in the same manner as command1 ARG1 would without writing a…
pschmitt
  • 93
  • 1
  • 6
3
votes
1 answer

Which keybind for smart-searching in history with ZSH?

When using the up and down arrow in my terminal (iTerm 2 on Mac OS Catalina), I can browse through my last commands using the up and down arrows. I use ZSH (Oh-my-zsh to be precise) and if I type e.g. vim then press up, it will browse my history for…
Fizk
  • 1,015
  • 1
  • 7
  • 19
3
votes
1 answer

compadd failure during optparse-applicative zsh completion script

So I'm not exactly sure whether this is something wrong with optparse-applicative's script or if I'm using it wrong. In the optparse-applicative readme, it states that programs are made available with automatic completion scripts, with options for…
Anrothan
  • 500
  • 5
  • 13
3
votes
1 answer

zsh completion complete literal quotes

I am writing my own completions for a program. I would like to be able to complete quoted words, maintaining the double or single quotes in the completion. #compdef foo _foo { local strings strings=(\ foo\ bar\ …
3
votes
1 answer

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 right in the completion menu by pressing the…
Iskustvo
  • 335
  • 1
  • 13
3
votes
1 answer

ZSH Completion based on previous flag

I am trying to create a completion where one of my completions will be dynamically generated depending on the values of the other flags. For example local state _arguments \ '-f[fabric]:fabric:->fabrics' \ '-c[containers/application where log…
diablo1234
  • 379
  • 2
  • 3
  • 10
3
votes
1 answer

Zsh completion need to hit twice

I have a command xssh that is a wrapper of the original ssh command. I need a Zsh completion for this command, and the completion rules are exactly the same as zsh. So what I add a the following to the _xssh file #compdef xssh compdef xssh=ssh I…
zijuexiansheng
  • 337
  • 3
  • 14
3
votes
1 answer

Defining ZSH completion function (compdef) for multiple commands

I have a ZSH completion script called #compdef kubens _arguments "1: :(- $(kubectl get namespaces -o=jsonpath='{range .items[*].metadata.name}{@}{"\n"}{end}'))" This provides completion to the kubens command. However if user provides a certain…
ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
3
votes
1 answer

ZSH auto completion provide full path to files in a specific folder

I'm trying to write an autocomplete function for a custom executable that takes file arguments from a particular folder. $ ./my_executable should provide the files in folder /home/me/argument_files. I got that to work with: compdef '_files -W…
Sidd
  • 1,168
  • 2
  • 10
  • 27
3
votes
1 answer

ZSH: tab complete file in subdirectory by name

I would like to be able to type a filename in zsh, hit tab, and see a list of files that match that name in any subdirectories of my current directory. Then I could tab through those results and hit enter to select a certain file, just like the…
Ben
  • 315
  • 1
  • 3
  • 14
3
votes
0 answers

Change Zsh file completion order for a specific directory

When I use Zsh file completion on my downloads directory, it would be useful if it would show the files sorted by modification time. This command will do so for all file completions: zstyle ':completion:*' file-sort modification How would I apply…
jcassee
  • 71
  • 1
  • 5
3
votes
1 answer

customizing ZSH tilde expansion

Context This concerns ZSH tilde expansion (as in bash tilde expansion). Example: ~http is expanded to /srv/http which is (roughly) the home for user http set in /etc/passwd. What I want to do I would like to configure ZSH in order to get any…
Arcturus B
  • 5,181
  • 4
  • 31
  • 51