aboutsummaryrefslogtreecommitdiff
path: root/.config/fish/config.fish
blob: 47dca4e01ac25d3207cccb980b6f910f6f72e608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
if not status is-interactive
    exit
end

# xdg
set -gx XDG_CONFIG_HOME "$HOME/.config"
set -gx XDG_CACHE_HOME "$HOME/.cache"
set -gx XDG_DATA_HOME "$HOME/.local/share"
set -gx XDG_STATE_HOME "$HOME/.local/state"

# fish
set -gx FISH_CFG $XDG_CONFIG_HOME/fish
set -g fish_greeting
set -gx LANG "en_US.UTF-8"

# home pollution fixes
set -gx CARGO_HOME "$XDG_DATA_HOME/cargo"
set -gx RUSTUP_HOME "$XDG_DATA_HOME/rustup"
set -gx GOPATH "$XDG_DATA_HOME/go"
set -gx GRADLE_USER_HOME "$XDG_DATA_HOME/gradle"
set -gx GTK2_RC_FILES "$XDG_CONFIG_HOME/gtk-2.0/gtkrc"
set -gx XCURSOR_PATH "/usr/share/icons:$XDG_DATA_HOME/icons"
set -gx LESSHISTFILE "$XDG_STATE_HOME/less/history"
set -gx NODE_REPL_HISTORY "$XDG_DATA_HOME/node_repl_history"
set -gx NPM_CONFIG_USERCONFIG "$XDG_CONFIG_HOME/npm/npmrc"
set -gx _JAVA_OPTIONS "-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java"
set -gx NUGET_PACKAGES "$XDG_CACHE_HOME/NuGetPackages"
set -gx PASSWORD_STORE_DIR "$XDG_DATA_HOME/pass"
set -gx PYTHONSTARTUP "/etc/python/pythonrc"
set -gx W3M_DIR "$XDG_DATA_HOME/w3m"
set -gx PNPM_HOME "$HOME/.local/share/pnpm"

# program
set -gx EDITOR "nvim"
set -gx MANPAGER "nvim +Man!"
set -gx MANWIDTH 999
set -gx PF_INFO "ascii title os wm editor shell kernel palette"
set -gx BAT_THEME "ansi"
set -gx LITE_SCALE 1.3
set -gx RANGER_LOAD_DEFAULT_RC "FALSE"
# set -gx MANPATH /usr/local/texlive/2023/texmf-dist/doc/man
set -gx INFOPATH /usr/local/texlive/2023/texmf-dist/doc/info

# $PATH
source $FISH_CFG/path.fish

# colors
source $FISH_CFG/colors.fish

# bindings
source $FISH_CFG/bindings.fish

# configs
source $FISH_CFG/done_cfg.fish

# secrets
source $FISH_CFG/secret.fish

# abbreviations & aliases
abbr -a paru paru --limit 10
abbr -a projects cd ~/Documents/RealProjects
abbr -a gc git commit -m
abbr -a ga git add
abbr -a gcl git clone
abbr -a pq pacman -Qqi
abbr -a gt git log --oneline --graph --decorate --all
alias imgcat="wezterm imgcat"
alias dots="git --git-dir=$HOME/.dots --work-tree=$HOME"
# alias sudo="doas"
alias ls="ls --color=auto"
alias grep="grep -P --color=always"
alias wget="wget --hsts-file=$XDG_DATA_HOME/wget-hsts"
alias stylua="stylua -s"
alias cd="z"
alias n="nvim ."
function y
	set tmp (mktemp -t "yazi-cwd.XXXXXX")
	yazi $argv --cwd-file="$tmp"
	if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
		builtin cd -- "$cwd"
	end
	rm -f -- "$tmp"
end
function ssh 
    export TERM=xterm-color
    /usr/bin/ssh $argv
    export TERM=xterm-256color
end
function flac_preview
    nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=hd720 -f image2 pipe: | psub)
    # nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=2k -f image2 pipe: | psub)
end
function multicd
    echo (string repeat -n (math (string length -- $argv[1]) - 1) ../)
end
abbr -a dotdot --regex '^\.\.+$' --position anywhere --function multicd
function last_history_item
    echo $history[1]
end
function post_exec_line --on-event fish_postexec
    if not string match -qr "^clear" $argv[1]
        echo ""
    end
end
abbr -a !! --position anywhere --function last_history_item

# shell init
fish_ssh_agent
starship init fish | source
zoxide init fish | source
direnv hook fish | source

function dl
    yt-dlp -v --download-archive "archive.txt" \
        --write-info-json --write-thumbnail --embed-thumbnail --embed-metadata \
        --write-subs --sub-langs all --sub-format=srv3 \
        --merge-output-format "mkv" -f "bestvideo[height<=1080][width<=1920]+bestaudio" \
        --abort-on-error -o "files/%(extractor_key)s%(id)s/item.%(ext)s" \
        --extractor-args "youtube:player-client=default,mweb" $argv
end

function archive_website
    wget \
    # Download the whole site.
    --recursive \
    # Get all assets/elements (CSS/JS/images).
    --page-requisites \
    # Save files with .html on the end.
    --adjust-extension \
    # Include necessary assets from offsite as well.
    --span-hosts \
    # Update links to still work in the static version.
    --convert-links \
    # Modify filenames to work in Windows as well.
    --restrict-file-names=windows \
    # Do not follow links outside this domain.
    --domains yoursite.com \
    # Don't follow links outside the directory you pass in.
    --no-parent \
    $argv # The URL to download
end