Skip to content

My dotfiles and personal preferences.

License

Notifications You must be signed in to change notification settings

anhpt379/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3,681 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anh's dotfiles

Linter Platform

vim-startify

Installation

Clone this repo to ~/dotfiles and follow the instructions in macOS/bootstrap.sh and local/bootstrap.sh.

I'm using this lima fedora42 image at the moment.

limactl start --name=fedora42 --yes macOS/lima/fedora42.yaml
limactl shell fedora42
sudo dnf install -y git
cd ~
git clone https://github.com/anhpt379/dotfiles.git
bash -x dotfiles/local/bootstrap.sh

# On the old VM:
mkdir /Users/$USER/data/fedora41
cd /Users/$USER/data/fedora41
mkdir -p .local/share/fish/ && cp ~/.local/share/fish/fish_history .local/share/fish/
mkdir -p .local/share/zoxide/ && cp ~/.local/share/zoxide/db.zo .local/share/zoxide/
mkdir -p .ssh/ && cp ~/.ssh/id_ed25519 .ssh/
mkdir -p .ssh/conf.d/ && cp ~/.ssh/conf.d/work.conf .ssh/conf.d/
mkdir -p .gnupg/ && cp -r ~/.gnupg/ .gnupg/
mkdir -p notes && cp -r ~/notes notes
mkdir -p data && cp -r ~/data data
tar cf code.tar ~/code

# Then, on macOS:
limactl copy -r ~/data/fedora41/ fedora42:~/

# Then, on the new VM:
cd
tar xf code.tar --strip-components=2
rm -f code.tar

Note: if switching to a new machine, it's better to compress ~/data & transfer it manually to the new machine using python3 -m http.server.

The setup

overview

Key concepts:

  • macOS is in charge of handling clipboard, notifications and GUI-based applications (Chrome, Slack, Kitty, etc.).
  • the linux VM is in charge of text-based applications (fish, nvim, git, etc.).
  • ssh port forwards (port 2224 → 2227) are being used to make open, noti, pbcopy and pbpaste commands work within the VM.

Why using a VM?

  • it's easier to reproduce the setup.
  • git & docker are much (10x) faster.

Why not using docker (with Docker Desktop for Mac)?

  • slow storage performance (git status on a docker volume was 8x slower than in a VM).

Why not using native macOS?

  • git & docker operations are slow (git status on a relatively large repo takes 450ms, vs 50ms in a VM).

Keyboard layout

  • tab is escape
  • right command and right option are backspace and delete.
  • : and ; are swapped.

keyboard

Key mappings

macOS

  • <Control>-<CapsLock>-m Clipboard History (Maccy)
  • <Command>-<CapsLock>-n Next Window (Karabiner)
  • <Command>-<CapsLock>-p Previous Window (Karabiner)
  • <Command>-<CapsLock>-<Up> Maximize (Rectangle)
  • <Command>-<CapsLock>-<Down> Almost Maximize (Rectangle)
  • <Command>-<CapsLock>-<Left> First Three Fourths (Rectangle)
  • <Command>-<CapsLock>-<Right> Last Fourth (Rectangle)

Browser

  • <Command>-t new tab
  • <Command>-w close tab
  • <Command>-n next tab (MRU Tab Switcher - Normal switch forward)
  • <Command>-p previous tab (MRU Tab Switcher - Normal switch backward)
  • <Command>-] move current tab down
  • <Command>-[ move current tab up
  • <Command>-o focus on the address bar
  • <Command>-u undo close tab
  • <Command>-<Shift>-u history
  • <Command>-y copy url
  • <Command>-f accept suggestion & go
  • <Command>-` switch to previous tab (MRU Tab Switcher - Quick switch)
  • <Command>-<Shift>-t search tabs
  • <Command>-<Shift>-n next tab
  • <Command>-<Shift>-p previous tab

Tmux (local)

  • <Command>-t new tab
  • <Command>-w close tab
  • <Command>-n next tab
  • <Command>-p previous tab
  • <Command>-] move current tab to the right
  • <Command>-[ move current tab to the left
  • <Command>-r reload config
  • <Command>-s open a split
  • <Command>-) next split
  • <Command>-( previous split
  • <Command>-' resize split
  • <Command>-<Shift>-t new window

Tmux (remote)

  • <Option>-t new tab
  • <Option>-w close tab
  • <Option>-n next tab
  • <Option>-p previous tab
  • <Option>-] move current tab to the right
  • <Option>-[ move current tab to the left
  • <Option>-r reload config
  • <Option>-s open a split
  • <Option>-) next split
  • <Option>-) previous split
  • <Option>-' resize split

Fish

  • <C-f> accept suggestion and execute
  • <C-v> edit the current command in vim
  • <C-r> fzf history
  • <Tab> fzf find

Vim

  • q close buffer
  • Q close all buffers
  • <Space>-s startify
  • <Space>-f fzf files (MRU)
  • <Space>-l lf
    • <Tab> select
    • x cut
    • y copy
    • d delete
    • p paste
    • r rename
  • <Space>-g ripgrep all files
  • <C-n> next buffer
  • <C-p> previous buffer
  • gs git status
    • a/Va stage/unstage
    • x/Vx discard changes
    • d show diff
    • r rebase
    • m open merge request link
    • p git push --force-with-lease
    • P git push --force
    • C commit
    • ca commit amend edit
    • ce commit amend no edit
    • ga git absorb
    • rr rebase continue
    • ra rebase abort
  • gb git branches
  • g[ git pull --rebase origin master
  • g] git push origin HEAD --force-with-lease
  • gl git log
  • gL git log current buffer
  • m git log current line
  • gp open github/gitlab pipelines in browser
  • go open link to file on GitLab/GitHub
  • gO copy link to file on GitLab/GitHub
  • gm create/open MR
  • gw write buffer to disk
  • M switch to branch master

Vim HJKL everywhere with Karabiner

When pressed together with Command, Option or CapsLock, HJKL will become arrow keys (Left/Down/Up/Right):

  • Command + H/J/K/L will perform character-level cursor movements.

    • Hold down an additional Shift key to select text.
  • Option + H/J/K/L will perform word-level cursor movements.

    • Hold down an additional Shift key to select text.
  • Control + H/J/K/L will perform page-level cursor movements.

    • Hold down an additional Shift key to select text.
  • CapsLock + N/P to go down and up.