From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1184 invoked from network); 11 Feb 2023 09:20:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2023 09:20:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1676107201; b=gxH3nvqHzXM2/a6zhxUuHG/0I0aiWXWddUjGD/+l5LEYwP7F7Etmo1k+A1EE7rhWSumByTow/1 gSUB4At8uviUK1mB+QNVNG2U0vm+mo6rrd7y3/qHzQpRTumSzr9UaDLdLTNqyHrm3POegO1riT esUZOqHJaOVlopSUt5lv5e8U/KGDPVqvmdLiME+bfHWE1bZ8DvUrvRIDI7QTdEgJB82MN8PkmH XhIBkImXf/ciS59L30Sy/fbCCikWonnuDEDgzA0GWmXGZXi1E4PnSQ9lJtDSUEb1rRcseFCHSn cVsR896TilGL/U29BeMj50cBpHjsCEUdxVS3Tm30fQ5+7g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f42.google.com) smtp.remote-ip=209.85.167.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1676107201; bh=uFDBUaJENk4xkbBLWqhoBNqPZsvvw/r3Yv0d34gq/PA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=pGdwKbbjKvorYGGwFyYRU3ITZqmGp1IgaIRMpRm0XWidxd5MGwctoR24S0NAvlbDRu1qFK/eeB 0IRU1RwGIbyEr/zyuc4fNUQFIDOfYeLP/Jq20L9MIElOXB0EmXyxY+SVzDt8TMuI6o4Hbh2Qwp tGFoHn3cuFjtnX+PcRXBrahyt7Adx3A4hagJJIm2GgPfhz3WmS26tkxy3DCmHxAN9NlMU+8w4S nh3Kw9XMTNClS9ur56APBJVKXR0qnk0pG93OS8ZyLshjbiTY8v1tVoVsvGFFgee1f76HdqBJ+d MDTMbxfks6Gci7Y3JeeVpqzqoIk0DjM10Vdm6r4sfcxYvA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=w5HBCQWwYB9LEcqzd8pwqzOaVI/BmrgTnCJc9rfkSvo=; b=NUleIv7CJM3875MmMY78AqsBwf m1aMrJFajpJxtNHUqqEkWtz1GYr2IP3L3JageWxXlE0tJWUFlZkV/ENEG3VTOH9L/jUOqg1v9XDpm uc6Tdg92lp9LZclYFvg2zQINTCV8MrS7qRQC3scCWvf8j/JEO0QloxKIqmpjuHf5EDPtuUibWGbEt RqTDqrjawfqaAo3FTrzQ6UyaVcTcYH7fekCq0L/13nAMWImLqW090nfc4VC+mbHhzfMXM8VmJsm/v E0+BA4gJW027DGN2OdyyXh3BmjHcBnEVp39qtkw/GIaMIEe3hUcU6S6gRw5ss3nLtxOlmkkK4L5Pp bCEDEIEQ==; Received: by zero.zsh.org with local id 1pQm36-000LOI-Df; Sat, 11 Feb 2023 09:20:00 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f42.google.com) smtp.remote-ip=209.85.167.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f42.google.com ([209.85.167.42]:33680) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pQm2O-000KfX-UG; Sat, 11 Feb 2023 09:19:17 +0000 Received: by mail-lf1-f42.google.com with SMTP id d34so7762626lfv.0 for ; Sat, 11 Feb 2023 01:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=w5HBCQWwYB9LEcqzd8pwqzOaVI/BmrgTnCJc9rfkSvo=; b=P13x8vd1A6A0QvmXuXoBPcvaF1WD0p3Z+RJDyslqHNaDPVODd3fjb2OHm1v+KjTfKP 87VNitGzFu7eEpAs9En7dciJNjSIW5ZBPHPVYbMXiiAp82A2S84wkCZqIIvrBNXNScu9 YkPHNGx8KvQWYMUZ2gek5Ocp/KDzcNgLt/EMFBSuIRTwcYJwIMPPrB2visy1IEemsWin /8dhGQhzTMnd2BT3DY+QbJmQGNW6MSSmSCd/jQEXb4bPcAJQBjtRtMY2M0/8+0jTotFn zkvEpUr4soWvTXHQ/CeiJnT3Qe+eLuOOQfM+G2PxodEr77Gm7+zLULxrwCe/gw+UPyAt MmZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w5HBCQWwYB9LEcqzd8pwqzOaVI/BmrgTnCJc9rfkSvo=; b=vpoZu6HE39TmWam++NcWdK5VRzDX6ObvswR97GYJrM/c1eu6ZRY1GxVniCVc9UXtUA yob2FCdp/43a0SI28p0tMRzs16qdOxExmk/1qBygeyr9yBY+i8p4cfTOBkp9/z4v1h8z IQjnaULuJXc186MqHDcBsW/az1JG5MyP6rvm4GxFTddKMHRtst7Xx9VEEfxkpgBteuDC vq1XxEt8B/+ifTv8neQQMaQxcZnz7ucWGJ97OgZNfzOvhOxApGRi2U4IdmUJRcgTZxVR u0Y/AV9NsCzOav9CwmizGReURlQ4FqbUD+5a2x6IfC2Vs0KaK0+doA27ZEpN/Ks1Aph2 g9QA== X-Gm-Message-State: AO0yUKUIe5Fp1ADBfmSfqCt5GvHuzZIUZ0abMXjttZcnhfDi7PSvP+1p 4M9+8/Pzcb4vmEdWaZQt5zrl8qP4OY0RugTCJk0= X-Google-Smtp-Source: AK7set/Wm143AnYMn8kdnADM3Bpa477PxHCSdaiMJyU2ktfW/H7gEw4GRD7qb6Fmu7DTysOs/CKIDEuaezEu7fWAr8c= X-Received: by 2002:a05:6512:931:b0:4d8:8ad1:a05c with SMTP id f17-20020a056512093100b004d88ad1a05cmr2520324lft.140.1676107155838; Sat, 11 Feb 2023 01:19:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Sat, 11 Feb 2023 10:19:03 +0100 Message-ID: Subject: Re: Prompt user for single file with bells and whistles To: OG Code Poet Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 28911 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Fri, Feb 10, 2023 at 10:37 PM OG Code Poet wrote: > > 1. Highlight: current menu selection item should be highlighted with reverse-video. > 2. Order: the possible file completions should be shown below the prompt. > 3. Prompt stepping: Prompt shouldn't step below after printing possible options above. This is related to 2. > 4. Only one: Tab complete only first item, as we are asking for only 1 file name from user, not multiple. (This is what I mean by "functionally correct") > 5. Size: If there are more possible completions than can fit below the prompt, that case is handled elegantly. Assume alternate screen, and no screen movement or scrolling available. > 6. Bonus: If you could think of yet another nice feature to have for a single file selector, feel free to add. Though it would be nice to have it in a separate listing or with comments to identify how to remove your that from solution for 1-5 above. > > Note: The answer would be self-contained zsh code. It wouldn't ask user to edit .zshrc or install some zsh extension/plugin/framework/library. How about this? #!/usr/bin/env -S zsh -fi zstyle ':completion:*' completer _files zstyle ':completion:*' menu yes select autoload -Uz compinit compinit vared -p "Select file: " -c file print -r -- "You selected: ${(q-)file}" Roman.