points/.README.md
2024-02-23 15:48:08 +01:00

6.2 KiB

Bare Git Repository

Starting from scratch

git init --bare $HOME/.dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no

Install onto a new system

The checkout command is expected to fail with a message. This is because your $HOME folder might already have some stock configuration files which would be overwritten by Git. The “BKDIR” part is a rough shortcut to move all the offending files automatically to a backup folder:

git clone --bare <git-repo-url> $HOME/.dotfiles

alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

dotfiles config --local status.showUntrackedFiles no

BKDIR=".dotfiles-backup/";
dotfiles checkout 2>&1 | egrep "\s+" | awk {'print $1'} |
  xargs -I{} sh -c "mkdir -p \$(dirname ${BKDIR}{}); mv -iv {} ${BKDIR}{}";

dotfiles checkout

Install into /etc/skel

sudo mkdir -p /etc/skel/.dotfiles
sudo chown $(whoami) /etc/skel

git clone --bare $(dotfiles remote -v | head -1 | cut -f2 | cut -f1 -d' ') /etc/skel/.dotfiles

alias skelfiles='/usr/bin/git --git-dir=/etc/skel/.dotfiles --work-tree=/etc/skel'
skelfiles config --local status.showUntrackedFiles no
skelfiles checkout

Useful Commands

  • List all tracked files (from CWD):
    dotfiles ls-tree --name-only -rz main | xargs -0 $(whence lsd) -lU

Other Tools

lazygit --git-dir=$HOME/.dotfiles --work-tree=$HOME

Install remotes as subtree

  • https://www.atlassian.com/git/tutorials/git-subtree
  • Create an alias for remote repository
    • dotfiles remote add <remote-name> <URL>
  • Import remote as a single commit (squashed)
    • `dotfiles subtree add --prefix --squash
    • Note 1: Must be called from $HOME
    • Note 2: Do not start with $HOME or ~

Every-day Tools

  • debian apt
  • versions_check: bat, lsd
  • fonts
  • kitty
  • lazygit
  • nnn
  • neovim

Generic Tips

Github Patches

From stackoverflow.

wget https://github.com/jesseduffield/lazygit/pull/2604.patch
git apply --stat --apply 2604.patch

Debian Packages

apt install curl fd-find fzf grc ripgrep wget xdg-utils

dpkg-divert --divert /usr/bin/fd --rename /usr/bin/fdfind
dpkg-divert --divert /usr/share/man/man1/fd.1.gz --rename /usr/share/man/man1/fdfind.1.gz
dpkg-divert --divert /usr/share/zsh/vendor-completions/_rg --rename /usr/share/zsh/vendor-completions/rg.zsh

Fonts

kitty

sudo apt install kitty-terminfo
(kitty --version && curl https://sw.kovidgoyal.net/kitty/changelog/ | html2text) | less

sh ~/.config/kitty/installer.sh

Note: Kitty prepends its bin folder to the path. So it is more coherent/simpler to copy this behaviour into Zsh.

lazygit

Dependencies

  • git-delta
  • go language (when compiling)

From Source

mkdir -p $HOME/dev_3rd/golang
cd $HOME/dev_3rd/golang

git clone https://github.com/jesseduffield/lazygit.git
cd lazygit

path+=(/usr/lib/go-1.21/bin)
go install

Binary Releases

URI=https://api.github.com/repos/jesseduffield/lazygit
LOCATION=$(curl -s $URI/releases/latest \
  | grep "browser_download_url.*Linux_x86_64" \
  | awk '{ print $2 }' \
  | sed 's/,$//'       \
  | sed 's/"//g')
echo $LOCATION
wget $LOCATION
tar xf *.tar.gz(om[1])

From Go Package

go install github.com/jesseduffield/lazygit@latest

Problem: Commit ID, build date and version aren't set.

$ lazygit --version
commit=, build date=, build source=unknown, version=unversioned, os=linux, arch=amd64, git version=2.43.0

neovim

Dependencies

  • kitty / NerdFont
  • libfuse2
  • xsel

Binary Nightly Release

mkdir -p $HOME/.local/bin
cd $HOME/.local/bin

curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage
ln -sf nvim.appimage nvim
ln -sf nvim.appimage vi

cd $HOME
nvim --version
vi --version

flatpak

flatpak install flathub io.neovim.nvim

nnn — n³

Dependencies

From source

 # From release
URI=https://github.com/jarun/nnn
xdg-open $URI/releases/latest
ARCHIVE=$(echo $HOME/Downloads/*.gz(om[1])) && echo $ARCHIVE
tar xf $ARCHIVE

 # From repository
git clone https://github.com/jarun/nnn.git

 # Compile
cd nnn*(om[1])
make clean
sudo make O_GITSTATUS=1 O_NAMEFIRST=1 O_NERD=1 install
sudo cp -v misc/auto-completion/zsh/* /usr/local/share/zsh/site-functions
sudo chmod a+r /usr/local/share/zsh/site-functions/*

 # Plugins
mv -v ~/.config/nnn/plugins plugins_$(stat -c %Y ~/.config/nnn/plugins)
mkdir -p ~/.config/nnn
cp -av plugins ~/.config/nnn