2024-10-18 14:14:58 +02:00
{
description = " j i r i k s 7 4 ' s Z S H c o n f i g u r a t i o n " ;
inputs = {
nixpkgs . url = " g i t h u b : n i x o s / n i x p k g s / n i x o s - u n s t a b l e " ;
flake-utils . url = " g i t h u b : n u m t i d e / f l a k e - u t i l s " ;
} ;
outputs = {
self ,
nixpkgs ,
flake-utils ,
. . .
} @ inputs :
{
2024-10-18 14:49:12 +02:00
homeManagerModules = {
default = { config , lib , pkgs , . . . }: {
home . packages = with pkgs ; [
nix-zsh-completions
asciinema # Terminal recording
libnotify # Notifications
websocat # For asciinema v2 streams
tldr
lsd
bat
eza
trash-cli
fzf # enhancd
fd # enhancd
# rofi # for fd
gnutar # ex
bzip3 # ex
unzip # ex
p7zip # ex
unrar # ex
gzip # ex
] ;
programs = {
# nix-index = {
# enable = true;
# enableZshIntegration = true;
# };
# thefuck = {
# enable = true;
# enableZshIntegration = true;
# };
direnv = {
2024-10-18 14:14:58 +02:00
enable = true ;
2024-10-18 14:49:12 +02:00
enableZshIntegration = true ;
nix-direnv . enable = true ;
2024-10-18 14:14:58 +02:00
} ;
2024-10-18 14:49:12 +02:00
zsh = {
enable = true ;
enableCompletion = true ;
zplug = {
enable = true ;
plugins = [
{ name = " r o m k a t v / p o w e r l e v e l 1 0 k " ; tags = [ " a s : t h e m e " " d e p t h : 1 " ] ; } # Installations with additional options. For the list of options, please refer to Zplug README.
{ name = " z - s h e l l / F - S y - H " ; } # Feature-rich Syntax Highlighting for Zsh
# { name = "zsh-users/zsh-syntax-highlighting"; }
{ name = " z s h - u s e r s / z s h - c o m p l e t i o n s " ; } # Adds some missing completions to zsh
{ name = " z s h - u s e r s / z s h - a u t o s u g g e s t i o n s " ; } # Simple plugin installation
{ name = " M i c h a e l A q u i l i n a / z s h - y o u - s h o u l d - u s e " ; } # Did you forget to use an alias?
{ name = " d a v i d d e / g i t " ; } # Aliases for git
{ name = " b a b a r o t / e n h a n c d " ; tags = [ " u s e : i n i t . s h " ] ; } # Includes simmilar functionality to zsh-z
{ name = " s u p e r c r a b t r e e / k " ; } # Directory listings for Zsh with git features.
{ name = " p l u g i n s / c o m m a n d - n o t - f o u n d " ; tags = [ " f r o m : o h - m y - z s h " ] ; }
{ name = " g k o / s s h - c o n n e c t " ; tags = [ " u s e : s s h - c o n n e c t . s h " ] ; } # List of most used ssh connections
{ name = " a g k o z a k / z s h - z " ; } # Jump arount your filesystem with ease
{ name = " s i n e t o / w e b - s e a r c h " ; }
{ name = " z s h - u s e r s / z a w " ; } # Desctiptions for command outputs (afaik)zplug "plugins/git", from:oh-my-zsh
# { name = "plugins/dirhistory"; tags = [ "from:oh-my-zsh" ]; }
] ;
} ;
initExtraFirst = ''
if [ [ " ' ' ${ ZSH_PROFILE } " - eq 1 ] ] ; then
zmodload zsh/zprof # Profiling. Enable `zprof` at the end of initExtra too.
else
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [ [ - r " ' ' ${ XDG_CACHE_HOME : - $ HOME/.cache } / p 1 0 k - i n s t a n t - p r o m p t - ' ' ${ ( % ) : - % n } . z s h " ] ] ; then
source " ' ' ${ XDG_CACHE_HOME : - $ HOME/.cache } / p 1 0 k - i n s t a n t - p r o m p t - ' ' ${ ( % ) : - % n } . z s h "
fi
2024-10-18 14:14:58 +02:00
fi
2024-10-18 14:49:12 +02:00
'' ;
2024-10-18 14:14:58 +02:00
2024-10-18 14:49:12 +02:00
initExtra = ''
# Remove nix from path if we are in a container (distrobox)
if [ - v DISTROBOX_ENTER_PATH ] ; then
export PATH = $ ( echo $ PATH | tr ' : ' ' \ n' | grep - vE ' /nix / | /run/wrappers | \ . nix-profile | /etc/profiles/per-user/jirka/bin | /run/current-system/sw/bin ' | tr ' \ n' ' : ' )
export PATH = $ ( echo $ PATH | sed ' s / : $ // ' )
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[ [ ! - f ~/.p10k.zsh ] ] || source ~/.p10k.zsh
export YSU_MESSAGE_POSITION = " a f t e r " # you-should-use plugin
export ASCIINEMA_API_URL = https://asciinema.stefka.eu
if [ - v ASCIINEMA_REC ] ; then
_zsh_autosuggest_disable
fi
# Basic auto/tab complete:
autoload - U compinit
zstyle ' : completion:*' menu select
zmodload zsh/complist
compinit
_comp_options + = ( globdots ) # Include hidden files.
# Custom ZSH Binds
bindkey ' ^ ' autosuggest-accept
bindkey " ^ [ [ H " beginning-of-line
bindkey " ^ [ [ F " end-of-line
bindkey " ^ [ [ 1 ; 5 C " forward-word
bindkey " ^ [ [ 1 ; 5 D " backward-word
bindkey " ^ [ [ 3 ~ " delete-char
# Extracting
ex ( )
{
if [ - f $ 1 ] ; then
case $ 1 in
* . tar . bz2 ) tar xjf $ 1 ; ;
* . tar . gz ) tar xzf $ 1 ; ;
* . tar . xz ) tar xJf $ 1 ; ;
* . bz2 ) bunzip3 $ 1 ; ;
* . rar ) unrar x $ 1 ; ;
* . gz ) gunzip $ 1 ; ;
* . tar ) tar xf $ 1 ; ;
* . tbz2 ) tar xjf $ 1 ; ;
* . tgz ) tar xzf $ 1 ; ;
* . zip ) unzip $ 1 ; ;
* . Z ) uncompress $ 1 ; ;
* . 7 z ) 7 z x $ 1 ; ;
* ) echo " ' $ 1 ' c a n n o t b e e x t r a c t e d v i a e x ( ) " ; ;
esac
else
echo " ' $ 1 ' i s n o t a v a l i d f i l e "
fi
}
# Kitty binds
if [ " $ T E R M " = " x t e r m - k i t t y " ] ; then
alias ssh = " k i t t y + k i t t e n s s h "
alias icat = " k i t t y + k i t t e n i c a t "
alias d = " k i t t y + k i t t e n d i f f "
alias get = " k i t t y + k i t t e n t r a n s f e r "
alias put = " k i t t y + k i t t e n t r a n s f e r - - d i r e c t i o n = u p l o a d "
alias kclip = " k i t t y + k i t t e n c l i p b o a r d "
fi
# Special aliases that may not work with Nix config
# Command line head / tail shortcuts
alias H = " | h e a d " ;
alias T = " | t a i l " ;
alias G = " | g r e p " ;
alias L = " | l e s s " ;
alias M = " | m o s t " ;
alias LL = " 2 > & 1 | l e s s " ;
alias CA = " 2 > & 1 | c a t - A " ;
alias NE = " 2 > / d e v / n u l l " ;
alias NUL = " > / d e v / n u l l 2 > & 1 " ;
alias P = " 2 > & 1 | p y g m e n t i z e - l p y t b " ;
if [ [ " ' ' ${ ZSH_PROFILE } " - eq 1 ] ] ; then
zprof
fi
'' ;
shellAliases = {
cat = " ${ pkgs . bat } / b i n / b a t - p " ;
# update = "sudo nixos-rebuild switch";
ls = " l s d " ;
# ls, the common ones I use a lot shortened for rapid fire usage
l = " l s - l F h " ; #size,show type,human readable
la = " l s - l A F h " ; #long list,show almost all,show type,human readable
lr = " l s - t R F h " ; #sorted by date,recursive,show type,human readable
lt = " l s - l t F h " ; #long list,sorted by date,show type,human readable
ll = " l s - l " ; #long list
ldot = " l s - l d . * " ;
lS = " l s - 1 F S s h " ;
lart = " l s - 1 F c a r t " ;
lrt = " l s - 1 F c r t " ;
grep = " g r e p - - c o l o r " ;
sgrep = " g r e p - R - n - H - C 5 - - e x c l u d e - d i r = { . g i t , . s v n , C V S } " ;
t = " t a i l - f " ;
dud = " d u - d 1 - h " ;
duf = " d u - s h * " ;
# fd="find . -type d -name";
ff = " f i n d . - t y p e f - n a m e " ;
h = " h i s t o r y " ;
hgrep = " f c - E l 0 | g r e p " ;
help = " m a n " ;
p = " p s - f " ;
sortnr = " s o r t - n - r " ;
unexport = " u n s e t " ;
# Use trash instead of rm if available
rm = " t r a s h " ;
cp = " c p - i " ;
mv = " m v - i " ;
cls = " c l e a r " ;
sshc = " s s h - c o n n e c t " ;
} ;
history = {
# ignoreAllDups = true;
path = " ${ config . xdg . cacheHome } / z h i s t o r y " ;
save = 10000 ;
size = 10000 ;
# share = true;
} ;
2024-10-18 14:14:58 +02:00
} ;
} ;
2024-10-18 14:49:12 +02:00
home . file = {
# ".zprofile".source = ./zprofile;
} ;
2024-10-18 14:14:58 +02:00
} ;
} ;
} ;
}