fish-shell / fish-shell/fish-shell

pushd completions include file names from the current directory

Open
#12,373 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
34.2k
Forks
2.4k
Avg merge
2d 8h
Merged PRs (30d)
13

Description

fish version: 4.3.2
OS: Fedora 43
I've tried this without third-party customizations.

## Expected behavior
Since pushd is used to navigate the directory stack and change directories (similar to cd), completion should only suggest directory names and the directory stack (e.g., +1, -0). Regular files should be filtered out of the completion suggestions to reduce noise.

## Actual behavior
When typing `pushd `, fish suggests all files and directories in the current working directory. Regular files are included even though they are not valid arguments for the command.

## Steps to reproduce
1. Create a dummy file: `touch should_not_appear.txt`
1. Type `pushd ` and press ``.
1. The file `should_not_appear.txt` is listed as a suggestion.

## Workaround
I've created `~/.config/fish/completions/pushd.fish` with the following content as a workaround.
```fish
complete -c pushd -e
source /usr/share/fish/completions/pushd.fish

# Don't suggest files in $PWD, only directories
complete -c pushd -f
complete -c pushd -a '(__fish_complete_directories (commandline -ct))'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.