breaking: Remove setup script and use chezmoi

This commit is contained in:
js0ny 2025-09-27 02:25:06 +01:00
parent 02bbb24cac
commit 0051a163c3
190 changed files with 118 additions and 3456 deletions

View file

@ -0,0 +1,176 @@
# $DOTFILES/tools/fish/conf.d/0init.fish
# Date: 2024-12-19
# Author: js0ny
# By dictionary order, this file is sourced first in fish shell
# Define user-specific environment variables for fish
# Location:
# ~/.config/fish/conf.d/0init.fish (default location)
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
set -gx DOTFILES $HOME/.dotfiles
# XDG Base Directory Specification
set -gx XDG_CONFIG_HOME (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo $HOME/.config)
set -gx XDG_DATA_HOME (set -q XDG_DATA_HOME; and echo $XDG_DATA_HOME; or echo $HOME/.local/share)
set -gx XDG_STATE_HOME (set -q XDG_STATE_HOME; and echo $XDG_STATE_HOME; or echo $HOME/.local/state)
set -gx XDG_CACHE_HOME (set -q XDG_CACHE_HOME; and echo $XDG_CACHE_HOME; or echo $HOME/.local/cache)
if test (uname) = "Darwin"
set -gx XDG_RUNTIME_DIR $HOME/.tmp/run/
else
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
end
set -gx GHCUP_USE_XDG_DIRS 1
set -gx PAGER "less -R"
set -gx EDITOR nvim
set -gx VISUAL nvim
# Minimal PATH for early commands
for dir in /usr/local/bin /usr/bin /bin /usr/sbin /sbin "$HOME/.local/bin" /opt/share/bin
if test -d "$dir" -a ! -L "$dir"
fish_add_path "$dir"
end
end
# Homebrew/Linuxbrew
test -d /opt/homebrew/bin && fish_add_path /opt/homebrew/bin
test -d /home/linuxbrew/.linuxbrew/bin && fish_add_path /home/linuxbrew/.linuxbrew/bin
if command -v brew > /dev/null
set -gx HOMEBREW_NO_ENV_HINTS
end
# Azure CLI
if command -v az > /dev/null
set -gx AZURE_CONFIG_DIR $XDG_DATA_HOME/azure
end
# Bun JS
if command -v bun > /dev/null
set -gx BUN_INSTALL "$XDG_DATA_HOME/bun"
set -gx PATH $BUN_INSTALL/bin $PATH
end
# Rust Cargo
if command -v cargo > /dev/null
set -gx CARGO_HOME $XDG_DATA_HOME/cargo
set -gx PATH $CARGO_HOME/bin $PATH
end
# CGDB
if command -v cgdb > /dev/null
set -gx CGDB_DIR $XDG_CONFIG_HOME/cgdb
end
# .NET
if command -v dotnet > /dev/null
set -gx DOTNET_CLI_HOME $XDG_DATA_HOME/dotnet
set -gx PATH $DOTNET_CLI_HOME/.dotnet/tools $PATH
end
# Docker
if command -v docker > /dev/null
set -gx DOCKER_CONFIG $XDG_CONFIG_HOME/docker
end
# GnuPG
if command -v gpg > /dev/null
set -gx GNUPGHOME $XDG_DATA_HOME/gnupg
end
# Go
if command -v go > /dev/null
set -gx GOPATH $XDG_DATA_HOME/go
set PATH $GOPATH/bin $PATH
end
# Julia
if command -v julia > /dev/null
set -gx JULIA_DEPOT_PATH $XDG_DATA_HOME/julia
end
# Node.js
if command -v node > /dev/null
set -gx NODE_REPL_HISTORY $XDG_STATE_HOME/node/repl_history
set -gx TS_NODE_REPL_HISTORY $XDG_STATE_HOME/node/ts_repl_history
set -gx NPM_CONFIG_USERCONFIG $XDG_CONFIG_HOME/npm/npmrc
set -gx NPM_CONFIG_INIT_MODULE $XDG_CONFIG_HOME/npm/config/npm-init.js
set -gx NPM_CONFIG_CACHE $XDG_CACHE_HOME/npm
set -gx NPM_CONFIG_TMP $XDG_RUNTIME_DIR/npm
end
# Parallel
if command -v parallel > /dev/null
set -gx PARALLEL_CONFIG $XDG_CONFIG_HOME/parallel
end
# Python
# Works only with Python 3.13.0a3 and later
if command -v python3 > /dev/null
set -gx PYTHON_HISTORY $XDG_DATA_HOME/python/history
end
# GNU Screen
if command -v screen > /dev/null
set -gx SCREENRC $XDG_CONFIG_HOME/screen/screenrc
set -gx SCREENDIR $XDG_RUNTIME_DIR/screen
end
# Ruby Gem
if command -v gem > /dev/null
for dir in $HOME/.local/share/gem/ruby/*/bin
if test -d $dir
set -gx PATH $dir $PATH
end
end
set -gx PATH $HOME/.local/share/gem/ruby/3.3.0/bin $PATH
end
# Spacemacs
if command -v emacs > /dev/null
set -gx SPACEMACSDIR $XDG_CONFIG_HOME/spacemacs
end
# tldr
if command -v tldr > /dev/null
set -gx TLDR_CACHE_DIR $XDG_CACHE_HOME/tldr
end
# W3M
if command -v w3m > /dev/null
set -gx W3M_DIR $XDG_DATA_HOME/w3m
end
# Wakatime
if command -v wakatime > /dev/null
set -gx WAKATIME_HOME $XDG_CONFIG_HOME/wakatime
end
# Wget
if command -v wget > /dev/null
alias wget="wget --hsts-file=$XDG_CACHE_HOME/wget-hsts"
end
# z
if command -v z > /dev/null
set -gx _Z_DATA $XDG_DATA_HOME/z
end
if command -v tldr > /dev/null
set -gx TLDR_CACHE_DIR $XDG_CACHE_HOME/tldr
end
if status is-interactive
if command -v ipython > /dev/null
set IPYTHONDIR $XDG_CONFIG_HOME/ipython
end
end
if command -v opam > /dev/null
set OPAMROOT $XDG_DATA_HOME/opam
test -r $OPAMROOT/opam-init/init.fish && source $OPAMROOT/opam-init/init.fish > /dev/null 2> /dev/null; or true
end
# Coursier: Scala dependency manager
if command -v coursier > /dev/null
set -gx PATH "$PATH:$XDG_DATA_HOME/coursier/bin"
end
# pnpm
set -gx PNPM_HOME "$XDG_DATA_HOME/pnpm"
if not string match -q -- $PNPM_HOME $PATH
set -gx PATH "$PNPM_HOME" $PATH
end
# pnpm end
test -d /opt/miniconda3 && source /opt/miniconda3/etc/fish/conf.d/conda.fish
test -f /opt/miniconda3/etc/fish/conf.d/conda.fish && source /opt/miniconda3/etc/fish/conf.d/conda.fish
# User-specific PATH
test -d $HOME/.local/scripts && fish_add_path $HOME/.local/scripts
test -d $HOME/.local/build && fish_add_path $HOME/.local/build
source "/home/js0ny/.deno/env.fish"

View file

@ -0,0 +1,179 @@
# $DOTFILES/tools/fish/conf.d/alias.fish
# Date: 2024-12-22
# Author: js0ny
# Location:
# ~/.config/fish/conf.d/alias.fish
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
switch (uname)
case "Darwin"
# macOS Specific
#abbr --add clip pbcopy
#abbr --add paste pbpaste
alias clip="pbcopy"
alias paste="pbpaste"
# Use GNU Coreutils
alias cp=gcp
alias ln=gln
alias mkdir=gmkdir
alias mv=gmv
alias rm=grm
alias rmdir=grmdir
alias touch=gtouch
alias clip=pbcopy
alias paste=pbpaste
alias sed=gsed
abbr --add reboot "sudo reboot"
case "Linux"
# Linux Specific
#switch($XDG_SESSION_TYPE)
#case "wayland"
# Wayland Specific
alias clip="wl-copy"
alias paste="wl-paste"
#case "x11"
# # X11 Specific
# alias clip="xclip -selection clipboard"
# alias paste="xclip -selection clipboard -o"
case '*'
# Default / Fallback case
alias clip="xclip -selection clipboard"
alias paste="xclip -selection clipboard -o"
end
# Powershell equivalent
abbr --add ni touch
abbr --add cls clear
abbr --add ii open
# Editors #
abbr --add v nvim
abbr --add c code
alias svi="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc" # Prevent conflicts with svelte-cli
# Dev #
abbr --add py python3
abbr --add ipy ipython
abbr --add g lazygit
abbr --add aic "aichat -s"
# lsd - modern ls
if command -v lsd > /dev/null
alias ls='lsd'
abbr --add l 'lsd -lah'
abbr --add ll 'lsd -l'
abbr --add la 'lsd -A'
abbr --add l. 'lsd -d .*'
abbr --add tree 'ls --tree'
else
abbr --add l 'ls -lah'
abbr --add ll 'ls -l'
end
# Functions #
function mkcd
mkdir -p $argv[1] && cd $argv[1]
end
function cdls
cd $argv[1] && ls
end
function tc
touch $argv[1] && code $argv[1]
end
function tv
touch $argv[1] && nvim $argv[1]
end
# Create a new file, if the directory does not exist, create it
# Arg: a file name
function mt
mkdir -p (dirname $argv[1]) && touch $argv[1]
end
function mtv
mkdir -p (dirname $argv[1]) && touch $argv[1] && nvim $argv[1]
end
abbr --add bcat "bat --style=plain"
# Use neovide as gVim
abbr --add gvi "neovide"
if command -v brew > /dev/null
abbr --add brewi "brew install"
abbr --add brewu "brew upgrade && brew update"
abbr --add brewr "brew remove"
abbr --add brewc "brew cleanup"
abbr --add brewl "brew list"
end
if command -v pacman > /dev/null
abbr --add pac "sudo pacman"
abbr --add paci "sudo pacman -S"
abbr --add pacr "sudo pacman -R"
abbr --add pacu "sudo pacman -Syu"
abbr --add pacl "pacman -Q"
if command -v paru > /dev/null
abbr --add pacs "paru -Ss"
else if command -v yay > /dev/null
abbr --add pacs "yay -Ss"
else
abbr --add pacs "pacman -Ss"
end
end
if command -v apt > /dev/null
abbr --add apt "sudo apt"
abbr --add apti "sudo apt install"
abbr --add aptr "sudo apt remove"
abbr --add aptu "sudo apt update && sudo apt upgrade"
abbr --add apts "apt search"
abbr --add aptl "apt list --installed"
end
if command -v dnf > /dev/null
abbr --add dnf "sudo dnf"
abbr --add dnfi "sudo dnf install"
abbr --add dnfr "sudo dnf remove"
abbr --add dnfu "sudo dnf update"
abbr --add dnfs "dnf search"
abbr --add dnfl "dnf list --installed"
end
if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty"
abbr --add icat "kitten icat"
else if test "$TERM_PROGRAM" = "WezTerm"
if test "$WSL_DISTRO_NAME"
abbr --add icat "wezterm.exe imgcat"
else
abbr --add icat "wezterm imgcat"
end
end
# Bash Style Command Substitution
# https://github.com/fish-shell/fish-shell/wiki/Bash-Style-Command-Substitution-and-Chaining-(!!-!$)
function __last_history_item; echo $history[1]; end
abbr -a !! --position anywhere --function __last_history_item
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end
abbr --add bcnt "emacs -nw $HOME/Documents/Finance/Beancount/"
if command -v chezmoi > /dev/null
alias pmoi="chezmoi --source ~/.local/share/pmoi --config ~/.config/chezmoi/pmoi.toml"
end

View file

@ -0,0 +1,18 @@
switch (uname)
case "Linux"
set SYSTEM_COLOR_SCHEME (gsettings get org.gnome.desktop.interface color-scheme)
if test $SYSTEM_COLOR_SCHEME = "'prefer-dark'"
fish_config theme choose "Catppuccin Mocha"
else
fish_config theme choose "Catppuccin Latte"
end
case "Darwin"
set SYSTEM_COLOR_SCHEME (defaults read -g AppleInterfaceStyle)
if test $SYSTEM_COLOR_SCHEME = "Dark"
fish_config theme choose "Catppuccin Mocha"
else
fish_config theme choose "Catppuccin Latte"
end
case '*'
fish_config theme choose "Catppuccin Mocha"
end

View file

@ -0,0 +1,49 @@
# $DOTFILES/tools/fish/conf.d/keymap.fish
# Date: 2024-12-22
# Author: js0ny
# Location:
# ~/.config/fish/conf.d/keymap.fish
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
# read key: `fish_key_reader`
# get current bindings: `bind`
fish_vi_key_bindings
# source $DOTFILES/tools/fish/conf.d/keymap/+colemak.fish
# Emacs Hybrid
bind -M default ctrl-p up-or-search
bind -M default ctrl-n down-or-search
bind -M default ctrl-f forward-char
bind -M default ctrl-b backward-char
bind -M default ctrl-a beginning-of-line
bind -M default ctrl-e end-of-line
bind -M default ctrl-k kill-line
bind -M insert ctrl-p up-or-search
bind -M insert ctrl-n down-or-search
bind -M insert ctrl-f forward-char
bind -M insert ctrl-b backward-char
bind -M insert ctrl-a beginning-of-line
bind -M insert ctrl-e end-of-line
bind -M insert ctrl-k kill-line
bind -M insert ctrl-w backward-kill-path-component
# ctrl + backspace
bind -M insert ctrl-backspace backward-kill-path-component
# alt + backspace
bind -M insert alt-backspace backward-kill-line
# ctrl + delete
bind -M insert ctrl-delete kill-word
# alt + delete (d$)
bind -M insert alt-delete kill-line
fzf --fish | source
# C-r : fzf history search
# C-t : fzf file search
# A-c : fzf directory search

View file

@ -0,0 +1,23 @@
# Colemak hnei
# ^
# e
# < h i >
# n
# v
# bind -M default 'h' backward-char
bind -M default n down-or-search
bind -M default e up-or-search
bind -M default i forward-char
# Similar position to [i] in QWERTY
bind -M default -m insert l repaint-mode
bind -M default -m insert L beginning-of-line repaint-mode
# Ne{[k]s}t -> fish doesnt have this feature
# [J]ump
bind -M default j forward-word
bind -M default J forward-bigword
# Use N to Join
bind -M default N end-of-line delete-char

View file

@ -0,0 +1,47 @@
# $DOTFILES/tools/fish/conf.d/navi.fish
# Date: 2024-12-22
# Author: js0ny
# Location:
# ~/.config/fish/conf.d/navi.fish
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
set __CD_CMD "cd"
if command -v zoxide > /dev/null
set __CD_CMD "z"
zoxide init fish | source
end
alias ..="$__CD_CMD .."
alias ...="$__CD_CMD ../.."
alias ....="$__CD_CMD ../../.."
alias .....="$__CD_CMD ../../../.."
alias ......="$__CD_CMD ../../../../.."
abbr --add \- "$__CD_CMD -"
function zls
$__CD_CMD $argv[1] && ls
end
alias cdls=zls
function __source_quick_jump
set dir (fd --type d --max-depth 1 . ~/Source/ | fzf --preview 'lsd --color always --icon always {}')
if test -n "$dir"
cd "$dir"
end
end
# Quick Jump Directories
test -d $DOTFILES && abbr --add dot "$__CD_CMD $DOTFILES"
test -d $HOME/Downloads && abbr --add down "$__CD_CMD $HOME/Downloads"
test -d $HOME/.config && abbr --add conf "$__CD_CMD $HOME/.config"
test -d $HOME/Obsidian && abbr --add ob "$__CD_CMD $HOME/Obsidian"
test -d $HOME/Source && alias src="__source_quick_jump"
test -d $HOME/Source/Scripts && alias scr="fd --type f --hidden --exclude .git --exclude '.*' . ~/Source/Scripts/ | fzf --preview 'bat --color=always --style=numbers {}' | xargs -r nvim"
test -d $HOME/OrgFiles && abbr --add org "$__CD_CMD $HOME/OrgFiles"

View file

@ -0,0 +1,13 @@
# $DOTFILES/tools/fish/conf.d/prompt.fish
# Date: 2024-12-22
# Author: js0ny
# Location:
# ~/.config/fish/conf.d/prompt.fish
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
if command -v starship > /dev/null
starship init fish | source
end

View file

@ -0,0 +1,13 @@
if command -v wslpath > /dev/null
function cdw
cd (wslpath -u $argv)
end
function zw
z (wslpath -u $argv)
end
alias psw="tasklist.exe"
alias killw="taskkill.exe"
alias winget="winget.exe"
# https://github.com/stuartleeks/wsl-notify-send
alias notify-send="wsl-notify-send.exe"
end