diff --git a/dot_config/fish/conf.d/10-starship.fish b/dot_config/fish/conf.d/10-starship.fish index 459dc72..741ee3a 100644 --- a/dot_config/fish/conf.d/10-starship.fish +++ b/dot_config/fish/conf.d/10-starship.fish @@ -1,10 +1,12 @@ #!/usr/bin/env fish -function starship_transient_prompt_func - starship module character -end +if command -v starship &>/dev/null + function starship_transient_prompt_func + starship module character + end -if status is-interactive - starship init fish | source - enable_transience + if status is-interactive + starship init fish | source + enable_transience + end end diff --git a/dot_config/fish/conf.d/20-gpg.fish b/dot_config/fish/conf.d/20-gpg.fish index 870d96f..7511078 100644 --- a/dot_config/fish/conf.d/20-gpg.fish +++ b/dot_config/fish/conf.d/20-gpg.fish @@ -1,6 +1,6 @@ #!/usr/bin/env fish -if test "$(command -v gpgconf &>/dev/null)" +if command -v gpgconf &>/dev/null set -gx GPG_TTY (tty) gpgconf --launch gpg-agent end diff --git a/dot_config/fish/conf.d/30-chezmoi.fish b/dot_config/fish/conf.d/30-chezmoi.fish index 3ea2e97..23fb870 100644 --- a/dot_config/fish/conf.d/30-chezmoi.fish +++ b/dot_config/fish/conf.d/30-chezmoi.fish @@ -1,12 +1,14 @@ #!/usr/bin/env fish -abbr -a cz --position command chezmoi -abbr -a czap --position command "chezmoi apply" -abbr -a cza --position command "chezmoi add" -abbr -a czc --position command "chezmoi cd" -abbr -a cze --position command "chezmoi edit" -abbr -a czu --position command "chezmoi update" +if command -v chezmoi &>/dev/null + abbr -a cz --position command chezmoi + abbr -a czap --position command "chezmoi apply" + abbr -a cza --position command "chezmoi add" + abbr -a czc --position command "chezmoi cd" + abbr -a cze --position command "chezmoi edit" + abbr -a czu --position command "chezmoi update" -abbr -a czct --position command "chezmoi chattr +t" + abbr -a czct --position command "chezmoi chattr +t" -abbr -a czcm --position command 'git aa && git c -m "$(chezmoi generate git-commit-message)" && git p' + abbr -a czcm --position command 'git aa && git c -m "$(chezmoi generate git-commit-message)" && git p' +end diff --git a/dot_config/fish/conf.d/30-eza.fish b/dot_config/fish/conf.d/30-eza.fish index 2984fb0..b8da294 100644 --- a/dot_config/fish/conf.d/30-eza.fish +++ b/dot_config/fish/conf.d/30-eza.fish @@ -1,18 +1,20 @@ #!/usr/bin/env fish -function ls --wraps eza - eza --all --icons=auto --sort=name --group-directories-first $argv -end +if command -v eza &>/dev/null + function ls --wraps eza + eza --all --icons=auto --sort=name --group-directories-first $argv + end -function lst --wraps eza - ls --tree --color=always $argv -end + function lst --wraps eza + ls --tree --color=always $argv + end -function lsl --wraps eza - eza --all --icons=auto --sort=name --group-directories-first --grid --long \ - --git --header $argv -end + function lsl --wraps eza + eza --all --icons=auto --sort=name --group-directories-first --grid --long \ + --git --header $argv + end -function lslt --wraps eza - lsl --tree --color=always $argv + function lslt --wraps eza + lsl --tree --color=always $argv + end end diff --git a/dot_config/fish/conf.d/30-fzf.fish.tmpl b/dot_config/fish/conf.d/30-fzf.fish.tmpl index 5198ded..0f784de 100644 --- a/dot_config/fish/conf.d/30-fzf.fish.tmpl +++ b/dot_config/fish/conf.d/30-fzf.fish.tmpl @@ -1,8 +1,11 @@ #!/usr/bin/env fish -set -gx FZF_DEFAULT_CMD 'rg --files --hidden --glob "!.git"' +if command -v fzf &>/dev/null + if command -v rg &>/dev/null + set -gx FZF_DEFAULT_CMD 'rg --files --hidden --glob "!.git"' + end -set -gx FZF_DEFAULT_OPTS "\ + set -gx FZF_DEFAULT_OPTS "\ --margin=10%,5% \ --border=sharp \ --pointer=' ' \ @@ -14,6 +17,11 @@ set -gx FZF_DEFAULT_OPTS "\ --color=fg:{{ .drapeau.colors.base05 }},header:{{ .drapeau.colors.base08 }},info:{{ .drapeau.colors.base0E }},pointer:{{ .drapeau.colors.base06 }} \ --color=marker:{{ .drapeau.colors.base06 }},fg+:{{ .drapeau.colors.base05 }},prompt:{{ .drapeau.colors.base0E }},hl+:{{ .drapeau.colors.base08 }}" -# fzf.fish -set -g fzf_preview_dir_cmd eza --all --color=always --sort=name --group-directories-first -set -g fzf_diff_highlighter delta --paging=never --features=arctic-fox + # fzf.fish + if command -v eza &>/dev/null + set -g fzf_preview_dir_cmd eza --all --color=always --sort=name --group-directories-first + end + if command -v delta &>/dev/null + set -g fzf_diff_highlighter delta --paging=never --features=arctic-fox + end +end diff --git a/dot_config/fish/conf.d/30-git.fish b/dot_config/fish/conf.d/30-git.fish index e35b753..70f31a4 100644 --- a/dot_config/fish/conf.d/30-git.fish +++ b/dot_config/fish/conf.d/30-git.fish @@ -1,50 +1,52 @@ #!/usr/bin/env fish -abbr -a g --position command git +if command -v git &>/dev/null + abbr -a g --position command git -################################################################################ -# Functions # -################################################################################ + ############################################################################ + # Functions # + ############################################################################ -function git_develop_branch - command git rev-parse --git-dir &>/dev/null || return - set -l branch + function git_develop_branch + command git rev-parse --git-dir &>/dev/null || return + set -l branch - for branch in dev devel develop development - if command git show-ref -q --verify refs/heads/$branch - echo $branch - return 0 + for branch in dev devel develop development + if command git show-ref -q --verify refs/heads/$branch + echo $branch + return 0 + end end + + echo develop + return 1 end - echo develop - return 1 -end + function git_main_branch + command git rev-parse --git-dir &>/dev/null || return + set -l ref -function git_main_branch - command git rev-parse --git-dir &>/dev/null || return - set -l ref - - for ref in - refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master} - if command git show-ref -q --verify $ref - echo (basename $ref) - return 0 + for ref in + refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master} + if command git show-ref -q --verify $ref + echo (basename $ref) + return 0 + end end + + echo main + return 1 end - echo main - return 1 -end + function git_current_branch + set -l ref (git symbolic-ref --quiet HEAD 2>/dev/null) + set -l ret $status -function git_current_branch - set -l ref (git symbolic-ref --quiet HEAD 2>/dev/null) - set -l ret $status + if [ $ret -ne 0 ] + [ $ret -eq 128 ] && return # no git repo + set ref (git rev-parse --short HEAD 2>/dev/null) || return + end - if [ $ret -ne 0 ] - [ $ret -eq 128 ] && return # no git repo - set ref (git rev-parse --short HEAD 2>/dev/null) || return + echo (string replace "refs/heads/" "" $ref) end - - echo (string replace "refs/heads/" "" $ref) end diff --git a/dot_config/fish/conf.d/30-go.fish b/dot_config/fish/conf.d/30-go.fish index 4a52a0b..30f1439 100644 --- a/dot_config/fish/conf.d/30-go.fish +++ b/dot_config/fish/conf.d/30-go.fish @@ -1,3 +1,5 @@ #!/usr/bin/env fish -fish_add_path "$HOME/go/bin" +if command -v go &>/dev/null + fish_add_path "$HOME/go/bin" +end diff --git a/dot_config/fish/conf.d/30-journalctl.fish b/dot_config/fish/conf.d/30-journalctl.fish index 80459e4..099041d 100644 --- a/dot_config/fish/conf.d/30-journalctl.fish +++ b/dot_config/fish/conf.d/30-journalctl.fish @@ -1,4 +1,6 @@ #!/usr/bin/env fish -abbr -a jf --position command "sudo journalctl --follow --unit" -abbr -a je --position command "sudo journalctl --pager-end --unit" +if command -v journalctl &>/dev/null + abbr -a jf --position command "sudo journalctl --follow --unit" + abbr -a je --position command "sudo journalctl --pager-end --unit" +end diff --git a/dot_config/fish/conf.d/30-lazygit.fish.tmpl b/dot_config/fish/conf.d/30-lazygit.fish.tmpl index 7464788..2a46ceb 100644 --- a/dot_config/fish/conf.d/30-lazygit.fish.tmpl +++ b/dot_config/fish/conf.d/30-lazygit.fish.tmpl @@ -1,11 +1,13 @@ #!/usr/bin/env fish -function lzg --wraps=lazygit - {{ if eq .drapeau.colors.name "catppuccin" -}} - set -f configs "$XDG_CONFIG_HOME/lazygit/config.yml,$XDG_CONFIG_HOME/lazygit/{{ .drapeau.colors.name }}/themes-mergable/{{ .drapeau.colors.flavor }}/pink.yml" - {{ else -}} - set -f configs "$XDG_CONFIG_HOME/lazygit/config.yml" - {{ end -}} +if command -v lazygit &>/dev/null + function lzg --wraps=lazygit + {{ if eq .drapeau.colors.name "catppuccin" -}} + set -f configs "$XDG_CONFIG_HOME/lazygit/config.yml,$XDG_CONFIG_HOME/lazygit/{{ .drapeau.colors.name }}/themes-mergable/{{ .drapeau.colors.flavor }}/pink.yml" + {{ else -}} + set -f configs "$XDG_CONFIG_HOME/lazygit/config.yml" + {{ end -}} - lazygit --use-config-file="$configs" + lazygit --use-config-file="$configs" + end end diff --git a/dot_config/fish/conf.d/30-less.fish b/dot_config/fish/conf.d/30-less.fish index 79721a5..f2fdb59 100644 --- a/dot_config/fish/conf.d/30-less.fish +++ b/dot_config/fish/conf.d/30-less.fish @@ -1,19 +1,19 @@ #!/usr/bin/env fish -set -gx LESS -R +if command -v less &>/dev/null + set -gx LESS -R -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -abbr -a L --position anywhere --set-cursor "% | less" + abbr -a L --position anywhere --set-cursor "% | less" -function lessv - if ! command -v nvim &>/dev/null - return - end - - if test -e "/usr/share/nvim/runtime/macros/less.sh" - /usr/share/nvim/runtime/macros/less.sh $argv - else if test -e "/usr/local/share/nvim/runtime/macros/less.sh" - /usr/local/share/nvim/runtime/macros/less.sh $argv + if command -v nvim &>/dev/null + function lessv + if test -e "/usr/share/nvim/runtime/macros/less.sh" + /usr/share/nvim/runtime/macros/less.sh $argv + else if test -e "/usr/local/share/nvim/runtime/macros/less.sh" + /usr/local/share/nvim/runtime/macros/less.sh $argv + end + end end end diff --git a/dot_config/fish/conf.d/30-php.fish b/dot_config/fish/conf.d/30-php.fish index 07cf29c..3ad6958 100644 --- a/dot_config/fish/conf.d/30-php.fish +++ b/dot_config/fish/conf.d/30-php.fish @@ -1,7 +1,11 @@ #!/usr/bin/env fish -fish_add_path "$HOME/.config/composer/vendor/bin" +if command -v composer &>/dev/null + fish_add_path "$HOME/.config/composer/vendor/bin" +end -abbr -a p --position command php -abbr -a pa --position command "php artisan" -abbr -a a --position command "php artisan" +if command -v php &>/dev/null + abbr -a p --position command php + abbr -a pa --position command "php artisan" + abbr -a a --position command "php artisan" +end diff --git a/dot_config/fish/conf.d/30-polybar.fish b/dot_config/fish/conf.d/30-polybar.fish deleted file mode 100644 index 4d47e26..0000000 --- a/dot_config/fish/conf.d/30-polybar.fish +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env fish - -function polybar-start - "$HOME/.config/polybar/launch.sh" --colorblocks & -end diff --git a/dot_config/fish/conf.d/30-systemctl.fish b/dot_config/fish/conf.d/30-systemctl.fish index 5dcfa02..be08488 100644 --- a/dot_config/fish/conf.d/30-systemctl.fish +++ b/dot_config/fish/conf.d/30-systemctl.fish @@ -1,9 +1,11 @@ #!/usr/bin/env fish -abbr -a sctl --position command "sudo systemctl" -abbr -a sctls --position command "sudo systemctl status" -abbr -a sctle --position command "sudo systemctl enable --now" -abbr -a sctld --position command "sudo systemctl disable --now" -abbr -a sctlr --position command "sudo systemctl restart" -abbr -a sctlo --position command "sudo systemctl stop" -abbr -a sctla --position command "sudo systemctl start" +if command -v systemctl &>/dev/null + abbr -a sctl --position command "sudo systemctl" + abbr -a sctls --position command "sudo systemctl status" + abbr -a sctle --position command "sudo systemctl enable --now" + abbr -a sctld --position command "sudo systemctl disable --now" + abbr -a sctlr --position command "sudo systemctl restart" + abbr -a sctlo --position command "sudo systemctl stop" + abbr -a sctla --position command "sudo systemctl start" +end diff --git a/dot_config/fish/conf.d/30-volta.fish b/dot_config/fish/conf.d/30-volta.fish index e4dbf8a..5849774 100644 --- a/dot_config/fish/conf.d/30-volta.fish +++ b/dot_config/fish/conf.d/30-volta.fish @@ -1,5 +1,7 @@ #!/usr/bin/env fish -fish_add_path "$HOME/.volta/bin" +if command -v volta &>/dev/null + fish_add_path "$HOME/.volta/bin" -set -gx VOLTA_HOME "$HOME/.volta" + set -gx VOLTA_HOME "$HOME/.volta" +end diff --git a/dot_config/fish/conf.d/30-wget.fish b/dot_config/fish/conf.d/30-wget.fish index ebf8342..70973c8 100644 --- a/dot_config/fish/conf.d/30-wget.fish +++ b/dot_config/fish/conf.d/30-wget.fish @@ -1,7 +1,9 @@ #!/usr/bin/env fish -set -gx WGETRC "$XDG_CONFIG_HOME/wgetrc" +if command -v wget &>/dev/null + set -gx WGETRC "$XDG_CONFIG_HOME/wgetrc" -#function wget --wraps wget -# wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" $argv -#end + function wget --wraps wget + command wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" $argv + end +end diff --git a/dot_config/fish/conf.d/30-yay.fish b/dot_config/fish/conf.d/30-yay.fish index 1ac4b1f..aed8287 100644 --- a/dot_config/fish/conf.d/30-yay.fish +++ b/dot_config/fish/conf.d/30-yay.fish @@ -1,13 +1,15 @@ #!/usr/bin/env fish -abbr -a y --position command yay -abbr -a yi --position command "yay -S" -abbr -a yr --position command "yay -R" -abbr -a yc --position command "yay -Sc" -abbr -a yu --position command "yay -Syu" -abbr -a ys --position command "yay -Ss" -abbr -a ysi --position command "yay -Qs" +if command -v yay + abbr -a y --position command yay + abbr -a yi --position command "yay -S" + abbr -a yr --position command "yay -R" + abbr -a yc --position command "yay -Sc" + abbr -a yu --position command "yay -Syu" + abbr -a ys --position command "yay -Ss" + abbr -a ysi --position command "yay -Qs" -function yay-group-missing --argument-names group - comm -23 <(yay -Sg $group | awk '{print $2}' | sort) <(yay -Qq | sort) + function yay-group-missing --argument-names group + comm -23 <(yay -Sg $group | awk '{print $2}' | sort) <(yay -Qq | sort) + end end diff --git a/dot_config/fish/conf.d/encrypted_30-bitwarden.fish.asc b/dot_config/fish/conf.d/encrypted_30-bitwarden.fish.asc index 2caf665..aa3e47d 100644 --- a/dot_config/fish/conf.d/encrypted_30-bitwarden.fish.asc +++ b/dot_config/fish/conf.d/encrypted_30-bitwarden.fish.asc @@ -1,10 +1,10 @@ -----BEGIN PGP MESSAGE----- -jA0ECQMIvR4z836ZO3//0sApAakbVKnuKb9TrQatlObf0ORC/qcp6yLIL7vTuRLH -kCtX75AFRrcGlTDEPjpO261FNeoRLEZJZJ911UJgobJOOwr/yAgy4Blcf8m7NC9q -PyaJfS37+5TURWjpTmeNBCg/vyzF5IQX5lxurM524VVdl1NN0hFn1NlIrJ2OvNy+ -OnUrjtM+CWQuDvuK1RIt73A6SjXsuSIbKxSZji5HZRN9qv7Tdbmv8pKoDwtmU1ZH -8juNFv6IA6mA0UDgScUBY6u5lOTzbcnE/UV/tjuxeUjalzuGTB5xXnH5ggw50LcG -yKSpNivjBe8nmgY= -=yQ/O +jA0ECQMInwAQ3xxYOS7/0sAoAWRHbdhtTICBBJCFsnNIlSUNyhCXNgduEIcgss+m +6DpDROJbe2pA+yBSntZXNO0w3VnrCYWsvurl0rDY4KFglAl+2ALrN0/9YfecAbC4 +XtutfDkAu/u6V7eLKBgovXpz6Jdt2Vtey5mkANQpD9ET+TVjPCJBhTQeSjqR886p +hQf6glkbOJOLEh11o+IvM6L7wvHG9gh8mxSVEImn8Ypd5BrnqODxeIIkEiFzTU/N +TDpiUSvILNcHDzBuUqyuKWUzS//r4+cKW6jTlOR7W5HO899uywcQodwyq4bIGoi9 +12E7OpMEf5mu/Q== +=uySh -----END PGP MESSAGE----- diff --git a/dot_config/topgrade.d/01-commands.toml.tmpl b/dot_config/topgrade.d/01-commands.toml.tmpl index adaa1d6..e117c74 100644 --- a/dot_config/topgrade.d/01-commands.toml.tmpl +++ b/dot_config/topgrade.d/01-commands.toml.tmpl @@ -11,9 +11,3 @@ # Custom commands [commands] "Fish Shell Completions" = "fish_update_completions" -{{ if lookPath "yay" -}} -"Update package list" = "yay -Qeq > {{ joinPath .chezmoi.sourceDir "dot_config/packages/" .chezmoi.hostname }} && set_color green && printf '%s'  && set_color normal && printf '%s' ' done\n'" -{{ end -}} -{{if lookPath "brew" -}} -"Update Brewfile" = "brew bundle dump --describe --force --file={{ joinPath .chezmoi.sourceDir "dot_config/packages/Brewfile" }} && set_color green && printf '%s'  && set_color normal && printf '%s' ' done\n'" -{{ end -}}