nix the things

This commit is contained in:
Daniel Flanagan 2023-08-30 23:03:42 -05:00
parent 34bd7970b2
commit 5c98767fe0
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
10 changed files with 0 additions and 608 deletions

View File

@ -1,5 +0,0 @@
fish_*
completions
conf.d
functions

View File

@ -1,22 +0,0 @@
set -U fish_color_normal normal # default color
set -U fish_color_command white # base command being run (>ls< -la)
set -U fish_color_param white # command's parameters
set -U fish_color_end green # command delimiter/separators (; and &)
set -U fish_color_error red # color of errors
set -U fish_color_escape yellow # color of escape codes (\n, \x2d, etc.)
set -U fish_color_operator blue # expansion operators (~, *)
set -U fish_color_quote yellow # quoted expressions (ls >"/tmp/test dir"<)
set -U fish_color_redirection blue # redirection operators (|, >, etc.)
set -U fish_color_cancel 333 brblack # sigint (cancel current comment) at prompt (^C)
set -U fish_color_autosuggestion 666 brblack # as-you-type suggestions
set -U fish_color_match blue # matching parens and the like
set -U fish_color_search_match white\x1e\x2d\x2dbackground\x3d333 # selected pager item
set -U fish_color_selection blue # vi mode visual selection (only fg)
set -U fish_color_valid_path yellow # if an argument is a valid path (only -u?)
set -U fish_color_comment 666 brblack # comments like this one!
set -U fish_pager_color_completion white # main color for pager
set -U fish_pager_color_description magenta # color for meta description
set -U fish_pager_color_prefix blue # the string being completed
set -U fish_pager_color_progress white\x1e\x2d\x2dbackground\x3d333 # status indicator at the bottom
# set -U fish_pager_color_secondary \x2d\x2dbackground\x3d181818 # alternating rows

View File

