points/.README.md
2024-05-06 15:56:45 +02:00

423 lines
9.8 KiB
Markdown

<!-- markdownlint-disable line-length no-inline-html no-duplicate-heading -->
# Installation Tips
Recommended installation order:
- [Debian packages](#debian)
- [dotfiles](#dotfiles)
- [System Config](#syscfg)
- [Qubes proxy scripts](#qubes)
- [ASDF](#asdf) & plugins
- [Newer Debian packages](#versions_check)
- [Fonts](#fonts)
- [kitty](#kitty) — `st`?
- [lazygit](#lazygit)
- [nnn](#nnn)
- [neovim](#neovim)
- Install into `/etc/skel` (see dotfiles)
## Generic Tips
### Desktop Files
See <https://specifications.freedesktop.org/desktop-entry-spec/latest/>
### GIT 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 <target-folder> <remote-name> <branch> --squash
- Note 1: Must be called from $HOME
- Note 2: Do not start <target-folder> with $HOME or ~
### Github Patches
From [stackoverflow](https://stackoverflow.com/questions/28484186/apply-github-commit-pull-request-as-a-patch).
```sh
wget https://github.com/jesseduffield/lazygit/pull/2604.patch
git apply --stat --apply 2604.patch
```
### Qubes Internet Access
- In _Basic_, connect to `sys-firewall`;
- In _Firewall rules_:
- check _Limit outgoing connections_;
- check _Allow full access for 25 minutes_.
## Debian Packages {#debian}
```sh
apt install --no-install-recommends \
aptitude \
curl fd-find fzf git grc ripgrep \
vim-nox vim-tiny- wget xdg-utils \
dpkg-divert --rename --divert /usr/bin/fd /usr/bin/fdfind
dpkg-divert --rename --divert /usr/share/man/man1/fd.1.gz \
/usr/share/man/man1/fdfind.1.gz
dpkg-divert --rename --divert /usr/share/zsh/vendor-completions/_rg \
/usr/share/zsh/vendor-completions/rg.zsh
# Installed by kicksecure
dpkg-divert --rename --divert /usr/share/zsh-autosuggestions/disabled \
/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
```
## dotfiles — Bare Git Repository {#dotfiles}
- <https://www.atlassian.com/git/tutorials/dotfiles>
- StreakyCobra
### Starting from scratch
```sh
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:
```sh
git clone --bare <git-repo-url> $HOME/.dotfiles
export ALL_PROXY=127.0.0.1:8082
git clone --bare https://forge.chapril.org/michel_ouba/points.git $HOME/.dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
BRANCH=main
BKDIR=".dotfiles-backup/";
dotfiles checkout ${BRANCH} 2>&1 | egrep "\s+" | awk {'print $1'} |
xargs -I{} sh -c "mkdir -p \$(dirname ${BKDIR}{}); mv -iv {} ${BKDIR}{}";
dotfiles checkout ${BRANCH}
for file in ${BKDIR%/}/*(D); {
ls -lh ${file} ./${file#${BKDIR}}; read;
vimdiff ${file} ./${file#${BKDIR}} }
```
When the `fetch` configuration is not set, insert the following line in the
_remote_ section of `.dotfiles/config`:
```config
fetch = +refs/heads/*:refs/remotes/origin/*
```
### Install into `/etc/skel`
```sh
sudo mkdir -p /etc/skel/.dotfiles
sudo chown $(whoami) /etc/skel /etc/skel/.dotfiles
sudo chown $(whoami) -R /etc/skel/.config
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
```sh
lazygit --git-dir=$HOME/.dotfiles --work-tree=$HOME
```
## System Config {#syscfg}
- [SysRq](https://www.kicksecure.com/wiki/SysRq)
- `sudo cp -aiv ~/.aptitude /root`
## Qubes proxy scripts {#qubes}
```sh
chmod +x $HOME/bin/*-proxy
export ALL_PROXY=127.0.0.1:8082
source ~/.zshrc
```
TODO: Insert random part in filenames.
## ASDF & main plugins {#asdf}
`.zshrc` will install `asdf`.
Before installing/compiling Python, make sure you have the required
[system dependencies](https://github.com/pyenv/pyenv/wiki#suggested-build-environment).
```sh
sudo apt install --no-install-recommends \
build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
asdf plugin add direnv
asdf install direnv latest
asdf direnv setup --version latest
asdf global direnv latest
asdf plugin add python
for Plugin in $(asdf plugin list); { echo $Plugin; asdf list $Plugin }
```
## Newer Debian packages {#versions_check}
```sh
cd ~/bin
asdf current
asdf local direnv latest
asdf install
direnv allow
python -m pip install -r requirements.txt
cd ~/Downloads
versions_check
wget-proxy https://...
dpkg -i *.deb
```
## Fonts {#fonts}
- [JetBrains Mono](https://www.jetbrains.com/lp/mono/)
- Choose files **without** “NL” (No Ligatures) in their names
- [Nerd Fonts](https://www.nerdfonts.com/)
- [Download](https://github.com/ryanoasis/nerd-fonts/tags)
- JetBrainsMono.tar.xz
- NerdFontsSymbolsOnly.tar.xz
- [Cheat Sheet](https://www.nerdfonts.com/cheat-sheet)
- <https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/bin/scripts/test-fonts.sh>
### in $HOME/.fonts
```sh
mv folder ~/.fonts
fc-cache -fv ~/.fonts
```
See also [How to install and manage fonts on Linux](https://linuxconfig.org/how-to-install-and-manage-fonts-on-linux).
### in /opt/fonts
`/etc/fonts/conf.d/00-opt.conf`:
```xml
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/opt/fonts</dir>
</fontconfig>
```
```sh
sudo mkdir -p /opt/fonts
sudo mv folder /opt/fonts
sudo chown root:root -R /opt/fonts
fc-cache -fv /opt/fonts
```
## kitty {#kitty}
- <https://sw.kovidgoyal.net/kitty/binary/>
### Dependencies
- `JetBrains Mono` (without NL)
- `NerdFontsSymbolsOnly`
- Note: outside of kitty, it may be interesting to also install
_JetBrains Mono_ **with** _NL_.
- terminfo
```sh
sudo apt install kitty-terminfo
# OR:
wget 'https://salsa.debian.org/debian/kitty/-/raw/debian/sid/terminfo/x/xterm-kitty
```
### Install
```sh
# Show installed version, debian package & changelog
(ls =kitty;
kitty --version;
apt show kitty;
curl https://sw.kovidgoyal.net/kitty/changelog/ | html2text) | less
# Debian package
sudo apt install kitty
# In $HOME
sh ~/.config/kitty/installer.sh
# In /opt/kitty.app
sudo sh ~/.config/kitty/installer.sh launch=n dest=/opt
sudo update-alternatives \
--install /usr/bin/x-terminal-emulator \
x-terminal-emulator /opt/kitty.app/bin/kitty 99
```
**Note**:
Kitty prepends its _bin_ folder to the path.
So it is more coherent/simpler to copy this behaviour into Zsh.
## lazygit {#lazygit}
### Dependencies
- git-delta
- go language (when compiling)
```sh
# debian testing & unstable:
apt install git-delta
```
### From Source
```sh
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
```sh
mkdir -p /opt/lazygit/bin
cd /opt/lazygit/bin
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
```sh
go install github.com/jesseduffield/lazygit@latest
export GOPATH=/opt/go && sudo mkdir -p $GOPATH
sudo -E go install github.com/jesseduffield/lazygit@latest
```
Problem: Commit ID, build date and version aren't set.
```sh
$ lazygit --version
commit=, build date=, build source=unknown, version=unversioned, os=linux, arch=amd64, git version=2.43.0
```
## neovim {#neovim}
### Dependencies
- kitty / NerdFont
- libfuse2
- xsel
### Binary Nightly Release
```sh
mkdir -p $HOME/.local/bin
cd $HOME/.local/bin
# ---
mkdir -p /opt/neovim/bin
cd /opt/neovim/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
```sh
flatpak install flathub io.neovim.nvim
```
## nnn — n³ {#nnn}
### Dependencies
- kitty / NerdFont
- Archives Management:
- bsdtar (`libarchive-tools`) supports _Zstd_
- [fuse-archive](https://github.com/google/fuse-archive)
- `atool`: last release is from 2012
- <https://github.com/solsticedhiver/atool2>
- <https://github.com/wummel/patool>
- Drag&Drop: <https://github.com/mwh/dragon>
- Trash:
- `trash-cli` is a much better CLI-only solution!
Compare the outputs of `trash-cli` and `gio trash --list`
<https://github.com/andreafrancia/trash-cli>
- For `gio trash`, packages `libglib2.0` & `gvfs` are recommended.
### From source
```sh
# 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 make PREFIX=/opt/nnn 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
```