feat(fish): Switch shell to fish

This commit is contained in:
js0ny 2024-12-19 19:56:24 +00:00
parent 053304c4d5
commit 9ed1246583
16 changed files with 3389 additions and 17 deletions

View file

@ -2,18 +2,173 @@
# Date: 2024-11-30 # Date: 2024-11-30
# Author: js0ny # Author: js0ny
# Location: $XDG_CONFIG_HOME/skhd/skhdrc # # Location: $XDG_CONFIG_HOME/skhd/skhdrc
# Linking: # # Linking:
# ln -sf $DOTFILES/platforms/mac/skhdrc $XDG_CONFIG_HOME/skhd/skhdrc # # ln -sf $DOTFILES/platforms/mac/skhdrc $XDG_CONFIG_HOME/skhd/skhdrc
# Navigation # # Navigation
# alt - h : yabai -m window --focus west
# alt - n : yabai -m window --focus south
# alt - e : yabai -m window --focus north
# alt - i : yabai -m window --focus east
# # Moving windows
# shift + alt - h : yabai -m window --warp west
# shift + alt - n : yabai -m window --warp south
# shift + alt - e : yabai -m window --warp north
# shift + alt - i : yabai -m window --warp east
# ctrl - 1 : yabai -m space --focus 1
# ctrl - 2 : yabai -m space --focus 2
# ctrl - 3 : yabai -m space --focus 3
# ctrl - 4 : yabai -m space --focus 4
# ctrl - 5 : yabai -m space --focus 5
# ctrl - 6 : yabai -m space --focus 6
# ctrl - 7 : yabai -m space --focus 7
# ctrl - 8 : yabai -m space --focus 8
# ctrl - 9 : yabai -m space --focus 9
# ctrl - 0 : yabai -m space --focus 10
# # minimize window
# alt - m : yabai -m window --minimize
# # float / unfloat window and center on screen
# alt - f : yabai -m window --toggle float
# # toggle window native fullscreen
# shift + alt - f : yabai -m window --toggle native-fullscreen
# # send window to a space
# shift + ctrl - 1 : yabai -m window --space 1
# shift + ctrl - 2 : yabai -m window --space 2
# shift + ctrl - 3 : yabai -m window --space 3
# shift + ctrl - 4 : yabai -m window --space 4
# shift + ctrl - 5 : yabai -m window --space 5
# shift + ctrl - 6 : yabai -m window --space 6
# shift + ctrl - 7 : yabai -m window --space 7
# shift + ctrl - 8 : yabai -m window --space 8
# shift + ctrl - 9 : yabai -m window --space 9
# shift + ctrl - 0 : yabai -m window --space 10
# open terminal
ctrl - r : open -n -a "Kitty"
# moves focus between windows in the current focused display
alt - h : yabai -m window --focus west alt - h : yabai -m window --focus west
alt - n : yabai -m window --focus south alt - n : yabai -m window --focus south
alt - e : yabai -m window --focus north alt - e : yabai -m window --focus north
alt - i : yabai -m window --focus east alt - i : yabai -m window --focus east
# Moving windows # moves focus between spaces
shift + alt - h : yabai -m window --warp west alt - 1 : yabai -m space --focus 1
shift + alt - n : yabai -m window --warp south alt - 2 : yabai -m space --focus 2
shift + alt - e : yabai -m window --warp north alt - 3 : yabai -m space --focus 3
shift + alt - i : yabai -m window --warp east alt - 4 : yabai -m space --focus 4
alt - 5 : yabai -m space --focus 5
alt - 6 : yabai -m space --focus 6
alt - 7 : yabai -m space --focus 7
alt - 8 : yabai -m space --focus 8
alt - 9 : yabai -m space --focus 9
alt - 0 : yabai -m space --focus 10
# delete focused space
alt - q : yabai -m space --destroy
# toggle window split type
alt - e : yabai -m window --toggle split
# close window
alt - x : yabai -m window --close
# minimize window
alt - m : yabai -m window --minimize
# rotate tree
alt - r : yabai -m space --rotate 90
# mirror tree y-axis
alt - y : yabai -m space --mirror y-axis
# toggle desktop offset
alt - a : yabai -m space --toggle padding; yabai -m space --toggle gap
# toggle window parent zoom
alt - d : yabai -m window --focus mouse && \
yabai -m window --toggle zoom-parent
# float / unfloat window and center on screen
alt - t : yabai -m window --toggle float;\
yabai -m window --grid 4:4:1:1:2:2
# toggle window fullscreen zoom
alt - f : yabai -m window --focus mouse && \
yabai -m window --toggle zoom-fullscreen
# toggle window native fullscreen
shift + alt - f : yabai -m window --toggle native-fullscreen
# increase gap in focused space
alt - g : yabai -m space --gap rel:10
# decrease gap in focused space
shift + alt - g : yabai -m space --gap rel:-10
# create a new space and follow focus
alt - n : yabai -m space --create && \
index="$(yabai -m query --displays --display | jq '.spaces[-1]')" && \
yabai -m space --focus "${index}"
# create a new space, move window and follow focus
shift + alt - n : yabai -m space --create && \
index="$(yabai -m query --displays --display | jq '.spaces[-1]')" && \
yabai -m window --space "${index}" && \
yabai -m space --focus "${index}"
# balance size of windows
shift + alt - 0 : yabai -m space --balance
# swap window
shift + alt - h : yabai -m window --swap west
shift + alt - n : yabai -m window --swap south
shift + alt - e : yabai -m window --swap north
shift + alt - i : yabai -m window --swap east
# move window
shift + cmd - h : yabai -m window --warp west
shift + cmd - n : yabai -m window --warp south
shift + cmd - e : yabai -m window --warp north
shift + cmd - i : yabai -m window --warp east
# send window to a space
shift + alt - 1 : yabai -m window --space 1
shift + alt - 2 : yabai -m window --space 2
shift + alt - 3 : yabai -m window --space 3
shift + alt - 4 : yabai -m window --space 4
shift + alt - 5 : yabai -m window --space 5
shift + alt - 6 : yabai -m window --space 6
shift + alt - 7 : yabai -m window --space 7
shift + alt - 8 : yabai -m window --space 8
shift + alt - 9 : yabai -m window --space 9
shift + alt - 0 : yabai -m window --space 10
# change layout of desktop
ctrl + alt - a : yabai -m space --layout bsp
ctrl + alt - d : yabai -m space --layout float
# increase window size
ctrl + alt - h : yabai -m window --resize left:-40:0
ctrl + alt - n : yabai -m window --resize bottom:0:40
ctrl + alt - e : yabai -m window --resize top:0:-40
ctrl + alt - i : yabai -m window --resize right:40:0
# decrease window size
ctrl + alt + cmd - h : yabai -m window --resize left:40:0
ctrl + alt + cmd - n : yabai -m window --resize bottom:0:-40
ctrl + alt + cmd - e : yabai -m window --resize top:0:40
ctrl + alt + cmd - i : yabai -m window --resize right:-40:0
# restart yabai
ctrl + alt + cmd - r : launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai"
ctrl + alt + cmd - o : node ~/Projects/Personal/philips-hue-experiments/commands/turn-on.js --all
ctrl + alt + cmd - f : node ~/Projects/Personal/philips-hue-experiments/commands/turn-off.js --all

