set -e fish_user_paths set -U fish_user_paths $HOME/apps/bin $HOME/.local/bin $HOME/Applications $HOME/.cabal/bin $HOME/.ghcup/bin $HOME/.deno/bin $fish_user_paths set -U EDITOR emacsclient -c --alternate-editor='' set -Ux PASSWORD_STORE_DIR $HOME/enc/keys/pass/ set -U PLANTUML_LIMIT_SIZE 16384 set -e SSH_AGENT_PID if not set -q gnupg_SSH_AUTH_SOCK_by or test $gnupg_SSH_AUTH_SOCK_by -ne $fish_pid set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket) end set fish_greeting set TERM "xterm-256color" set EDITOR "emacsclient -t -a ''" set VISUAL "emacsclient -c -a emacs" set QT_QPA_PLATFORMTHEME "qt6ct" set SSH_AUTH_SOCK $XDG_RUNTIME_DIR/ssh-agent.socket set GNUPGHOME "~/enc/keys/gnupg" set LEDGER_FILE "~/enc/org/hledger/2023.journal" function fish_user_key_bindings fish_default_key_bindings end set fish_color_normal brcyan set fish_color_autosuggestion '#7d7d7d' set fish_color_command brcyan set fish_color_error '#ff6c6b' set fish_color_param brcyan set -g spark_version 1.0.0 complete -xc spark -n __fish_use_subcommand -a --help -d "Show usage help" complete -xc spark -n __fish_use_subcommand -a --version -d "$spark_version" complete -xc spark -n __fish_use_subcommand -a --min -d "Minimum range value" complete -xc spark -n __fish_use_subcommand -a --max -d "Maximum range value" function spark -d "sparkline generator" if isatty switch "$argv" case {,-}-v{ersion,} echo "spark version $spark_version" case {,-}-h{elp,} echo "usage: spark [--min= --max=] Draw sparklines" echo "examples:" echo " spark 1 2 3 4" echo " seq 100 | sort -R | spark" echo " awk \\\$0=length spark.fish | spark" case \* echo $argv | spark $argv end return end command awk -v FS="[[:space:],]*" -v argv="$argv" ' BEGIN { min = match(argv, /--min=[0-9]+/) ? substr(argv, RSTART + 6, RLENGTH - 6) + 0 : "" max = match(argv, /--max=[0-9]+/) ? substr(argv, RSTART + 6, RLENGTH - 6) + 0 : "" } { for (i = j = 1; i <= NF; i++) { if ($i ~ /^--/) continue if ($i !~ /^-?[0-9]/) data[count + j++] = "" else { v = data[count + j++] = int($i) if (max == "" && min == "") max = min = v if (max < v) max = v if (min > v ) min = v } } count += j - 1 } END { n = split(min == max && max ? "▅ ▅" : "▁ ▂ ▃ ▄ ▅ ▆ ▇ █", blocks, " ") scale = (scale = int(256 * (max - min) / (n - 1))) ? scale : 1 for (i = 1; i <= count; i++) out = out (data[i] == "" ? " " : blocks[idx = int(256 * (data[i] - min) / scale) + 1]) print out } ' end function letters cat $argv | awk -vFS='' '{for(i=1;i<=NF;i++){ if($i~/[a-zA-Z]/) { w[tolower($i)]++} } }END{for(i in w) print i,w[i]}' | sort | cut -c 3- | spark | lolcat printf '%s\n' 'abcdefghijklmnopqrstuvwxyz' ' ' | lolcat end function commits git log --author="$argv" --format=format:%ad --date=short | uniq -c | awk '{print $1}' | spark | lolcat end function __history_previous_command switch (commandline -t) case "!" commandline -t $history[1]; commandline -f repaint case "*" commandline -i ! end end function __history_previous_command_arguments switch (commandline -t) case "!" commandline -t "" commandline -f history-token-search-backward case "*" commandline -i '$' end end if [ $fish_key_bindings = "fish_vi_key_bindings" ]; bind -Minsert ! __history_previous_command bind -Minsert '$' __history_previous_command_arguments else bind ! __history_previous_command bind '$' __history_previous_command_arguments end function backup --argument filename cp $filename $filename.bak end function copy set count (count $argv | tr -d \n) if test "$count" = 2; and test -d "$argv[1]" set from (echo $argv[1] | trim-right /) set to (echo $argv[2]) command cp -r $from $to else command cp $argv end end function coln while read -l input echo $input | awk '{print $'$argv[1]'}' end end function rown --argument index sed -n "$index p" end function skip --argument n tail +(math 1 + $n) end function take --argument number head -$number end function org-search -d "send a search string to org-mode" set -l output (/usr/bin/emacsclient -a "" -e "(message \"%s\" (mapconcat #'substring-no-properties \ (mapcar #'org-link-display-format \ (org-ql-query \ :select #'org-get-heading \ :from (org-agenda-files) \ :where (org-ql--query-string-to-sexp \"$argv\"))) \ \" \"))") printf $output end alias clear='/bin/clear; echo; echo; seq 1 (tput cols) | sort -R | spark | lolcat; echo; echo' alias doas="doas --" alias ..='cd ..' alias ...='cd ../..' alias .3='cd ../../..' alias .4='cd ../../../..' alias .5='cd ../../../../..' alias vim='nvim' alias ls='exa -al --color=always --group-directories-first' alias la='exa -a --color=always --group-directories-first' alias ll='exa -l --color=always --group-directories-first' alias lt='exa -aT --color=always --group-directories-first' alias l.='exa -a | egrep "^\."' alias pacsyu='sudo pacman -Syyu' alias parsua='paru -Sua --noconfirm' alias parsyu='paru -Syu --noconfirm --sudoloop' alias unlock='sudo rm /var/lib/pacman/db.lck' alias cleanup='sudo pacman -Rns (pacman -Qtdq)' alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist" alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist" alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist" alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist" alias grep='grep --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias cp="cp -i" alias mv='mv -i' alias df='df -h' alias free='free -m' alias psa="ps auxf" alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e" alias psmem='ps auxf | sort -nr -k 4' alias pscpu='ps auxf | sort -nr -k 3' alias merge='xrdb -merge ~/.Xresources' alias addup='git add -u' alias addall='git add .' alias branch='git branch' alias checkout='git checkout' alias clone='git clone' alias commit='git commit -m' alias fetch='git fetch' alias pull='git pull origin' alias push='git push origin' alias tag='git tag' alias newtag='git tag -a' alias jctl="journalctl -p 3 -xb" alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify" alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys" alias yta-aac="youtube-dl --extract-audio --audio-format aac " alias yta-best="youtube-dl --extract-audio --audio-format best " alias yta-flac="youtube-dl --extract-audio --audio-format flac " alias yta-m4a="youtube-dl --extract-audio --audio-format m4a " alias yta-mp3="youtube-dl --extract-audio --audio-format mp3 " alias yta-opus="youtube-dl --extract-audio --audio-format opus " alias yta-vorbis="youtube-dl --extract-audio --audio-format vorbis " alias yta-wav="youtube-dl --extract-audio --audio-format wav " alias ytv-best="youtube-dl -f bestvideo+bestaudio " alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'" alias tb="nc termbin.com 9999" alias tips="lbrynet txo spend --type=support --is_not_my_input --blocking" colorscript random starship init fish | source set -gx PATH "$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" function phil-fix-names perl-rename 'y/A-Z/a-z/' * && perl-rename 'y/ /-/' * end function polish setxkbmap -model pc104 -layout pl -option compose:rctrl end function greek setxkbmap -model pc104 -layout gr -option compose:rctrl end function vps ssh -p 2222 phil@46.38.232.163 -i ~/.ssh/id_ed25519_nopass end function vpssh sshfs phil@46.38.232.163:/srv/ ~/remote/vps-srv -p 2222 -o identityFile=~/.ssh/id_ed25519_nopass -o reconnect end function vpsshu fusermount3 -u ~/remote/vps-srv/ end