@ -1,83 +0,0 @@
source (dirname (status --current-filename))/paths.fish
for s in $ENV_PATH/*/config.d.fish
source $s (dirname $s)
end
for f in vars colors functions
source $FISH_PATH/$f.fish
end
if has_command rtx
rtx activate fish | source
else if has_command brew && test -f (brew --prefix asdf)/libexec/asdf.fish
set --universal --export ASDF_DIR (brew --prefix asdf)
source (brew --prefix asdf)/libexec/asdf.fish
else if test -f $HOME/.asdf/asdf.fish
source $HOME/.asdf/asdf.fish
else if test -f /opt/asdf-vm/asdf.fish
source /opt/asdf-vm/asdf.fish
end
if test -f $HOME/.nix-profile/etc/profile.d/nix.fish
. $HOME/.nix-profile/etc/profile.d/nix.fish
end
if test -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
# for determinate systems install
set nix_profiles /nix/var/nix/profiles/default $HOME/.nix-profile
set --export --universal NIX_PROFILES "$nix_profiles"
if set -q NIX_SSL_CERT_FILE
:
else if test -e /etc/ssl/certs/ca-certificates.crt
set --export --universal NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
else
for p in (string split $NIX_PROFILES)
test -e $p/etc/ssl/certs/ca-bundle.crt && \
set --export --universal NIX_SSL_CERT_FILE $p/etc/ssl/certs/ca-bundle.crt
end
end
set --prepend --export --global fish_user_paths $HOME/.nix-profile/bin /nix/var/nix/profiles/default/bin
end
if has_command direnv
direnv hook fish | source
end
# everything after this is ONLY relevant to interactive shells
status --is-interactive || exit
if has_command nnn
source $DOTFILES_PATH/common/nnn/config.fish
end
for f in prompt key-bindings
source $FISH_PATH/$f.fish
end
if test -f /usr/share/password-store/extensions/otp.bash
source $FISH_PATH/pass-otp-completions.fish
end
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION enabled
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
test $PWD = $HOME && begin
cd $NICE_HOME || cd
end
# If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features
# Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij
if not set --query ZELLIJ && set --query FISH_START_ZELLIJ
# simulate auto attach
zellij attach -c
# simulate auto kill
kill $fish_pid
else if not set --query TMUX && set --query FISH_START_TMUX
tmux att -t default || tmux new -s default
end

View File

@ -1 +0,0 @@
/home/daniel/.home/.config/lytedev-dotfiles/common/fish

View File

@ -1,219 +0,0 @@
function has_command --wraps=command --description "Exits non-zero if the given command cannot be found"
command --quiet --search $argv[1]
end
alias ll 'ls -l'
alias la 'll --all'
alias lA 'la --all'
if has_command exa
alias ls 'exa --group-directories-first --classify'
alias l ls
alias tree 'ls --tree --level=3'
alias lt 'll --sort=modified'
alias lat 'la --sort=modified'
alias lc 'lt --sort=accessed'
alias lT 'lt --reverse'
alias lC 'lc --reverse'
alias lD 'la --only-dirs'
end
if has_command rm-improved
alias rm rm-improved
end
if has_command thefuck
thefuck --alias | source
alias f fuck
end
function scount --wraps=count --description "Silent count exits with a non-zero status if no arguments given to count"
count $argv > /dev/null
end
function d --wraps=cd --description "Quickly jump to NICE_HOME (or given relative or absolute path) and list files."
if scount $argv
cd $argv
else
cd $NICE_HOME
end
la
end
function c --wraps=cd --description "Quickly jump to a subdirectory of NICE_HOME (or just to NICE_HOME if none given)"
if scount $argv
cd $NICE_HOME && d $argv
else
d $NICE_HOME
end
end
alias cd.. "d .."
alias cdd "d $DOTFILES_PATH"
alias cde "d $XDG_CONFIG_HOME/lytedev-env"
alias cdc "d $XDG_CONFIG_HOME"
alias cdn "d $NOTES_PATH"
alias cdl "d $XDG_DOWNLOAD_DIR"
alias cdg "d $XDG_GAMES_DIR"
alias .. "d .."
alias ... "d ../.."
alias .... "d ../../.."
alias ..... "d ../../../.."
alias ...... "d ../../../../.."
alias ....... "d ../../../../../.."
alias ........ "d ../../../../../../.."
alias ......... "d ../../../../../../../.."
has_command tmux && alias t "tmux"
has_command zellij && begin; alias z "zellij"; alias j "zellij"; end
has_command rsync && alias rcp 'rsync -r -ah --progress'
has_command bat && alias cat bat
if has_command git
function g -w git
if scount $argv; git $argv
else; git status; end
end
end
if has_command docker
alias dlf "docker logs --tail=500 -f"
alias ctop "docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock quay.io/vektorlab/ctop:latest"
end
if has_command docker-compose
alias dclf "docker-compose logs --tail=500 -f"
end
if has_command weechat
function chat
set -l pass (pass config/weechat-passphrase | head -n 1)
env WEECHAT_PASSPHRASE=$pass weechat
end
end
if has_command rg
function rgl; rg --color always $argv | less -r; end
alias rg "rg --text"
alias gr "rg"
end
if has_command kubectl
alias k "kubectl"
alias kg "k get"
end
alias v $EDITOR
alias e $EDITOR
alias sv "sudo -E $EDITOR"
alias se sv
function ltl --wraps=ls --description "Echoes the name of the file most recently modified either in the current directory or in the given path"
set d $argv[1] .
set -l l ""
for f in $d[1]/*
if test -z $l; set l $f; continue; end
if command test $f -nt $l; and test ! -d $f
set l $f
end
end
echo $l
end
function ltld --wraps=ls --description "Echoes the name of the directory most recently modified either in the current directory or in the given path"
set d $argv[1] .
set -l l ""
for f in $d[1]/*
if test -z $l; set l $f; continue; end
if command test $f -nt $l; and test -d $f
set l $f
end
end
echo $l
end
alias vltl "$EDITOR (ltl)"
alias cdltl "cd (ltld)"
function p
set ip 8.8.8.8
set -q argv[1] && set ip $argv[1]
ping $ip $argv[2..]
end
function pp --description "Keeps trying to ping 8.8.8.8 forever"
while not ping -n 1 -w 5 8.8.8.8
sleep 1
end
end
alias C "clear; set -q TMUX && begin; has_command tmux && tmux clear-history; end || true"
if has_command systemctl
alias sctl "sudo systemctl"
alias sctlu "systemctl --user"
alias bt "sctl start bluetooth && sudo bluetoothctl"
alias btctl "bt"
end
alias resrc "source $XDG_CONFIG_HOME/fish/config.fish; fish_user_key_bindings"
has_command sc && alias scs "sc $NOTES_PATH/_scratch.sc"
alias dd "dd status=progress"
alias year 'cal (date +%Y)'
alias mount 'sudo -E mount'
alias umount 'sudo -E umount'
alias ip 'ip -color'
alias pt 'pass tessen'
has_command xdg-open && alias open xdg-open
has_command docker && begin
alias dc "docker compose"
alias dk "docker"
end
function fish_preexec
test -n $TMUX && begin
set envlist (tmux show-environment)
for var in DISPLAY WAYLAND_DISPLAY
set -gx $var (echo $envlist | rg '^'$var'=(.*)$' -r '$1')
end
end
end
# source:
# https://github.com/ivakyb/fish_ssh_agent/blob/master/functions/fish_ssh_agent.fish
function __ssh_agent_is_started -d "check if ssh agent is already started"
if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
source $SSH_ENV > /dev/null
end
if test -z "$SSH_AGENT_PID"
return 1
end
ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep -q ssh-agent
#pgrep ssh-agent
return $status
end
function __ssh_agent_start -d "start a new ssh agent"
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
chmod 600 $SSH_ENV
source $SSH_ENV > /dev/null
true # suppress errors from setenv, i.e. set -gx
end
if set --query KITTY_PID
alias kssh "kitty +kitten ssh"
end
function fish_ssh_agent --description "Start ssh-agent if not started yet, or uses already started ssh-agent."
if test -z "$SSH_ENV"
set -xg SSH_ENV $HOME/.ssh/environment
end
if not __ssh_agent_is_started
__ssh_agent_start
end
end

View File

@ -1,38 +0,0 @@
function fish_user_key_bindings
set --export SKIM_TMUX_HEIGHT ""
set --export --universal SKIM_ALT_C_COMMAND "fd --hidden --type directory"
set --export --universal SKIM_CTRL_T_COMMAND "fd --hidden"
command -q sk && begin
functions | grep skim_key_bindings &>/dev/null && skim_key_bindings
bind -M insert \cg skim-cd-widget
end
fish_vi_key_bindings insert --no-erase
set --universal fish_cursor_default block
set --universal fish_cursor_insert line
set --universal fish_cursor_block block
fish_vi_cursor
set --universal fish_vi_force_cursor 1
# bind "jk" from insert mode to return to normal mode
set normal_mode "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end"
bind -M insert jk $normal_mode
bind -M insert jK $normal_mode
bind -M insert Jk $normal_mode
bind -M insert JK $normal_mode
bind -M insert jj $normal_mode
bind -M insert jJ $normal_mode
bind -M insert Jj $normal_mode
bind -M insert JJ $normal_mode
bind -M insert \cp up-or-search
bind -M insert \cn down-or-search
bind -M insert \ce end-of-line
bind -M insert \ca beginning-of-line
bind -M insert \cv edit_command_buffer
bind -M default \cv edit_command_buffer
end

View File

@ -1,4 +0,0 @@
#!/usr/bin/env fish
complete -c pass -f -n '__fish_pass_needs_command' -a otp -d 'Command: show TOTP code'
complete -c pass -f -n '__fish_pass_uses_command otp' -s c -l clip -d 'Put TOTP code in clipboard'
complete -c pass -f -n '__fish_pass_uses_command otp' -a "(__fish_pass_print_entries)"

View File

@ -1,72 +0,0 @@
set --export --universal XDG_CONFIG_HOME $HOME/.config
set --export --universal XDG_CACHE_HOME $HOME/.cache
set --export --universal XDG_DATA_HOME $HOME/.local/share
set --export --universal XDG_STATE_HOME $HOME/.local/state
set --export --universal DOTFILES_PATH $XDG_CONFIG_HOME/lytedev-dotfiles
set --export --universal ENV_PATH $XDG_CONFIG_HOME/lytedev-env
set --export --universal FISH_PATH $XDG_CONFIG_HOME/fish
if not set --query NICE_HOME
# default NICE_HOME to HOME
set --export --universal NICE_HOME $HOME
# if HOME ends with a dir called .home, assume that NICE_HOME is HOME's parent dir
test (basename $HOME) = .home && set --export --universal NICE_HOME (realpath $HOME/..)
end
# reset paths on shell start
set --erase --global fish_user_paths
# add NICE_HOME to CDPATH (see `man 1 cd`)
set --erase CDPATH
set --export --global CDPATH . $NICE_HOME
set --export --universal GOPATH $HOME/.go
set --export --universal GOBIN $GOPATH/bin
set paths_candidates \
$HOME/.asdf/shims \
/opt/homebrew/bin \
/opt/homebrew/sbin \
$DOTFILES_PATH/common/bin \
$HOME/.bin \
$HOME/.local/bin \
$HOME/.deno/bin \
$HOME/.yarn/bin \
$HOME/.nimble/bin \
$HOME/.cargo/bin \
$HOME/.krew/bin \
$HOME/.go \
$GOPATH/bin \
$HOME/.netlify/helper/bin
# add candidate paths to PATH if they exist
for d in $paths_candidates $ENV_PATH/*/bin
test -d $d && set --append --export --global fish_user_paths $d
end
command --search --quiet python && \
set --append --export --global fish_user_paths (python -m site --user-base)/bin
command --search --quiet ruby && \
set --append --export --global fish_user_paths (ruby -e 'print Gem.user_dir')/bin
set --export --universal NOTES_PATH $NICE_HOME/doc/notes
set --export --universal SCROTS_PATH $NICE_HOME/img/scrots
set --export --universal USER_LOGS_PATH $NICE_HOME/doc/logs
set --export --universal XDG_DESKTOP_DIR $HOME/desktop
set --export --universal XDG_PUBLICSHARE_DIR $HOME/public
set --export --universal XDG_TEMPLATES_DIR $HOME/templates
set --export --universal XDG_DOCUMENTS_DIR $NICE_HOME/doc
set --export --universal XDG_DOWNLOAD_DIR $NICE_HOME/dl
set --export --universal XDG_MUSIC_DIR $NICE_HOME/music
set --export --universal XDG_PICTURES_DIR $NICE_HOME/img
set --export --universal XDG_VIDEOS_DIR $NICE_HOME/video
set --export --universal XDG_GAMES_DIR $NICE_HOME/games
set --export --universal NOTES_PATH $XDG_DOCUMENTS_DIR/notes
set --export --universal USER_LOGS_PATH $XDG_DOCUMENTS_DIR/logs
set --export --universal SCROTS_PATH $XDG_PICTURES_DIR/scrots