View file

@ -1,3 +1,17 @@
# .dotfiles # dotfiles
Moving to _Colemak_ This repository contains dotfiles for multiple platforms, with _colemak_ as the default keyboard layout.
## Structure
```shell
 .
├──  .editorconfig # Editor configuration, for LF/CRLF correction
├──  .gitattributes # Git attributes, for LF/CRLF correction
├──  bootstrap # Setup scripts for new machines
├──  common # Single-file configurations (lesskey, vimrc etc`)
├──  platforms # Platform-specific configurations
├──  readme.md # This file
├──  scripts # Scripts for various tasks
└──  tools # Multi-file configurations (shell, neovim etc)
```

View file

@ -39,3 +39,8 @@ fi
if command -v winget.exe > /dev/null; then if command -v winget.exe > /dev/null; then
winget.exe upgrade winget.exe upgrade
fi fi
# macOS - Rime
if [ $(uname) = "Darwin"]; then
bash ~/plum/rime-install
fi

View file

@ -1,6 +1,6 @@
// Paste this into surfingkeys advanced settings // Paste this into surfingkeys advanced settings
// or use: // or use:
// Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/browser/surfingkeys.js // Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/tools/browser/surfingkeys.js
// TODO: Visual Mode // TODO: Visual Mode
// #region Example // #region Example

2
tools/fish/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
fish_variables
completions

View file

@ -0,0 +1,137 @@
# $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/.cache)
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
set -gx PAGER "less -R"
set -gx EDITOR nvim
set -gx VISUAL nvim
# Minimal PATH for early commands
set -gx PATH /usr/local/bin /usr/bin /bin /usr/sbin /sbin ~/.local/bin $PATH
if test -d /opt/homebrew/bin # macOS
set -gx PATH /opt/homebrew/bin $PATH
else if test -d /home/linuxbrew/.linuxbrew/bin # Linux
set -gx PATH /home/linuxbrew/.linuxbrew/bin $PATH
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
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

View file

@ -0,0 +1,55 @@
# Powershell equivalent
abbr --add ni touch
abbr --add cls clear
abbr --add ii open
# Editors #
abbr --add v nvim
abbr --add c code
alias sv="sudo vim -u ~/.config/vim/vimrc"
alias sn="sudo nvim -u ~/.config/nvim/init.lua"
# Dev #
abbr --add py python3
abbr --add ipy ipython
abbr --add reload "source $__fish_config_dir/config.fish"
abbr --add pulldots "cd $DOTFILES && git pull"
# lsd - modern ls
if command -v lsd > /dev/null
alias ls='lsd -A -I .DS_Store -I .git -I .gitkeep'
abbr --add l 'lsd -lah'
abbr --add ll 'lsd -l'
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
# Use neovide as gVim
if command -v neovide > /dev/null
abbr --add gvi "neovide"
end
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"
end

View file

@ -0,0 +1,16 @@
fish_vi_key_bindings
# Colemak hnei
# ^
# n
# < h i >
# e
# 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

View file

@ -0,0 +1,13 @@
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
abbr --add \- 'cd -'
if command -v zoxide > /dev/null
zoxide init fish | source
end

View file

@ -0,0 +1,5 @@
if command -v starship > /dev/null
set -gx STARSHIP_CONFIG $DOTFILES/tools/starship/starship_fish.toml
starship init fish | source
end

23
tools/fish/config.fish Normal file
View file

@ -0,0 +1,23 @@
# $DOTFILES/tools/fish/config.fish
# Date: 2024-12-15
# Author: js0ny
# Define interactive shell configurations for fish
# Location:
# ~/.config/fish/config.fish (default location)
# Linking: Link the whole directory for submodules
# ln -sf $DOTFILES/tools/fish ~/.config/fish
if status is-interactive
# Commands to run in interactive sessions can go here
switch (uname)
case "Darwin"
# macOS Specific
abbr --add clip pbcopy
abbr --add paste pbpaste
case "Linux"
# Linux Specific
case '*'
# Default / Fallback case
end
end

29
tools/fish/readme.md Normal file
View file

@ -0,0 +1,29 @@
## `type -q` vs `command -v`
```shell
󰈺 > time for i in (seq 1 10000)
type -q vim
end
time for i in (seq 1 10000)
command -v vim >/dev/null
end
________________________________________________________
Executed in 545.79 millis fish external
usr time 177.62 millis 174.28 millis 3.34 millis
sys time 367.72 millis 366.16 millis 1.56 millis
________________________________________________________
Executed in 292.97 millis fish external
usr time 71.23 millis 69.31 millis 1.93 millis
sys time 215.22 millis 214.78 millis 0.44 millis
```
`command -v` is faster

2705
tools/kitty/kitty.conf Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,208 @@
# starship.toml
# ~/.config/starship.toml
format = '''$os$time $username @ $hostname $directory $all$character'''
continuation_prompt = "[r % ](bold cyan) " # Doesn't work in fish
add_newline = true
[time]
disabled = false
format = '[\[$time\]](purple)'
time_format = '%H:%M'
[username]
format = '[$user](bold)'
show_always = true
[hostname]
ssh_only = false
ssh_symbol = '󰞉 '
[character]
success_symbol = "[󰈺 >](bold green)"
error_symbol = "[󰈺 >](bold red)"
vimcmd_symbol = "[ <](bold green)"
[directory]
truncation_length = 2
truncate_to_repo = true
read_only = " 󰌾"
style = "bold cyan"
truncation_symbol = ".../"
[directory.substitutions]
"~/Documents" = "󰈙 "
"~/Downloads" = " "
"~/Music" = " "
"~/Pictures" = " "
"Source" = " "
"src" = " "
[aws]
symbol = " "
[buf]
symbol = " "
[c]
symbol = " "
[conda]
symbol = " "
[crystal]
symbol = " "
[dart]
symbol = " "
[docker_context]
symbol = " "
[elixir]
symbol = " "
[elm]
symbol = " "
[fennel]
symbol = " "
[fossil_branch]
symbol = " "
[git_branch]
symbol = " "
[git_commit]
tag_symbol = '  '
[golang]
symbol = " "
[guix_shell]
symbol = " "
[haskell]
symbol = " "
[haxe]
symbol = " "
[hg_branch]
symbol = " "
[java]
symbol = " "
[julia]
symbol = " "
[kotlin]
symbol = " "
[lua]
symbol = " "
[memory_usage]
symbol = "󰍛 "
[meson]
symbol = "󰔷 "
[nim]
symbol = "󰆥 "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[ocaml]
symbol = " "
[os]
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
[package]
symbol = "󰏗 "
[perl]
symbol = " "
[php]
symbol = " "
[pijul_channel]
symbol = " "
[python]
symbol = " "
[rlang]
symbol = "󰟔 "
[ruby]
symbol = " "
[rust]
symbol = "󱘗 "
[scala]
symbol = " "
[swift]
symbol = " "
[zig]
symbol = " "
[gradle]
symbol = " "

View file

@ -34,7 +34,7 @@ if command -v lsd > /dev/null; then
alias ls='lsd -A -I .DS_Store -I .git' alias ls='lsd -A -I .DS_Store -I .git'
alias l='lsd -lah' alias l='lsd -lah'
alias ll='lsd -l' alias ll='lsd -l'
alias tree='lsd --tree -I .DS_Store -I .git' alias tree='lsd --tree -I .DS_Store -I .git -A'
fi fi
# Functions # # Functions #
@ -89,3 +89,8 @@ if command -v brew > /dev/null; then
alias brewc="brew cleanup" alias brewc="brew cleanup"
alias brewr="brew uninstall" alias brewr="brew uninstall"
fi fi
alias -s {htm,html,css,scss,js,jsx,ts,tsx,json,jsonc}=code
alias -s {md,markdown}=code
alias -s {py,sh,rb,pl,php,java,c,cpp,h,hpp}=nvim
alias -s {cs,csx,fs,fsx,razor}=code

View file

@ -35,8 +35,8 @@ done
# Use `set -k` to mark leading `#` as a comment character # Use `set -k` to mark leading `#` as a comment character
set -k set -k
# TODO: Below should be reorganized # # TODO: Below should be reorganized
export PATH=$HOME/.local/bin:$PATH # export PATH=$HOME/.local/bin:$PATH
export NVM_DIR="$HOME/.config/nvm" # export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm # [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm