Divergent
Pages

Set Up Linux System with Useful Tools

[!info] The Linux distro I have been fiddling to use is Fedora.

Install zsh

sudo dnf install zsh

Change default shell

chsh -s $(which zsh)

One might need to reboot for the change to take effect. Make sure the path from which zsh is included in /etc/shells.

Install bat

sudo dnf install bat

One can combine bat with git diff to view lines around code changes with proper syntax highlighting. Add the following function to .zshrc file:

batdiff() {
    git diff --name-only --relative --diff-filter=d | xargs bat --diff
}

Install Eza

[!note] As of Fedora 42, eza is no longer available in the official Fedora repositories due to the absence of an active maintainer.

I ended up installing Eza with homebrew.

Install fzf

sudo dnf install fzf

Set up fzf key bindings and fuzzy completion

Add the following line to shell configuration file.

source <(fzf --zsh)

Set up preview for fzf with bat

#  [IMPORTANT] If using the same name as the original command,
#  make sure to use the command path when referenced,
#  instead of just the name to avoid recursive loop.
fzf() {
  /usr/sbin/fzf --style full --preview 'bat --color=always {}' --preview-window '~3'
}

Install Zoxide

curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

Add this to the end of your config file (usually ~/.zshrc):

eval "$(zoxide init zsh)"

For completions to work, the above line must be added after compinit is called. You may have to rebuild your completions cache by running rm ~/.zcompdump*; compinit.

Install Homebrew

Install requirements/dependencies for Brew

sudo dnf group install development-tools
sudo dnf install procps-ng curl file git

Install Homebrew with the official script

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Run these commands in your terminal to add Homebrew to your PATH:

echo >> /home/caijq/.zshrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/caijq/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Install Starship

As of time of writing, installing Starship via dnf does not seem to be available. To install Starship on Fedora, one can use the Copr repository.

First, enable the Copr repository for Starship by running:

sudo dnf copr enable atim/starship

Then, install Starship with:

sudo dnf install starship

Finally, add the following line to .zshrc file and set up configuration file typically located at ~/.config/starship.toml.

eval "$(starship init zsh)"

On this page