View File

@ -1,127 +0,0 @@
set MAX_PATH_PIECE_CHARS 3
function get_hostname
if test (uname) = Linux || test (uname) = Darwin
has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname
else
# assume bsd
hostname | head -n 1 | cut -d. -f1
end
end
function fish_greeting
_prompt_prefix
printf "%s\n" (date)
end
function preprocess_pwd
test (pwd) = / && echo "/" && return 1
test (pwd) = $NICE_HOME && echo "~" && return 0
pwd | cut -c2- | \
awk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.'$MAX_PATH_PIECE_CHARS[1]'s",p[i]}}}'
end
function _maybe_sudo_prefix
if set -q SUDO_USER
set_color -b yellow black
printf " SUDO "
set_color -b normal normal
printf " "
end
end
function _maybe_aws_profile
if set -q AWS_PROFILE && test $AWS_PROFILE = prd
printf " "
set_color -b yellow black
printf " AWS_PROFILE=prd "
set_color -b normal normal
end
end
function _user_and_host
if test $argv[1] -eq 0
set_color -b normal blue
else
set_color -b normal red
end
printf "%s@%s" $USER (get_hostname)
end
function _cur_work_dir
set_color -b normal magenta
printf " %s" (preprocess_pwd)
end
function _last_cmd_duration
set_color -b normal green
set -q CMD_DURATION && printf " %dms" $CMD_DURATION
end
function _maybe_jobs_summary
if jobs -q
set_color -b normal cyan
printf " &%d" (jobs -p | wc -l)
end
end
function _user_prompt
printf "\n"
set_color brblack
if test (id -u) -eq 0
printf '# '
else
printf '$ '
end
set_color -b normal normal
end
function _maybe_git_summary
set_color -b normal yellow
set cur_sha (git rev-parse --short HEAD 2>/dev/null)
if test $status = 0
set num_changes (git status --porcelain | wc -l | string trim)
if test $num_changes = 0
set num_changes "✔"
else
set num_changes "+$num_changes"
end
printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes
end
end
function _prompt_marker
printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c"
end
function _prompt_continuation_marker
printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c"
end
function cmd_marker --on-variable _
printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c"
end
function _prompt_prefix
set_color -b normal brblack
printf "# "
end
function fish_prompt
set last_cmd_status $status
_prompt_marker
_prompt_prefix
_maybe_sudo_prefix
_user_and_host $last_cmd_status
_cur_work_dir
_maybe_git_summary
_maybe_aws_profile
_last_cmd_duration
_maybe_jobs_summary
_user_prompt
end
function fish_mode_prompt; end
function fish_right_prompt
end

