webcodr

Find things even faster with srchr

Inspired by my last post about rgp and fdp I got the idea to combine both into a more powerful and easier tool called srchr.

It’s a TUI written in Rust and uses similar or the same libraries as rg, fd, fzf and bat, but in one package. There are no external dependencies and it comes for macOS, Linux and Windows in aarch64 and x86-64.

Currently srchr is not available via package managers, but there’s an installation script:

curl -fsSL https://raw.githubusercontent.com/webcodr/srchr/main/install.sh | sh

I will also publish srchr on Homebrew, the AUR and perhaps some other package managers.

Beware, it’s still under development and the UI is functional, but not finished yet. At the moment there is just a hardcoded Tokyp Night inspired color theme, but this will also change in the near future.

srchr on GitHub

Update

It’s now available on Homebrew for macOS and Linux!

brew install webcodr/tap/srchr

Using fd, rg, fzf and bat to find things fast

Modern terminal programs like fd or rg make it really easy to find stuff, but there’s still room for improvement. In this post I will show you how to use fish to write to small functions with fd, rg, fzf and bat to search for file names and file content with an interactive list and even a preview in the terminal.

I don’t know that stuff?

First things first. If you already know fd or the other tools from above, feel free to skip this section.

  • fd is a more user-friendly replacement for find
  • rg or ripgrep is grep an steroids, respecting git ignore files and skips binaries or hidden files
  • fzf is a command-line fuzzy finder. You basically can pipe everything into fzf and just type to filter the output
  • bat is a modern version of cat with syntax highlighting and git integration

Say hi to rgp and fdp

function rgp
    set -l search_term $argv[1]

    if test -z "$search_term"
        echo "Usage: rgp <search_term>"

        return 1
    end

    rg -l $search_term | fzf --preview 'bat --color always {}' --bind 'enter:become("$EDITOR" {+})'
end

function fdp
    set -l search_term $argv[1]

    if test -z "$search_term"
        echo "Usage: fdp <search_term>"

        return 1
    end

    fd -tf $search_term | fzf --preview 'bat --color always {}' --bind 'enter:become("$EDITOR" {+})'
end

That’s all you need. Put them into your fish config file or the fish functions folder.

Usage

rgp something – this will use rg to search recursively search the current directory for files with something inside. The result is piped into fzf. You know can filter the result further with fzf or select a file with the arrow keys and bat will give you a live preview of the file with syntax highlighting. Pressing enter will open the selected file with your default editor (environment variable EDITOR).

fdp works similar, but looks for file names instead of the file content and also pipes the result to fzf for further filtering, preview or opening the selected file.

Don’t like fish? Here’s a version that works with bsh or zsh.

Note: the local keyword is not POSIX-compliant. If you need that, just remove it, but this makes search_term global, so use with care.

rgp() {
    local search_term=$1

    if [ -z "$search_term" ]; then
        echo "Usage: rgp <search_term>"
        
        return 1
    fi

    rg -l "$search_term" | fzf --preview 'bat --color always {}' --bind 'enter:become("$EDITOR" {+})'
}

fdp() {
    local search_term=$1

    if [ -z "$search_term" ]; then
        echo "Usage: fdp <search_term>"
        
        return 1
    fi

    fd -tf "$search_term" | fzf --preview 'bat --color always {}' --bind 'enter:become("$EDITOR" {+})'
}

Fix Omarchy Gaming (Vulkan)

After setting up my new notebook, I wanted to try some games on Steam. Works like a charm on my mini PC with Omarchy, but not this time. After starting a game, it takes a few seconds and nothing, the game silently crashes.

After fiddling and searching around, Proton logging etc., still no cause in sight. Then I tried Doom 2016 and it worked! But why? Doom starts with an OpenGL renderer, after switching to Vulkan it behaves like the other games. So there’s something wrong with Vulkan?

Vulkan Tools (Arch package vulkan-tools) to the rescue! After running vulkaninfo it became pretty clear that something important was missing: the Radeon Vulkan driver. No driver, no Vulkan. No Vulkan, no Proton …

Thankfully it’s easy to fix, just install the missing packages:

sudo pacman -S vulkan-radeon mesa mesa-vdpau lib32-vulkan-radeon lib32-mesa

It should work immediately after the installation. There’s already a GitHub issue with a pull request to solve this, but it’s open for a weeks now and it’s not clear, when the fix will be merged and released.

I don’t know why it’s no problem with my other PC, but I have installed Omarchy the old way on this machine (Arch Install and the Omarchy setup script). My best guess is that the bug was introduced with Omarchy’s ISO setup.

How does it run?

Well, that Ryzen AI MAX+ 390 is an absolute beast. Doom 2016 runs with over 100 fps with max settings on the internal display (2880x1800) and still far beyond 60 fps in 4K on my main monitor. Just don’t use fullscreen mode, it flickers like hell (known problem of Doom 2016 with the Vulkan renderer).

The HP ZBook Ultra no gaming notebook, but it has a really powerful APU and is still a quite compact and light device on the level of a 14" MacBook Pro. I don’t want a 250 W 4 kg behemoth of a notebook.

Hyprland Trackpad Tips & Tricks

For first time in my life I bought a PC notebook. I didn’t even consider to boot in the pre-installed Windows 11 and installed Omarchy right away.

The HP ZBook has a quite good trackpad, even compared to MacBooks, but some things seemed off. No right-click with two fingers, instead it would only work in the lower right corner. And I absolutely hate tapping, I want real clicks.

Turns out, it’s not the hardware. It’s all configurable in Hyprland. In Omarchy you can find the settings in .config/hypr/input, sub-category input:touchpad.

Here are some handy options to tweak the settings:

input {
  touchpad {
    # Enable two-finger clicks for right-clicking
    clickfinger_behaviour = true

    # Disable tapping
    tap-to-click = false

    # Enable natural scrolling
    natural_scroll = true

    # Disable the trackpad while typing (accidental tapping etc.)
    disable_while_typing = true
  }
}

There is even more like tapping maps, middle button emulation etc. – you can find all options here.

More awesome CLI tools

This a follow up article to Awesome CLI tools with even more useful CLI tools.

btop

It’s top on steroids with a beautiful terminal UI. Way more information at a glance and just a joy to use.

delta

Do you often look at git diffs? Are you missing syntax highlighting? delta is here to help. Just install it, configure delta as pager for git and voila, diffs with syntax highlighting.

dog

Dog is a modern DNS lookup tool with colored output and a simple interface.

tokei

Are you a fan of statistics? Tokei can summarize file types, lines of code, comments or blank spaces of your project.

I’m currently converting a large Java project to Kotlin and tokei makes it easy to see the progress.

procs

A modern replacement for ps with colored output, keyword search, tree view and some useful helpers for networking (ports) and Docker.

lazygit

One of my favorites. Lazygit is a dead simple, yet powerful and elegant to use terminal UI for git. I’m not a fan of the git CLI and always preferred a GUI tool like Tower, but nowadays lazygit is my git client of choice. I don’t think there is better git client out there. Even many NeoVim distributions support it out-of-the-box (Lazyvim with LEADER + gg).

sd

Do you use sed? Do you like it? I don’t. sd is better, much better.