2025-01-27 22:30:24 +00:00
# simplified version of https://raw.githubusercontent.com/Lunarnovaa/nixconf/3d13d69e9fcf072365935ee9dda719d6b0aa9bc1/modules/programs/terminal/nushell.nix
{
lib ,
config ,
pkgs ,
. . .
} : let
inherit ( config . local . systemVars ) username ;
inherit ( lib . modules ) mkIf ;
carapaceCache = " ${ config . hjem . users . ${ username } . directory } / . c a c h e / c a r a p a c e " ;
starshipCache = " ${ config . hjem . users . ${ username } . directory } / . c a c h e / s t a r s h i p " ;
zoxideCache = " ${ config . hjem . users . ${ username } . directory } / . c a c h e / z o x i d e " ;
in {
config = mkIf config . local . profiles . desktop . enable {
users . users . ${ username } . shell = pkgs . nushell ;
hjem . users . ${ username } = {
packages = with pkgs ; [ carapace nushell ] ;
files = {
" . c o n f i g / n u s h e l l / c o n f i g . n u " . text = ''
# disabling the basic banner on startup
$ env . config = {
show_banner : false ,
edit_mode : vi ,
hooks : {
pre_prompt : [ { ||
if ( which direnv | is-empty ) {
return
}
direnv export json | from json | default { } | load-env
if ' ENV_CONVERSIONS' in $ env and ' PATH' in $ env . ENV_CONVERSIONS {
$ env . PATH = do $ env . ENV_CONVERSIONS . PATH . from_string $ env . PATH
}
} ]
}
}
$ env . SSH_AUTH_SOCK = $ " ( $ e n v . X D G _ R U N T I M E _ D I R ) / s s h - a g e n t "
2025-01-29 10:24:57 +00:00
# remove indicator chars besides the one provided by starship
$ env . PROMPT_INDICATOR_VI_INSERT = " "
$ env . PROMPT_INDICATOR_VI_NORMAL = " "
$ env . PROMPT_MULTILINE_INDICATOR = " | "
2025-01-27 22:30:24 +00:00
# aliases
alias ll = ls - l
alias lg = lazygit
alias lg = lazygit ;
alias g = git ;
alias gs = git status ;
alias gsh = git show HEAD ;
alias gshs = DELTA_FEATURES = + side-by-side git show HEAD ;
alias ga = git add ;
alias gaa = git add : / ;
alias gap = git add - p ;
alias gc = git commit ;
alias gca = git commit - - amend ;
alias gcm = git commit - - message ;
alias gcf = git commit - - fixup ;
alias gk = git checkout ;
alias gkp = git checkout - p ;
alias gd = git diff ;
alias gds = DELTA_FEATURES = + side-by-side git diff ;
alias gdc = git diff - - cached ;
alias gdcs = DELTA_FEATURES = + side-by-side git diff - - cached ;
alias gf = git fetch ;
alias gl = git log ;
alias glp = git log - p ;
alias glps = DELTA_FEATURES = + side-by-side git log - p ;
alias gp = git push ;
alias gpf = git push - - force-with-lease ;
alias gr = git reset ;
alias gra = git reset : / ;
alias grp = git reset - p ;
alias gt = git stash ;
alias gtp = git stash pop ;
alias gu = git pull ;
# carapace init (completion engine)
source $ { carapaceCache } /init.nu
# starship init
use $ { starshipCache } /init.nu
# zoxide init
source $ { zoxideCache } /init.nu
'' ;
" . c o n f i g / n u s h e l l / e n v . n u " . text = ''
mkdir $ { carapaceCache }
mkdir $ { starshipCache }
mkdir $ { zoxideCache }
carapace _carapace nushell | save - f $ { carapaceCache } /init.nu
starship init nu | save - f $ { starshipCache } /init.nu
zoxide init nushell | save - f $ { zoxideCache } /init.nu
'' ;
} ;
} ;
2025-01-28 12:04:54 +00:00
# needed for ghostty, as it runs as a systemd service (for faster startups)
systemd . user . services . ghosttyd . path = [
pkgs . carapace
pkgs . zoxide
] ;
2025-01-27 22:30:24 +00:00
} ;
}