1
0
Fork 0

Pallas: Switch from fish to zsh

This commit is contained in:
Daniel Kempkens 2024-12-22 23:41:02 +01:00
parent 216ed06c62
commit c2a294623b
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
23 changed files with 325 additions and 93 deletions

View file

@ -22,7 +22,7 @@ let
nerdfonts = pkgs.stdenvNoCC.mkDerivation {
pname = "nerdfonts";
version = "3.2.1";
version = "3.3.0";
src = ./NerdFonts;

View file

@ -22,6 +22,7 @@
(local nix #[(exe :nix) :repl])
(local ruby #[(exe :irb)])
(local typescript #[(exe :node)])
(local zsh #[(exe :zsh)])
;; Map filetype to REPL
(local repl-map {: elixir
: erlang
@ -31,10 +32,11 @@
: javascript
: nix
: ruby
: typescript})
: typescript
: zsh})
(fn mod.open-shell []
(let [shell (. repl-map :fish)]
(let [shell (. repl-map :zsh)]
(open-split shell)))
(fn mod.open-repl []

View file

@ -11,6 +11,7 @@
; Icons
:elixir "#A074C4"
:et "#1C3062"
:nvim "#019833"
:nix "#7EBAE4"
:reddit "#FA4400"
:ssh "#F4C82D"}
@ -24,48 +25,63 @@
(let [title tab.tab_title]
(if (and title (> (length title) 0)) title tab.active_pane.title)))
(fn extract-tab-info [title]
(match title
(where t (t:find "^nvim%s"))
{:title (t:gsub "^nvim%s(.*)" "%1") :icon " " :color "#019833"}
(where t (t:find "^git%s"))
{:title (t:gsub "^git%s(.*)" "%1") :icon "󰊢 " :color "#F25029"}
(where t (t:find "^mix%s"))
{:title (t:gsub "^mix%s(.*)" "%1") :icon " " :color colors.elixir}
(where t (t:find "^iex%s")) {: title :icon " " :color colors.elixir}
(where t (t:find "^upa%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^upp%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nrsw%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^ngc%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nix%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nix-%w+%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^colmena%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^deploy%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^ssh%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^scp%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^et%s")) {: title :icon " " :color colors.et}
(where t (t:find "^just%s")) {: title :icon " " :color "#C87D57"}
(where t (t:find :^ytdl)) {: title :icon " " :color "#FF0000"}
(where t (t:find :^instagram-)) {: title :icon " " :color "#FB2179"}
(where t (t:find "^gallery-dl%s"))
{:title (t:gsub "^gallery-dl%s(.*)" "%1") :icon " " :color "#009900"}
(where t (t:find "^bdfr%s"))
{:title (t:gsub "^bdfr%s(.*)" "%1") :icon " " :color colors.reddit}
(where t (t:find "^bdfr-%w+%s")) {: title
:icon " "
:color colors.reddit}
(where t (t:find "^rexit%s")) {: title :icon " " :color colors.reddit}
(where t (t:find :^redis-)) {: title :icon " " :color "#DC372C"}
(where t (t:find "^%[%w+%]%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^%w+@%w+:%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^%w+-dev")) {: title :icon " " :color "#0099CC"}
(where t (t:find "^%w+-dl%s")) {: title :icon " " :color "#22BC00"}
_ {: title :icon " " :color "#F8F8F2"}))
(fn extract-tab-info [title tab]
(let [current-pane tab.active_pane]
(match title
(where t (t:find "^nvim%s"))
{:title (t:gsub "^nvim%s(.*)" "%1") :icon " " :color colors.nvim}
(where t (t:find :^nvim$)) {: title :icon " " :color colors.nvim}
(where t (t:find "^git%s"))
{:title (t:gsub "^git%s(.*)" "%1") :icon "󰊢 " :color "#F25029"}
(where t (t:find "^mix%s"))
{:title (t:gsub "^mix%s(.*)" "%1") :icon " " :color colors.elixir}
(where t (t:find "^iex%s")) {: title :icon " " :color colors.elixir}
(where t (t:find "^upa%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^upp%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nrsw%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^ngc%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nix%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nix-%w+%s")) {: title
:icon " "
:color colors.nix}
(where t (t:find "^colmena%s")) {: title
:icon " "
:color colors.nix}
(where t (t:find "^deploy%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^ssh%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^scp%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^et%s")) {: title :icon " " :color colors.et}
(where t (t:find "^just%s")) {: title :icon " " :color "#C87D57"}
(where t (t:find :^ytdl)) {: title :icon " " :color "#FF0000"}
(where t (t:find :^instagram-)) {: title :icon " " :color "#FB2179"}
(where t (t:find "^gallery-dl%s")) {:title (t:gsub "^gallery-dl%s(.*)"
"%1")
:icon " "
:color "#009900"}
(where t (t:find :^discord-)) {: title :icon " " :color "#5865F2"}
(where t (t:find "^bdfr%s"))
{:title (t:gsub "^bdfr%s(.*)" "%1") :icon " " :color colors.reddit}
(where t (t:find "^bdfr-%w+%s")) {: title
:icon " "
:color colors.reddit}
(where t (t:find "^rexit%s")) {: title
:icon " "
:color colors.reddit}
(where t (t:find :^redis-)) {: title :icon " " :color "#DC372C"}
(where t (t:find "^%[%w+%]%s")) {: title
:icon " "
:color colors.ssh}
(where t (t:find "^%w+@%w+:%s")) {: title
:icon " "
:color colors.ssh}
(where t (t:find "^%w+-dev")) {: title :icon " " :color "#0099CC"}
(where t (t:find "^%w+-dl%s")) {: title :icon " " :color "#22BC00"}
_ {: title :icon " " :color "#F8F8F2"})))
(wezterm.on :format-tab-title
(fn [tab _tabs _panes _config _hover max-width]
(let [raw-title (extract-tab-title tab)
tab-info (extract-tab-info raw-title)
tab-info (extract-tab-info raw-title tab)
title (wezterm.truncate_right tab-info.title
(- max-width 5))]
(if tab.is_active
@ -142,7 +158,7 @@
(set overrides.freetype_load_target :Light)
(window:set_config_overrides overrides))))))
;; Configuration
{:default_prog [_G.shells.fish :--interactive]
{:default_prog [_G.shells.zsh :-i]
;; Appearance
:color_scheme "Dracula (Official)"
:window_decorations :INTEGRATED_BUTTONS|RESIZE
@ -220,8 +236,7 @@
;; Launch Menu
:launch_menu [{:label :Btop++ :args [_G.programs.btop]}
{:label :bash :args [_G.shells.bash]}
{:label :fish :args [_G.shells.fish]}
{:label :nushell :args [_G.shells.nushell]}]
{:label :zsh :args [_G.shells.zsh]}]
;; Other
:front_end :WebGpu
:check_for_updates false})

View file

@ -7,8 +7,7 @@ in
imports = [
../config/fonts
../programs/fish.nix
../programs/nushell.nix
../programs/zsh
../programs/atuin.nix
../programs/direnv.nix
../programs/fzf.nix

View file

@ -3,6 +3,7 @@
{
imports = [
../programs/fish.nix
../programs/zsh
../programs/atuin.nix
../programs/starship.nix
../programs/direnv.nix

View file

@ -3,7 +3,7 @@
enable = true;
enableBashIntegration = false;
enableZshIntegration = false;
enableZshIntegration = true;
enableFishIntegration = true;
settings = {
@ -25,6 +25,12 @@
};
};
programs.zsh.history = {
save = 0;
size = 0;
share = false;
};
programs.fish.shellInit = ''
set -x fish_history ""
'';

View file

@ -95,7 +95,7 @@ in
end
pushd "$config_dir"
rm -rf result
rm -f result
if test -z "$DIRENV_DIR"
eval (direnv export fish 2>/dev/null)

View file

@ -3,6 +3,7 @@
{
programs.starship = {
enable = true;
enableZshIntegration = true;
enableFishIntegration = true;
enableTransience = true;

View file

@ -1,26 +1,17 @@
{ pkgs, config, ... }:
{ pkgs, ... }:
let
wezterm-pkg = pkgs.wezterm;
wezterm-nushell = pkgs.writeShellScript "wezterm-nushell.sh" ''
source /etc/static/bashrc
source ${config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh
exec ${pkgs.nushell.outPath}/bin/nu
'';
in
{
programs.wezterm = {
enable = true;
package = wezterm-pkg;
extraConfig = /* lua */ ''
_G.shells = {
bash = '${pkgs.bash.outPath}/bin/bash',
fish = '${pkgs.fish.outPath}/bin/fish',
nushell = '${wezterm-nushell}',
zsh = '${pkgs.zsh.outPath}/bin/zsh',
};
_G.programs = {

View file

@ -1,42 +1,56 @@
{ pkgs, config, lib, ... }:
{ pkgs, lib, ... }:
{
programs.yt-dlp = {
enable = true;
programs =
let
ytdlPackage = pkgs.yt-dlp;
ytdlExe = lib.getExe ytdlPackage;
in
{
yt-dlp = {
enable = true;
package = ytdlPackage;
settings = {
format = "'bestvideo+bestaudio/best'";
# Metadata
add-metadata = true;
embed-subs = true;
xattrs = true;
# Subtitles
write-sub = true;
sub-format = "best";
sub-lang = "en,de";
# Downloader
downloader = "aria2c";
downloader-args = "aria2c:'--async-dns=false --max-download-limit=6M --min-split-size=1M --max-connection-per-server=4 --split=4'";
# Other
no-overwrites = true;
no-call-home = true;
settings = {
format = "'bestvideo+bestaudio/best'";
# Metadata
add-metadata = true;
embed-subs = true;
xattrs = true;
# Subtitles
write-sub = true;
sub-format = "best";
sub-lang = "en,de";
# Downloader
downloader = "aria2c";
downloader-args = "aria2c:'--async-dns=false --max-download-limit=6M --min-split-size=1M --max-connection-per-server=4 --split=4'";
# Other
no-overwrites = true;
no-call-home = true;
};
};
zsh.shellAliases = {
ytdl = "${ytdlExe} --config-location \"$HOME/.config/yt-dlp/config\" --download-archive \"$HOME/.config/yt-dlp/archive\"";
ytdl_mp4 = "ytdl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]'";
yti = "ytdl -F";
};
fish = {
shellAliases = {
ytdl = "ytdl_with_options";
ytdl_mp4 = "ytdl_with_options -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]'";
yti = "ytdl_with_options -F";
};
functions.ytdl_with_options = ''
${ytdlExe} --config-location "$HOME/.config/yt-dlp/config" --download-archive "$HOME/.config/yt-dlp/archive" $argv
'';
};
};
};
home.packages = with pkgs; [
aria2
rtmpdump
];
programs.fish = {
shellAliases = {
ytdl = "ytdl_with_options";
ytdl_mp4 = "ytdl_with_options -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]'";
yti = "ytdl_with_options -F";
};
functions.ytdl_with_options = ''
${lib.getExe config.programs.yt-dlp.package} --config-location "$HOME/.config/yt-dlp/config" --download-archive "$HOME/.config/yt-dlp/archive" $argv
'';
};
}

View file

@ -8,6 +8,11 @@
ji = "zi";
};
programs.zsh.shellAliases = {
j = "z";
ji = "zi";
};
programs.nushell.shellAliases = {
j = "z";
ji = "zi";

View file

@ -0,0 +1,144 @@
{ pkgs, lib, config, ... }:
let
inherit (pkgs) fetchFromGitHub;
inherit (pkgs.stdenv) isDarwin;
inherit (lib) optionals;
inherit (lib.attrsets) optionalAttrs;
in
{
programs.zsh = {
enable = true;
enableCompletion = true;
enableVteIntegration = !config.programs.wezterm.enable;
autosuggestion = {
enable = true;
strategy = [ "completion" ];
};
syntaxHighlighting = {
enable = true;
highlighters = [ "main" "brackets" ];
};
plugins = [
{
# https://github.com/dracula/zsh-syntax-highlighting
name = "dracula-zsh-syntax-highlighting";
file = "zsh-syntax-highlighting.sh";
src = fetchFromGitHub {
owner = "dracula";
repo = "zsh-syntax-highlighting";
rev = "09c89b657ad8a27ddfe1d6f2162e99e5cce0d5b3";
hash = "sha256-JrSKx8qHGAF0DnSJiuKWvn6ItQHvWpJ5pKo4yNbrHno=";
};
}
{
# https://github.com/trystan2k/zsh-tab-title
name = "zsh-tab-title";
file = "zsh-tab-title.plugin.zsh";
src = fetchFromGitHub {
owner = "trystan2k";
repo = "zsh-tab-title";
rev = "9c36ac968fe675edcc181a41b0b8959024a8b6c1";
hash = "sha256-ZEhbQ+yIfCz+vmua7XYBQ4kSVgwoNR8Y4zJyKNypsz0=";
};
}
{
# https://github.com/Freed-Wu/zsh-colorize-functions
name = "zsh-colorize-functions";
file = "zsh-colorize-functions.plugin.zsh";
src = fetchFromGitHub {
owner = "Freed-Wu";
repo = "zsh-colorize-functions";
rev = "46a299f8f8b1c71867679eaf4f67e30fd2746820";
hash = "sha256-DvqhWgox8v3Km1Rzkg7tEDqJ2zF62K6ILAzlOhUbuCc=";
};
}
{
# https://github.com/Freed-Wu/zsh-help
name = "zsh-help";
file = "zsh-help.plugin.zsh";
src = fetchFromGitHub {
owner = "Freed-Wu";
repo = "zsh-help";
rev = "95cbc114078d8209730e38c72a6fa5859ca0773d";
hash = "sha256-ij+ooXQxV3CmsCN/CrJMicTWvS+9GYHA/1Kuqh5zXIY=";
};
}
] ++ optionals isDarwin [
{
# https://github.com/MichaelAquilina/zsh-auto-notify
name = "zsh-auto-notify";
file = "auto-notify.plugin.zsh";
src = fetchFromGitHub {
owner = "MichaelAquilina";
repo = "zsh-auto-notify";
rev = "27c07dddb42f05b199319a9b66473c8de7935856";
hash = "sha256-ScBwky33leI8mFMpAz3Ng2Z0Gbou4EWMOAhkcMZAWIc=";
};
}
];
shellAliases =
let
ezaExe = lib.getExe pkgs.eza;
in
{
upa = "nix flake update ~/.config/nixpkgs -v && upn";
ngc = "nix-collect-garbage -d && sudo nix-collect-garbage -d";
nsr = "sudo nix-store --verify --check-contents --repair";
la = "${ezaExe} --long --all --group --header --group-directories-first --sort=type --icons";
lg = "${ezaExe} --long --all --group --header --git";
lt = "${ezaExe} --long --all --group --header --tree --level ";
} // optionalAttrs isDarwin {
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
};
initExtra = /* sh */ ''
# Keymaps
bindkey '^[[1;3C' forward-word # Alt+Right
bindkey '^[[1;3D' backward-word # Alt+Left
# Plugins
ZSH_TAB_TITLE_ENABLE_FULL_COMMAND=true
ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true
AUTO_NOTIFY_THRESHOLD=10
# Path configuration
if [[ -d "$HOME/.bin" ]]; then
path=("$HOME/.bin" $path)
export PATH
fi
() {
local user_functions="$HOME/.zsh/user_functions"
if [[ -d $user_functions ]]; then
typeset -TUg +x FPATH=$user_functions:$FPATH fpath
autoload ''${=$(cd "$user_functions" && echo *)}
fi
local server_functions="$HOME/.zsh/server_functions"
if [[ -d $server_functions ]]; then
typeset -TUg +x FPATH=$server_functions:$FPATH fpath
autoload ''${=$(cd "$server_functions" && echo *)}
fi
}
'';
};
home.file.".zsh/user_functions" = {
source = ./functions;
recursive = true;
};
# Plugin dependencies
programs.bat.enable = true;
}

View file

@ -0,0 +1 @@
echo -n "$1" | base64 --decode

View file

@ -0,0 +1 @@
osascript -e "id of app \"$1\""

View file

@ -0,0 +1 @@
et -c "$*" mediaserver

View file

@ -0,0 +1,32 @@
os="$(uname)"
other_hostname="$1"
case "$os" in
Darwin)
nix_hostname="$(scutil --get LocalHostName)"
config_dir="$HOME/.config/nixpkgs"
;;
Linux)
nix_hostname="$(hostname -s)"
config_dir="/etc/nixos"
;;
*)
echo "Unsupported OS"
exit 1
esac
pushd "$config_dir"
rm -f result
if [ -z "$DIRENV_DIR" ]; then
eval "$(direnv export zsh 2>/dev/null)"
fi
if [ -z "$other_hostname" ]; then
just deploy-local-machine "$nix_hostname"
else
just deploy-remote-machine "$other_hostname"
fi
rm -f result
popd

13
home/programs/zsh/functions/upn Executable file
View file

@ -0,0 +1,13 @@
os="$(uname)"
case "$os" in
Darwin)
$HOME/.config/nixpkgs/home/programs/nvim/update-plugins.sh
;;
Linux)
/etc/nixos/home/programs/nvim/update-plugins.sh
;;
*)
echo "Unsupported OS"
exit 1
esac

View file

@ -0,0 +1 @@
wezterm cli spawn --domain-name "SSH:$1"

5
system/darwin/zsh.nix Normal file
View file

@ -0,0 +1,5 @@
{
programs.zsh = {
enable = true;
};
}

View file

@ -11,7 +11,7 @@ in
../darwin/defaults.nix
../darwin/sudo.nix
../darwin/fish.nix
../darwin/zsh.nix
../darwin/attic.nix
../darwin/mas.nix

View file

@ -170,7 +170,7 @@ in
home = "/home/daniel";
description = "Daniel";
extraGroups = [ "wheel" ];
shell = pkgs.fish;
shell = pkgs.zsh;
openssh.authorizedKeys.keys = [ ssh-keys.LAN ssh-keys.DanielsPhone ];
};