pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
{ config, pkgs, lib, isDarwin, ... }:
let
inherit (lib)
optionalAttrs
optionals;
in
{
home.packages = with pkgs; [
zsh-completions
];
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.keychain = {
enable = lib.mkIf pkgs.stdenv.isLinux true;
agents = [ "ssh" "gpg"];
keys = [ "id_rsa" "id_ed25519" "C171251002C200F2" ];
# extraFlags = [ "--quiet" "--ignore-missing" ];
};
programs.command-not-found.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
defaultKeymap = "emacs";
history = {
size = 100000;
save = 100000;
expireDuplicatesFirst = true;
};
profileExtra = ''
[[ -f ~/.nix-profile/etc/profile.d/nix.sh ]] && . ~/.nix-profile/etc/profile.d/nix.sh
path=(~/bin
~/.local/bin
~/go/bin/
$path)
'';
shellAliases = {
cp = "cp -iv";
mv = "mv -iv";
mkdir = "mkdir -v";
tree = "eza --tree";
pp = "pushbullet push \"Pixel\" link \"\${1}\" \"\${1}\"";
upgrade_emacs = "cp ~/.emacs.d/straight/versions/default.el ~/straight-versions-default-`date \"+%Y-%m-%d-%H%M%S\"`.el && emacs --batch -l \"~/.emacs.d/init.el\" -f \"my/upgrade-packages\"";
diff_emacs = "difft --color always --context 0 $(ls -d1v ~/straight-versions-default-*.el | tail -1) ~/.emacs.d/straight/versions/default.el | grep '\\[9[12]' | egrep -v '(gnu-elpa-mirror|nongnu-elpa|melpa|emacsmirror-mirror)'";
nix-up = "git -C ~/dotfiles pull && doas nix-channel --update && doas nixos-rebuild switch && nix-channel --update && home-manager switch && system-changes-report && hm-changes-report && df -h && date";
_nix-up = "doas nix-channel --update && doas nixos-rebuild switch && nix-channel --update && home-manager switch && system-changes-report && hm-changes-report && df -h && date";
home-up = "git -C ~/dotfiles pull && nix-channel --update && home-manager switch && hm-changes-report";
_home-up = "nix-channel --update && home-manager switch && hm-changes-report";
nix-hammer = "nix shell -f https://github.com/jtojnar/nixpkgs-hammering/archive/master.tar.gz -c nixpkgs-hammer";
fb = "fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'";
zz = "z $PWD";
els = "ea run linear ls -- -1";
erg = "ea run grouped rg --";
fd = "ea run linear fd --";
git-reset-branch = "git fetch && git reset --hard origin/\$(git branch --show-current)";
# Git log aliases from the omz git plugin
gl = "git pull";
glg = "git log --stat";
glgp = "git log --stat -p";
glgg = "git log --graph";
glgga = "git log --graph --decorate --all";
glgm = "git log --graph --max-count=10";
glo_ = "git log --oneline --decorate";
glol = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\"";
glols = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\" --stat";
glod = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\"";
glods = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\" --date=short";
glola = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\" --all";
glog = "git log --oneline --decorate --graph";
gloga = "git log --oneline --decorate --graph --all";
}
// optionalAttrs pkgs.stdenv.isDarwin {
oemacs = "open -a /Applications/Emacs.app";
};
localVariables = {
PER_DIRECTORY_HISTORY_TOGGLE = "^\\\\"; # ^\\ is ^#
HISTORY_START_WITH_GLOBAL = true;
ZSH_AUTOSUGGEST_STRATEGY = ["history" "completion"];
NVM_AUTO_USE = true;
NVM_LAZY_LOAD = true;
LSP_USE_PLISTS = true;
LESS = "-iRXF";
};
initExtraFirst = ''
[[ $TERM == "tramp" ]] && unsetopt zle && PS1='$ ' && return
'';
initExtra = ''
# Based on prezto tmux plugin
if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && (-z "$SSH_TTY" || -n "$TMUX_AUTO_ATTACH") ]]; then
tmux start-server
if ! tmux has-session 2> /dev/null; then
tmux new-session -d -s "0" \; set-option -t "0" destroy-unattached off &> /dev/null
fi
if [[ -n "$SSH_TTY" ]]; then
exec tmux -u attach-session
else
exec tmux -u attach-session -d
fi
fi
# Keep these in initExtra, rather than localVariables, because the order matters
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='rg --hidden --files --sort-files --null -g "!{.git,node_modules}/*" | xargs -0 dirname | sort -u'
export FZF_ALT_C_OPTS="--preview 'eza --tree {} | head -200'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind 'ctrl-t:toggle-preview'"
export FZF_DEFAULT_OPTS="--bind=ctrl-t:toggle-all --bind=ctrl-j:jump"
eval "$(batpipe)"
autopair-init
enable-fzf-tab
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# make home and end work
[[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]" beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
# disable sort when completing `git checkout`
zstyle ''\':completion:*:git-checkout:*''\' sort false
# set descriptions format to enable group support
zstyle ''\':completion:*:descriptions''\' format ''\'[%d]''\'
# Allow tab to expand aliases
zstyle ':completion:*' completer _expand_alias _complete _ignored
# set list-colors to enable filename colorizing
#zstyle ''\':completion:*''\' list-colors ''${(s.:.)LS_COLORS}
# preview directory''\'s content with eza when completing cd
zstyle ''\':fzf-tab:complete:cd:*''\' fzf-preview ''\'eza -1 --color=always ''$realpath''\'
# switch group using `,` and `.`
zstyle ''\':fzf-tab:*''\' switch-group ''\',''\' ''\'.''\'
set -o noclobber append_history share_history
# disable flow control (so that fzf-git.sh's ^g^s can work)
stty -ixon
function generate () { gopass generate -s -p $1 $((RANDOM % 14 + 45)) }
function fcd { cd $(fd -L --max-depth=''${1:-4} --type=d 2>/dev/null | fzf-tmux) }
fif() {
if [ ! "$#" -gt 0 ]; then
echo "usage: fif <SEARCH_TERM>"
return 1;
fi
rg --files-with-matches --no-messages "$1" | fzf $FZF_PREVIEW_WINDOW --preview "rg --ignore-case --pretty --context 10 '$1' {}"
}
fe() {
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ''${EDITOR:-vim} "''${files[@]}"
}
# TODO is there a way to do this in shellAliases
alias ..="cd .."
alias ...="cd ../.."
alias -- -="cd -"
.,() {
local declare dirs=()
get_parent_dirs() {
if [[ -d "''${1}" ]]; then dirs+=("$1"); else return; fi
if [[ "''${1}" == '/' ]]; then
for _dir in "''${dirs[@]}"; do echo $_dir; done
else
get_parent_dirs $(dirname "$1")
fi
}
local DIR=$(get_parent_dirs $(realpath "$PWD/..") | fzf-tmux)
cd "$DIR"
}
# From omz
function mkcd () {
mkdir -p $@ && cd ''${@:$#}
}
tre () { command tre "$@" -e && source "/tmp/tre_aliases_$USER" 2>/dev/null; }
function gcd () {
if [ $# -eq 0 ] ; then
echo "Number of days must be specified" >&2
return 1
fi
if ! [[ $1 =~ '^[0-9]+$' ]] ; then
echo "Number of days must be a number" >&2
return 2
fi
if [ $1 -eq 0 ] ; then
GC_ARGS=(-d)
else
GC_ARGS=(--delete-older-than ''${1}d)
fi
DOAS=$(command -v doas)
# Run as the current user (as well as root) to clean up hm generations
nix-collect-garbage ''${GC_ARGS[@]}
if [ -n $DOAS ] ; then
$DOAS nix-collect-garbage ''${GC_ARGS[@]}
fi
df -h
date
}
function checkout-pr () {
git fetch ''${2:-upstream} pull/''${1}/head:pr-''${1}
git switch pr-''${1}
}
[[ ! -f ~/.zsh.local ]] || source ~/.zsh.local
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
'';
plugins = with pkgs; [
{
name = "zsh-autopair";
src = zsh-autopair;
file = "share/zsh/zsh-autopair/autopair.zsh";
}
{
name = "zsh-bd";
src = zsh-bd;
file = "share/zsh-bd/bd.zsh";
}
{
name = "zsh-fzf-tab";
src = zsh-fzf-tab;
file = "share/fzf-tab/fzf-tab.zsh";
}
{
name = "zsh-fast-syntax-highlighting";
src = zsh-fast-syntax-highlighting;
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
{
name = "zsh-powerlevel10k";
src = zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "zsh-history-substring-search";
src = zsh-history-substring-search;
file = "share/zsh-history-substring-search/zsh-history-substring-search.zsh";
}
{
name = "zsh-forgit";
src = zsh-forgit;
file = "share/zsh/zsh-forgit/forgit.plugin.zsh";
}
{
name = "zsh-edit";
src = zsh-edit;
file = "share/zsh/zsh-edit/zsh-edit.plugin.zsh";
}
{
name = "fzf-git.sh";
src = fzf-git-sh;
file = "share/zsh/fzf-git-sh/fzf-git.sh";
}
{
name = "per-directory-history";
src = fetchFromGitHub {
owner = "jimhester";
repo = "per-directory-history";
rev = "0687bbfd736da566472a6d67c2b45c501b73d405";
sha256 = "7Z0qaDhgopKt9BDKSqdziw9jsVgiLLafs30wPPbz+oo=";
};
file = "per-directory-history.zsh";
}
]
++ optionals stdenv.isDarwin [
{
name = "zsh-nvm";
src = fetchFromGitHub {
owner = "lukechilds";
repo = "zsh-nvm";
rev = "23067bd9bb6eb6f4737a3ea90cb0cb5e85f61ba2";
sha256 = "Zwdi7bezMFKaIKYwsSftu3mJSFvadEWmY2hYnU1Kpu4=";
};
file = "zsh-nvm.plugin.zsh";
}
];
};
}
|