mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
feat(nix): migrate fish shell and direnv to Nix
This commit is contained in:
109
nix/home/fish/default.nix
Normal file
109
nix/home/fish/default.nix
Normal file
@@ -0,0 +1,109 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
sharedAliases = import ../shared/shared-aliases.nix { inherit lib; };
|
||||
|
||||
# Function to read a file and return its contents as a string
|
||||
readFile = file: builtins.readFile (./. + "/functions/${file}");
|
||||
|
||||
# List of function files
|
||||
functionFiles = [
|
||||
"dataUrl.fish"
|
||||
"deleteNodeModules.fish"
|
||||
"encodeBase64.fish"
|
||||
"fcd.fish"
|
||||
"fe.fish"
|
||||
"fhcd.fish"
|
||||
"fs.fish"
|
||||
"fwt.fish"
|
||||
"ghpr.fish"
|
||||
"server.fish"
|
||||
"unquarantine.fish"
|
||||
"update.fish"
|
||||
];
|
||||
|
||||
# Create a set of functions, where each key is the function name (without .fish extension)
|
||||
# and the value is the contents of the file
|
||||
fishFunctions = builtins.listToAttrs (map
|
||||
(file: {
|
||||
name = lib.removeSuffix ".fish" file;
|
||||
value = readFile file;
|
||||
})
|
||||
functionFiles
|
||||
);
|
||||
in
|
||||
{
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
|
||||
# Shell options
|
||||
interactiveShellInit = ''
|
||||
# Enable vi-mode key bindings
|
||||
fish_vi_key_bindings
|
||||
|
||||
# Set environment variables
|
||||
set -gx TERM wezterm
|
||||
'';
|
||||
|
||||
shellAliases = sharedAliases.shellAliases;
|
||||
|
||||
functions = fishFunctions;
|
||||
|
||||
plugins = [
|
||||
{
|
||||
name = "autopair.fish";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jorgebucaran";
|
||||
repo = "autopair.fish";
|
||||
rev = "4d1752ff5b39819ab58d7337c69220342e9de0e2";
|
||||
sha256 = "qt3t1iKRRNuiLWiVoiAYOu+9E7jsyECyIqZJ/oRIT1A=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "replay.fish";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jorgebucaran";
|
||||
repo = "replay.fish";
|
||||
rev = "d2ecacd3fe7126e822ce8918389f3ad93b14c86c";
|
||||
sha256 = "TzQ97h9tBRUg+A7DSKeTBWLQuThicbu19DHMwkmUXdg=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "bass";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "edc";
|
||||
repo = "bass";
|
||||
rev = "79b62958ecf4e87334f24d6743e5766475bcf4d0";
|
||||
sha256 = "3d/qL+hovNA4VMWZ0n1L+dSM1lcz7P5CQJyy+/8exTc=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "z";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jethrokuan";
|
||||
repo = "z";
|
||||
rev = "85f863f20f24faf675827fb00f3a4e15c7838d76";
|
||||
sha256 = "+FUBM7CodtZrYKqU542fQD+ZDGrd2438trKM0tIESs0=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "fish-lf-icons";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "joshmedeski";
|
||||
repo = "fish-lf-icons";
|
||||
rev = "d1c47b2088e0ffd95766b61d2455514274865b4f";
|
||||
sha256 = "6po/PYvq4t0K8Jq5/t5hXPLn80iyl3Ymx2Whme/20kc=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "nix-env.fish";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "lilyball";
|
||||
repo = "nix-env.fish";
|
||||
rev = "7b65bd228429e852c8fdfa07601159130a818cfa";
|
||||
sha256 = "RG/0rfhgq6aEKNZ0XwIqOaZ6K5S4+/Y5EEMnIdtfPhk=";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
7
nix/home/fish/functions/dataUrl.fish
Normal file
7
nix/home/fish/functions/dataUrl.fish
Normal file
@@ -0,0 +1,7 @@
|
||||
function dataUrl --description "Create a data URL from a file"
|
||||
set mimeType (file -b --mime-type $argv)
|
||||
if string match -r '^text/' $mimeType
|
||||
set mimeType "$mimeType;charset=utf-8"
|
||||
end
|
||||
echo "data:$mimeType;base64,(openssl base64 -in $argv | tr -d '\n')"
|
||||
end
|
||||
3
nix/home/fish/functions/deleteNodeModules.fish
Normal file
3
nix/home/fish/functions/deleteNodeModules.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function deleteNodeModules --description "Delete all node_modules folders in a folder and subfolders"
|
||||
find . -name "node_modules" -type d -exec rm -rf '{}' +
|
||||
end
|
||||
3
nix/home/fish/functions/encodeBase64.fish
Normal file
3
nix/home/fish/functions/encodeBase64.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function encodeBase64 --description "Encodes images in Base64"
|
||||
uuencode -m $argv[1] /dev/stdout | sed 1d | sed '$d'
|
||||
end
|
||||
3
nix/home/fish/functions/fcd.fish
Normal file
3
nix/home/fish/functions/fcd.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function fcd --description "cd into directory"
|
||||
cd (find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
end
|
||||
10
nix/home/fish/functions/fe.fish
Normal file
10
nix/home/fish/functions/fe.fish
Normal file
@@ -0,0 +1,10 @@
|
||||
# fe [FUZZY PATTERN] - Open the selected file with the default editor
|
||||
# - Bypass fuzzy finder if there's only one match (--select-1)
|
||||
# - Exit if there's no match (--exit-0)
|
||||
function fe --description "Open the selected file with the default editor"
|
||||
set files (fzf-tmux --query=$argv --multi --select-1 --exit-0 | string split \n)
|
||||
|
||||
if test -n "$files"
|
||||
$EDITOR $files; and true # This line is added to prevent failure when using "set -e" in shell.
|
||||
end
|
||||
end
|
||||
4
nix/home/fish/functions/fhcd.fish
Normal file
4
nix/home/fish/functions/fhcd.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
function fhcd --description "Jump to home directory and search for directories"
|
||||
cd $HOME
|
||||
cd (find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
end
|
||||
13
nix/home/fish/functions/fs.fish
Normal file
13
nix/home/fish/functions/fs.fish
Normal file
@@ -0,0 +1,13 @@
|
||||
function fs --description "Determine size of a file or total size of a directory"
|
||||
if du -b /dev/null >/dev/null 2>&1
|
||||
set arg -sbh
|
||||
else
|
||||
set arg -sh
|
||||
end
|
||||
|
||||
if test -n "$argv"
|
||||
du $arg -- $argv
|
||||
else
|
||||
du $arg .[^.]* *
|
||||
end
|
||||
end
|
||||
3
nix/home/fish/functions/fwt.fish
Normal file
3
nix/home/fish/functions/fwt.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function fwt --description "Jump to Git worktree directory"
|
||||
cd (git worktree list | awk '{print $1}' | fzf)
|
||||
end
|
||||
4
nix/home/fish/functions/ghpr.fish
Normal file
4
nix/home/fish/functions/ghpr.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
function ghpr --description "Search and preview GitHub pull requests"
|
||||
set -l GH_FORCE_TTY 100%
|
||||
gh pr list | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --header-lines 3 | awk '{print $1}' | xargs gh pr checkout
|
||||
end
|
||||
3
nix/home/fish/functions/server.fish
Normal file
3
nix/home/fish/functions/server.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function server --description "Run a server with browser-sync"
|
||||
browser-sync start --server --files "**"
|
||||
end
|
||||
5
nix/home/fish/functions/unquarantine.fish
Normal file
5
nix/home/fish/functions/unquarantine.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
function unquarantine --description "Manually remove a downloaded app or file from the quarantine"
|
||||
for attribute in com.apple.metadata:kMDItemDownloadedDate com.apple.metadata:kMDItemWhereFroms com.apple.quarantine
|
||||
xattr -r -d "$attribute" $argv
|
||||
end
|
||||
end
|
||||
13
nix/home/fish/functions/update.fish
Normal file
13
nix/home/fish/functions/update.fish
Normal file
@@ -0,0 +1,13 @@
|
||||
function update --description "Updating Homebrew, Ruby, Python, Node.js, Neovim, and MacOS"
|
||||
sudo -v
|
||||
brew update && brew outdated && brew upgrade && brew cleanup
|
||||
sudo gem update --system && sudo gem update && gem cleanup all
|
||||
pip install --upgrade pip
|
||||
pip list -o --format columns | cut -d' ' -f1 | xargs -n1 pip install -U
|
||||
pnpm update -g
|
||||
~/.tmux/plugins/tpm/bin/update_plugins all
|
||||
gh extension upgrade --all
|
||||
fisher update
|
||||
nvim --headless "+Lazy! sync" +qa
|
||||
# sudo softwareupdate -i -a
|
||||
end
|
||||
Reference in New Issue
Block a user