dot/.config/fish/config.fish

269 lines
7.9 KiB
Fish
Raw Normal View History

2023-04-15 17:20:42 +02:00
set -e fish_user_paths
set -U fish_user_paths $HOME/.local/bin $HOME/Applications $HOME/.cabal/bin $HOME/.ghcup/bin $fish_user_paths
2023-08-12 16:45:26 +02:00
set fish_greeting
set TERM "xterm-256color"
set EDITOR "emacsclient -t -a ''"
set VISUAL "emacsclient -c -a emacs"
2023-08-02 13:47:58 +02:00
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"
2023-04-15 17:20:42 +02:00
function fish_user_key_bindings
2023-08-12 16:45:26 +02:00
fish_default_key_bindings
2023-04-15 17:20:42 +02:00
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=<n> --max=<n>] <numbers...> 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
2023-08-12 16:45:26 +02:00
2023-04-15 17:20:42 +02:00
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'
2023-08-12 16:45:26 +02:00
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'
2023-04-15 17:20:42 +02:00
alias l.='exa -a | egrep "^\."'
2023-08-12 16:45:26 +02:00
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)'
2023-04-15 17:20:42 +02:00
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'
2023-08-12 16:45:26 +02:00
alias df='df -h'
alias free='free -m'
2023-04-15 17:20:42 +02:00
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"
2023-08-12 16:45:26 +02:00
2023-04-15 17:20:42 +02:00
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 config="/usr/bin/git --git-dir=$HOME/git/dot --work-tree=$HOME"
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 vps
ssh -p 2222 phil@46.38.232.163 -i ~/.ssh/id_ed25519_nopass
end
function vpssh
2023-08-13 02:36:33 +02:00
sshfs phil@46.38.232.163:/srv/ ~/remote/vps-srv -p 2222 -o identityFile=~/.ssh/id_ed25519_nopass -o reconnect
end
function vpsshu
2023-08-13 02:36:33 +02:00
fusermount3 -u ~/remote/vps-srv/
end