set fish_greeting ""

function filesize
	for file in $argv
		if [ -f "$file" ]
			echo "$file: $(stat -c %s "$file" | numfmt --to=iec)"
		else
			echo "$file: not found"
		end
	end
end

function _fetch
  # if which pfetch > /dev/null 2>&1 && [ "$VSCODE_INJECTION" != "1" ]
  #   export PF_INFO="ascii title os host kernel uptime memory de"
  #   #export PF_ASCII="arch"
  #   pfetch
  # end
  if which ufetch > /dev/null 2>&1 && [ "$VSCODE_INJECTION" != "1" ]
    ufetch
  end
end

if which pyenv > /dev/null 2>&1
	pyenv init - | source
end

if [ "$TERM" = "foot" ] || [ "$TERM" = "xterm-kitty" ]
	alias ssh="TERM=xterm-256color $(which ssh)"
	alias gg="TERM=xterm-256color $(which gg)"
end

if status is-interactive
	bind \cl 'clear; _fetch; commandline -f repaint'
	bind \cb btop
	bind \cs 'source ~/.config/fish/config.fish'

	if which eza > /dev/null 2>&1
		alias ls="eza --icons=auto"
	else
		alias ls="exa --icons=auto"
	end

	if which bat > /dev/null 2>&1
		alias cat="bat"
 	else if which batcat > /dev/null 2>&1
		alias cat="batcat"
	end

  if which nvim > /dev/null 2>&1
    alias v="nvim"
    alias edit="nvim"
    alias e="nvim"
    alias V="sudoedit"
    export EDITOR=nvim
  end
	
	if which zoxide > /dev/null 2>&1
		zoxide init --cmd cd fish | source
	end

	if [ "$reload" = "" ]
    _fetch
	end
  
  alias :q="exit"
	set reload "done"
end