Skip Navigation

Search

Linux @lemmy.ml
thingsiplay @beehaw.org

fzn: output selected line number with fzf instead text

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.

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

  

Usage:

 bash
    
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.

Linux @lemmy.ml
Psyhackological @lemmy.ml

How have you automated configuring your machines in terms of packages and dotfiles so it works cross-distro?

I'm looking for interesting tools to automate managing packaging and configuring everything automated.

And yeah I know about NixOS but I like to distro hop and experiment so I for now know these:

  • Ansible - automating many machines, using different package names as vars and package managers.
  • Bash - the most native and compatible scripting language that can be.
  • Chezmoi - for dotfiles.

For now that's it. I'm looking forward for your suggestions!

Linux @lemmy.ml
thingsiplay @beehaw.org

unwrap: Wrapper to marry GNU Parallel and 7-Zip for archive extraction

It uses 7z to extract files from archives. By also utilizing GNU Parallel, multiple files can be processed at the same time.

The purpose is to streamline option handling and usability of both programs into a unified command line interface, by only incorporating functionality which I need. 7z's option and argument handling is a bit confusing and does things in unique and unfamiliar ways. On the other side, we have Parallel, which is extremely complex and has ton of functionality; also confusing. So I picked up my favorite options and bundled them into a manageable script.

Name of the script is inspired by unwrap() functionality from Rust programming language. It unpacks certain type of variables to make use what is inside of it.

7z (probably in package p7zip) and parallel are required and need to be present.

 bash
    
git clone https://github.com/thingsiplay/unwrap
cd unwrap
chmod +x unwrap

  

usage:

 bash
    
unwrap *.zip

unwrap -f -i '*.txt' -o . *.zip