shfl

GitHub Actions Workflow Status Top Language Last Commit Latest Release

shfl (short for “shuffle”) helps you easily rearrange lines in a file with simple keymaps.

demo

🤔 Motivation

I like switching my tmux sessions quickly (using tmux switch-client -t "$session", triggered via a shortcut). The session names are stored in a local file, and I map a key to a session on a specific line number. To easily change which session is assigned to which line number, I needed a tool that would start up quickly and have easy keymaps to reorder lines in a file.

💾 Installation

homebrew:

brew install dhth/tap/shfl

cargo:

cargo install --git https://github.com/dhth/shfl.git

Or get the binaries directly from a release. Read more about verifying the authenticity of released artifacts here.

⌨️ Keymaps

K                    move item one position above
Enter                move item/selection to the start of the list
j / Down             go down
k / Up               go up
[1-9]                move current item to index in list
g                    go to the start of the list
G                    go to the end of the list
w                    write to file
space / s            select/unselect item
?                    show/hide help view
Esc / q              go back/reset selection/exit

🔐 Verifying release artifacts

In case you get the shfl binary directly from a release, you may want to verify its authenticity. Checksums are applied to all released artifacts, and the resulting checksum file is signed using cosign.

Steps to verify (replace A.B.C in the cshflands listed below with the version you want):

  1. Download the following files from the release:

    - shfl_A.B.C_checksums.txt
    - shfl_A.B.C_checksums.txt.pem
    - shfl_A.B.C_checksums.txt.sig
    
  2. Verify the signature:

    cosign verify-blob shfl_A.B.C_checksums.txt \
        --certificate shfl_A.B.C_checksums.txt.pem \
        --signature shfl_A.B.C_checksums.txt.sig \
        --certificate-identity-regexp 'https://github\.com/dhth/shfl/\.github/workflows/.+' \
        --certificate-oidc-issuer "https://token.actions.githubusercontent.com"
    
  3. Download the compressed archive you want, and validate its checksum:

    curl -sSLO https://github.com/dhth/shfl/releases/download/vA.B.C/shfl_A.B.C_linux_amd64.tar.gz
    sha256sum --ignore-missing -c shfl_A.B.C_checksums.txt
    
  4. If checksum validation goes through, uncompress the archive:

    tar -xzf shfl_A.B.C_linux_amd64.tar.gz
    ./shfl
    

Acknowledgements

shfl is built using ratatui.