5
submitted 1 day ago* (last edited 1 day ago) by [email protected] to c/[email protected]

Regular call to fzf, but output the index number of the selected entry, instead the text itself. It's a pretty niche use case, but there was a few times in the past when I needed it. You can use options for fzf just normally too.

fzn() {
    nl | fzf --with-nth 2.. "${@}" | awk '{print $1}'
}

Usage:

find . -maxdepth 1 -type d | fzn -e -m

I always forget how to do this manually, so I made this simple function for Bash. Just copy this like an alias into your .bashrc and use it like any other command in a pipe.

no comments (yet)
sorted by: hot top new old
there doesn't seem to be anything here
this post was submitted on 18 Jun 2025
5 points (100.0% liked)

Linux

55434 readers
553 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS