feat(devkit): zsh wrapper
This commit is contained in:
@@ -4,4 +4,5 @@
|
||||
lazygit = pkgs.callPackage ./lazygit {};
|
||||
starship = pkgs.callPackage ./starship {};
|
||||
yazi = pkgs.callPackage ./yazi {};
|
||||
zsh = pkgs.callPackage ./zsh {inherit starship;};
|
||||
}
|
||||
|
||||
4
packages/devkit/zsh/.zshenv
Normal file
4
packages/devkit/zsh/.zshenv
Normal file
@@ -0,0 +1,4 @@
|
||||
# Source any OS-specific environment variables
|
||||
if [ -f "$HOME/.zshenv" ]; then
|
||||
source "$HOME/.zshenv"
|
||||
fi
|
||||
82
packages/devkit/zsh/.zshrc
Normal file
82
packages/devkit/zsh/.zshrc
Normal file
@@ -0,0 +1,82 @@
|
||||
# Source OS-specific configurations
|
||||
if [ -f "$HOME/.zshrc" ]; then
|
||||
source "$HOME/.zshrc"
|
||||
fi
|
||||
|
||||
typeset -U auto cdpath fpath manpath
|
||||
|
||||
if [ -f "$ZSHRC_PREPEND" ]; then
|
||||
source "$ZSHRC_PREPEND"
|
||||
fi
|
||||
|
||||
# Autocompletion
|
||||
autoload -U compinit && compinit
|
||||
|
||||
# Autosuggestion
|
||||
source "$ZSH_PLUGIN_AUTOSUGGESTIONS"
|
||||
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
||||
|
||||
# Command history
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=1000
|
||||
|
||||
HISTFILE="$HOME/.zsh_history"
|
||||
mkdir -p "$(dirname $HISTFILE)"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
unsetopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
unsetopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
unsetopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt SHARE_HISTORY
|
||||
unsetopt EXTENDED_HISTORY
|
||||
|
||||
# Start starship for interactive shells
|
||||
if [[ "$TERM" != "dump" ]]; then
|
||||
eval "$(starship init zsh)"
|
||||
fi
|
||||
|
||||
# Syntax highlighting
|
||||
source "$ZSH_PLUGIN_SYNTAXHIGHLIGHING"
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS+=()
|
||||
|
||||
# Integration for Zellij
|
||||
if command -v "zellij" >/dev/null 2>&1; then
|
||||
eval "$(zellij setup --generate-auto-start zsh)"
|
||||
fi
|
||||
|
||||
# Integration for direnv
|
||||
if command -v "direnv" >/dev/null 2>&1; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
# Integration for Ghostty
|
||||
if [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then
|
||||
source "$GHOSTTY_RESOURCES_DIR/shell-integration/zsh/ghostty-integration"
|
||||
fi
|
||||
|
||||
# Integration with GPG
|
||||
export GPG_TTY="$TTY"
|
||||
|
||||
# Aliases
|
||||
alias -- vi='nvim'
|
||||
alias -- vim='nvim'
|
||||
alias -- vimdiff='nvim -d'
|
||||
alias -- lg='lazygit'
|
||||
|
||||
# Yazi alias (with wrapper to change cwd)
|
||||
function y() {
|
||||
local tmp="$(mktemp -t "yazi-cmd.XXXXXX")" cwd
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||
builtin cd -- "$cwd"
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
}
|
||||
# Yazi alias (without wrapper to change cwd)
|
||||
alias -- yy='yazi'
|
||||
|
||||
if [ -f "$ZSHRC_APPEND" ]; then
|
||||
source "$ZSHRC_APPEND"
|
||||
fi
|
||||
58
packages/devkit/zsh/default.nix
Normal file
58
packages/devkit/zsh/default.nix
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
symlinkJoin,
|
||||
makeWrapper,
|
||||
pkgs,
|
||||
lib,
|
||||
zsh ? pkgs.zsh,
|
||||
starship ? pkgs.starship,
|
||||
# .zshrc
|
||||
zshrc-prepend ? "",
|
||||
zshrc-append ? "",
|
||||
}: let
|
||||
packages = [
|
||||
starship
|
||||
];
|
||||
|
||||
zsh-syntax-highlighting = "${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh";
|
||||
zsh-autosuggestions = "${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh";
|
||||
|
||||
zshrc-prepend-file = pkgs.writeText ".zshrc_prepend" zshrc-prepend;
|
||||
zshrc-append-file = pkgs.writeText ".zshrc_append" zshrc-append;
|
||||
|
||||
drv = symlinkJoin ({
|
||||
paths = zsh;
|
||||
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/zsh \
|
||||
--set-default 'PATH' '${lib.makeBinPath packages}:$PATH' \
|
||||
--set-default 'ZSH_PLUGIN_SYNTAXHIGHLIGHING' '${zsh-syntax-highlighting}' \
|
||||
--set-default 'ZSH_PLUGIN_AUTOSUGGESTIONS' '${zsh-autosuggestions}' \
|
||||
--set-default 'ZSHRC_PREPEND' '${zshrc-prepend-file}' \
|
||||
--set-default 'ZSHRC_APPEND' '${zshrc-append-file}' \
|
||||
--set-default 'ZDOTDIR' '${./.}'
|
||||
'';
|
||||
}
|
||||
// {inherit (zsh) name pname meta man;});
|
||||
in
|
||||
pkgs.stdenv.mkDerivation (rec {
|
||||
name = drv.name;
|
||||
pname = drv.pname;
|
||||
|
||||
buildCommand = let
|
||||
desktopEntry = pkgs.makeDesktopItem {
|
||||
name = pname;
|
||||
desktopName = name;
|
||||
exec = "${lib.getExe drv}";
|
||||
terminal = true;
|
||||
};
|
||||
in ''
|
||||
mkdir -p $out/bin
|
||||
cp ${lib.getExe drv} $out/bin
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
cp ${desktopEntry}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop
|
||||
'';
|
||||
}
|
||||
// {inherit (zsh) meta man;})
|
||||
Reference in New Issue
Block a user