View File

@ -1,37 +0,0 @@
# sane ls colors
set --export --universal LS_COLORS 'ow=01;36;40'
set --export --universal EXA_COLORS '*=0'
# iex history
set --export --universal ERL_AFLAGS "-kernel shell_history enabled -kernel shell_history_file_bytes 1024000"
set --export --universal TERMINAL kitty
set --export --universal TERMINAL_ARGS '--single-instance'
set --export --universal BROWSER firefox
# TODO: use the text editor?
set --export --universal PAGER "less"
set --export --universal MANPAGER "less"
if command --search --quiet hx
set --export --universal EDITOR hx
set --export --universal VISUAL hx
alias helix hx
else if command --search --quiet helix
set --export --universal EDITOR helix
set --export --universal VISUAL helix
alias hx helix
else if command --search --quiet nvim
set --export --universal EDITOR nvim
set --export --universal VISUAL nvim
else if command --search --quiet vim
set --export --universal EDITOR vim
set --export --universal VISUAL vim
else if command --search --quiet vi
set --export --universal EDITOR vi
set --export --universal VISUAL vi
end
set --export --universal SOPS_AGE_KEY_FILE "$XDG_CONFIG_HOME/sops/age/keys.txt"
# has_command fd && set -Ux FZF_DEFAULT_COMMAND 'fd --type f --hidden --follow --exclude .git'