A script to "Modernize" your Linux CLI
Use this script to install modern CLI tools for Linux
Published: 13 Oct, 2024
Tools like grep, find, and cat have been replaced by newer tools, most of which are written in Rust. These newer tools perform better while also being more user friendly. It makes sense to stop using the old tools and switch over.
Your distribution will have those tools packaged but they’ll usually be outdated unless you’re using a rolling release distro like Arch Linux. I use Ubuntu which tends to be outdated. I decided to write my own tool to download and install these tools so that I always have the latest versions.
The script is written in Fish shell syntax because it’s my default shell. Take a look:
#!/usr/bin/fish
set DEST_DIR $HOME/.local/bin
function latest_tag
set repo $argv[1]
set tag (curl -L "https://api.github.com/repos/$repo/releases/latest" 2>/dev/null | jq '.tag_name' | cut -d '"' -f 2)
echo $tag
end
function download
set repo $argv[1]
set tag (latest_tag "$repo")
set dest $argv[2]
set filename $argv[3]
set download_url "https://github.com/$repo/releases/download/$tag/$filename"
curl -L -o $dest $download_url 2>/dev/null
end
function neovim
set dest "$DEST_DIR/nvim"
download neovim/neovim $dest "nvim.appimage"
set chmod +x $dest
end
function ripgrep
set dest "/tmp/ripgrep.deb"
set repo BurntSushi/ripgrep
set tag (latest_tag "$repo")
set filename ripgrep_$tag-1_amd64.deb
download $repo $dest $filename
sudo dpkg -i $dest
end
function fd
set dest "/tmp/fd.deb"
set repo sharkdp/fd
set tag (latest_tag "$repo" | cut -d "v" -f 2)
set filename fd_"$tag"_amd64.deb
echo $filename
download $repo $dest $filename
sudo dpkg -i $dest
end
function zoxide
set dest "/tmp/zoxide.deb"
set repo ajeetdsouza/zoxide
set tag (latest_tag "$repo" | cut -d "v" -f 2)
set filename zoxide_"$tag"-1_amd64.deb
download $repo $dest $filename
sudo dpkg -i $dest
end
function bat
set dest "/tmp/bat.deb"
set repo sharkdp/bat
set tag (latest_tag "$repo" | cut -d "v" -f 2)
set filename bat_"$tag"_amd64.deb
download $repo $dest $filename
sudo dpkg -i $dest
end
neovim
ripgrep
fd
zoxide
bat
This script will download binaries to $HOME/.local/bin or install the debian package if available. It currently installs everything at once but I’m thinking of adding arguments to allow installing/updating each tool separately. You can run this script any number of times to fetch and install the latest version of the tools.