Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option to specify header/name of the candidates list #362

Open
asok opened this issue Feb 16, 2025 · 0 comments
Open

New option to specify header/name of the candidates list #362

asok opened this issue Feb 16, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@asok
Copy link

asok commented Feb 16, 2025

Problem
I'm writing a script that will allow me to browse the filesystem and to choose file/directory. By using option --passthrough-keybindings I'm able to recursively call my script and go up or down in the filesystem tree.
It would be nice to have the current directory printed instead of "STDIN".

Feature
Add a new option to specify the header/name of the candidates list.

Examples

This is my script:

#! /bin/sh

path="${1}/"

while :
do
output=$(ls -1pha ${path}. | sed 1,2d | tv --preview "if [[ -d ${path}{0} ]] ; then ls ${path}{0} ; else bat -n --color=never --line-range=:20 ${path}{0}; fi" --passthrough-keybindings "ctrl-h,ctrl-l,ctrl-g,esc")
    results=(${output// / })

    case ${results[0]} in
        "ctrl-l")
        if [[ -d "${path}${results[1]}" ]] ;
        then path="${path}${results[1]}" ;
        else
            output=${results[1]}
            break;
        fi
        ;;
        "ctrl-h")
        path="${path}../"
        ;;
        "ctrl-g")
        exit
        ;;
        "esc")
        exit
        ;;
        *)
        output=${results[0]}
        break
        ;;
    esac
done

echo "${path}${output}"

Additional context
This is how it looks in Zed editor:

Image

If I'm not mistaked fzf heas option --header which does something similar.

@asok asok added the enhancement New feature or request label Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant