diff --git a/fish/conf.d/fisher.fish b/fish/conf.d/fisher.fish new file mode 100644 index 0000000..7249f30 --- /dev/null +++ b/fish/conf.d/fisher.fish @@ -0,0 +1,13 @@ +# https://github.com/jorgebucaran/fisher +set -g fisher_path ~/.config/fish/fisher +set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..-1] +set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..-1] +if not functions -q fisher + echo "Installing fish-shell package manager: $fisher_path/functions/fisher.fish" + curl -fsSL -o $fisher_path/functions/fisher.fish --create-dirs https://git.io/fisher + echo "Installing fish-shell packages..." + fish -c fisher +end +for file in $fisher_path/conf.d/*.fish + builtin source $file 2> /dev/null +end diff --git a/fish/conf.d/fzf.fish b/fish/conf.d/fzf.fish new file mode 100644 index 0000000..4261ff3 --- /dev/null +++ b/fish/conf.d/fzf.fish @@ -0,0 +1,8 @@ +# https://github.com/junegunn/fzf +set -gx FZF_DEFAULT_OPTS "--no-height --layout=reverse --multi" +set -gx FZF_DEFAULT_COMMAND "fd --type=file" +set -gx FZF_CTRL_T_COMMAND "fd --type=file --follow" +set -gx FZF_CTRL_T_OPTS "--ansi --preview 'bat --color=always {}'" +set -gx FZF_CTRL_R_OPTS "--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'" +set -gx FZF_ALT_C_COMMAND "fd --type=directory --follow" +set -gx FZF_ALT_C_OPTS "--preview 'tree -CL 1 {}'" diff --git a/fish/conf.d/nix.fish b/fish/conf.d/nix.fish new file mode 100644 index 0000000..573a364 --- /dev/null +++ b/fish/conf.d/nix.fish @@ -0,0 +1,19 @@ +# https://github.com/NixOS/nix +# +# If nix profile exists: +# - source the profile in bash +# - export the NIX_* variables in fish +# - add nix profile to PATH +# +if test -f ~/.nix-profile/etc/profile.d/nix.sh + for line in (bash -c 'source $0; for name in "${!NIX_@}"; do printf "%s=%s\n" "$name" "${!name}"; done' ~/.nix-profile/etc/profile.d/nix.sh) + set -gx (string split -m 1 = $line) + end + if functions -q fish_add_path + fish_add_path -gP ~/.nix-profile/bin + else + if not contains -- ~/.nix-profile/bin $PATH + set PATH ~/.nix-profile/bin $PATH 2>/dev/null + end + end +end diff --git a/fish/config.fish b/fish/config.fish index 75b89c3..f727873 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -7,43 +7,6 @@ if test -x /usr/libexec/java_home set -gx JAVA_HOME (/usr/libexec/java_home -v 1.8) end -# FZF (https://github.com/junegunn/fzf) -set -gx FZF_DEFAULT_OPTS "--no-height --layout=reverse --multi" -set -gx FZF_DEFAULT_COMMAND "fd --type=file" -set -gx FZF_CTRL_T_COMMAND "fd --type=file --follow" -set -gx FZF_CTRL_T_OPTS "--ansi --preview 'bat --color=always {}'" -set -gx FZF_CTRL_R_OPTS "--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'" -set -gx FZF_ALT_C_COMMAND "fd --type=directory --follow" -set -gx FZF_ALT_C_OPTS "--preview 'tree -CL 1 {}'" - -# Nix package manager -if test -f ~/.nix-profile/etc/profile.d/nix.sh - for line in (bash -c 'source $0; for name in "${!NIX_@}"; do printf "%s=%s\n" "$name" "${!name}"; done' ~/.nix-profile/etc/profile.d/nix.sh) - set -gx (string split -m 1 = $line) - end - if functions -q fish_add_path - fish_add_path -gP ~/.nix-profile/bin - else - if not contains -- ~/.nix-profile/bin $PATH - set PATH ~/.nix-profile/bin $PATH 2>/dev/null - end - end -end - -# Fish package manager -set -g fisher_path ~/.config/fish/fisher -set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..-1] -set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..-1] -if not functions -q fisher - echo "Installing fish-shell package manager: $fisher_path/functions/fisher.fish" - curl -fsSL -o $fisher_path/functions/fisher.fish --create-dirs https://git.io/fisher - echo "Installing fish-shell packages..." - fish -c fisher -end -for file in $fisher_path/conf.d/*.fish - builtin source $file 2> /dev/null -end - if status --is-interactive # Disable the default shell greeting set fish_greeting