set fish_greeting

# Plugins installation and configuration
# The fish_inclusion variable is used to avoid multiple inclusions of the plugins
# because of the fish configuration file being sourced every time fisher is called
# Everithing related to the plugins must be in the if block
if not set -q fish_inclusion

  set -U fish_inclusion 1

  function install_fisher_plugin
    set -l plugin_path $argv[1]
    set -l plugin_name $argv[2]

    if not test -e $plugin_path
      if test $plugin_name = "jorgebucaran/fisher"
        # Install Fisher
        curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install $plugin_name
      else
        fisher install $plugin_name
      end
    end
  end

  install_fisher_plugin ~/.config/fish/functions/fisher.fish jorgebucaran/fisher
  install_fisher_plugin ~/.config/fish/functions/theme_gruvbox.fish jomik/fish-gruvbox  # Gruvbox theme for bg and fg
  install_fisher_plugin ~/.config/fish/conf.d/gruvbox.fish sujaybokil/fish-gruvbox      # Gruvbox theme for syntax highlighting
  install_fisher_plugin ~/.config/fish/conf.d/autopair.fish jorgebucaran/autopair.fish
  install_fisher_plugin ~/.config/fish/conf.d/sponge.fish meaningful-ooo/sponge
  install_fisher_plugin ~/.config/fish/conf.d/abbr_tips.fish gazorby/fish-abbreviation-tips

  theme_gruvbox dark soft

  set sponge_regex_patterns '^\s+.*'
  set sponge_allow_previously_successful true

  set -eU fish_inclusion
end


# Set personal aliases 
# For a full list of active aliases, run `alias`.
alias ls='lsd'
alias ll='ls -alF'
alias rm='rip'
alias cat='bat'
alias grep='rg'
alias find='fd -H'
alias sed='sd'
alias c='clear'
alias prolog='~/.config/scryer-prolog/target/release/scryer-prolog'     # À remplacer par prolog='scryer-prolog'
alias csc='sudo cytech-site-change'
alias quit='exit'
alias compresse='echo "tar -cv [nomDuFichieràCompresser] -f [nomArchive].tar"'
alias maj='~/./miseajour.sh'
alias vi=(which vim)
alias vim='nvim'

# Set the Oh-My-Posh prompt
oh-my-posh init fish --config $HOME/.config/ohmyposh/prompt.json | source

# Allow zoxide to work and to replace cd
zoxide init --cmd cd fish | source
