From 7f2634e3303e011b2a482936cd031e49b5fd9068 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 16 Sep 2024 15:12:11 +0200 Subject: [PATCH] Add fisher plugins Todo: Add templates for ssh-agent --- .chezmoiignore | 2 + dot_config/fish/conf.d/fish-ssh-agent.fish | 7 +++ dot_config/fish/fish_plugins | 4 +- dot_config/fish/fish_variables | 62 +++++++++++++++++++ .../functions/__ssh_agent_is_started.fish | 14 +++++ .../fish/functions/__ssh_agent_start.fish | 5 ++ dot_config/fish/functions/fisher.fish | 6 +- dot_config/fish/themes/.keep | 0 8 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 dot_config/fish/conf.d/fish-ssh-agent.fish create mode 100644 dot_config/fish/fish_variables create mode 100644 dot_config/fish/functions/__ssh_agent_is_started.fish create mode 100644 dot_config/fish/functions/__ssh_agent_start.fish create mode 100644 dot_config/fish/themes/.keep diff --git a/.chezmoiignore b/.chezmoiignore index 8f37934..49ad22c 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -24,4 +24,6 @@ LICENSE .config/nvim/lua/plugins/telescope.lua .config/nvim/lua/plugins/core.lua .config/nvim/lua/plugins/disabled.lua +.config/fish/conf.d/fish-ssh-agent.fish +.config/fish/functions/__ssh_agent_* {{ end }} diff --git a/dot_config/fish/conf.d/fish-ssh-agent.fish b/dot_config/fish/conf.d/fish-ssh-agent.fish new file mode 100644 index 0000000..719087a --- /dev/null +++ b/dot_config/fish/conf.d/fish-ssh-agent.fish @@ -0,0 +1,7 @@ +if test -z "$SSH_ENV" + set -xg SSH_ENV $HOME/.ssh/environment +end + +if not __ssh_agent_is_started + __ssh_agent_start +end diff --git a/dot_config/fish/fish_plugins b/dot_config/fish/fish_plugins index 159007b..3cf61bf 100644 --- a/dot_config/fish/fish_plugins +++ b/dot_config/fish/fish_plugins @@ -1,4 +1,4 @@ -jorgebucaran/fisher +danhper/fish-ssh-agent plttn/fish-eza patrickf1/fzf.fish -danhper/fish-ssh-agent +jorgebucaran/fisher diff --git a/dot_config/fish/fish_variables b/dot_config/fish/fish_variables new file mode 100644 index 0000000..3d87168 --- /dev/null +++ b/dot_config/fish/fish_variables @@ -0,0 +1,62 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR --export EZA_LAAD_OPTIONS:\x2d\x2dall\x1e\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LAAID_OPTIONS:\x2d\x2dall\x1e\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2dicons\x1e\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LAAI_OPTIONS:\x2d\x2dall\x1e\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2dicons +SETUVAR --export EZA_LAA_OPTIONS:\x2d\x2dall\x1e\x2d\x2dall\x1e\x2d\x2dbinary +SETUVAR --export EZA_LAD_OPTIONS:\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LAID_OPTIONS:\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2dicons\x1e\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LAI_OPTIONS:\x2d\x2dall\x1e\x2d\x2dbinary\x1e\x2d\x2dicons +SETUVAR --export EZA_LA_OPTIONS:\x2d\x2dall\x1e\x2d\x2dbinary +SETUVAR --export EZA_LC_OPTIONS:\x2d\x2dacross +SETUVAR --export EZA_LD_OPTIONS:\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LE_OPTIONS:\x2d\x2dextended\x1e\x2d\x2dlong +SETUVAR --export EZA_LG_OPTIONS:\x2d\x2dgit\x1e\x2d\x2dgit\x2dignore\x1e\x2d\x2dlong +SETUVAR --export EZA_LID_OPTIONS:\x2d\x2dicons\x1e\x2d\x2donly\x2ddirs +SETUVAR --export EZA_LI_OPTIONS:\x2d\x2dicons +SETUVAR --export EZA_LL_OPTIONS:\x2d\x2dlong +SETUVAR --export EZA_LO_OPTIONS:\x2d\x2doneline +SETUVAR --export EZA_LT_OPTIONS:\x2d\x2dtree\x1e\x2d\x2dlevel +SETUVAR --export EZA_L_OPTIONS:\x1d +SETUVAR --export EZA_STANDARD_OPTIONS:\x2d\x2dgroup\x1e\x2d\x2dheader\x1e\x2d\x2dgroup\x2ddirectories\x2dfirst +SETUVAR --export __FISH_EZA_ALIASES:l\x1ela\x1eld\x1eli\x1elid\x1elaa\x1elad\x1elai\x1elaid\x1elaad\x1elaai\x1elaaid\x1ell\x1ella\x1elld\x1elli\x1ellid\x1ellaa\x1ellad\x1ellai\x1ellaid\x1ellaad\x1ellaai\x1ellaaid\x1elg\x1elga\x1elgd\x1elgi\x1elgid\x1elgaa\x1elgad\x1elgai\x1elgaid\x1elgaad\x1elgaai\x1elgaaid\x1ele\x1elea\x1eled\x1elei\x1eleid\x1eleaa\x1elead\x1eleai\x1eleaid\x1eleaad\x1eleaai\x1eleaaid\x1elt\x1elta\x1eltd\x1elti\x1eltid\x1eltad\x1eltai\x1eltaid\x1eltaad\x1eltaai\x1eltaaid\x1elc\x1elca\x1elcd\x1elci\x1elcid\x1elcaa\x1elcad\x1elcai\x1elcaid\x1elcaad\x1elcaai\x1elcaaid\x1elo\x1eloa\x1elod\x1eloi\x1eloid\x1eloaa\x1eload\x1eloai\x1eloaid\x1eloaad\x1eloaai\x1eloaaid +SETUVAR --export __FISH_EZA_BASE_ALIASES:l\x1ell\x1elg\x1ele\x1elt\x1elc\x1elo +SETUVAR --export __FISH_EZA_EXPANDED:a\x1ed\x1ei\x1eid\x1eaa\x1ead\x1eai\x1eaid\x1eaad\x1eaai\x1eaaid +SETUVAR --export __FISH_EZA_EXPANDED_OPT_NAME:LA\x1eLD\x1eLI\x1eLID\x1eLAA\x1eLAD\x1eLAI\x1eLAID\x1eLAAD\x1eLAAI\x1eLAAID +SETUVAR --export __FISH_EZA_OPT_NAMES:EZA_L_OPTIONS\x1eEZA_LA_OPTIONS\x1eEZA_LD_OPTIONS\x1eEZA_LI_OPTIONS\x1eEZA_LID_OPTIONS\x1eEZA_LAA_OPTIONS\x1eEZA_LAD_OPTIONS\x1eEZA_LAI_OPTIONS\x1eEZA_LAID_OPTIONS\x1eEZA_LAAD_OPTIONS\x1eEZA_LAAI_OPTIONS\x1eEZA_LAAID_OPTIONS\x1eEZA_LL_OPTIONS\x1eEZA_LG_OPTIONS\x1eEZA_LE_OPTIONS\x1eEZA_LT_OPTIONS\x1eEZA_LC_OPTIONS\x1eEZA_LO_OPTIONS +SETUVAR --export __FISH_EZA_SORT_OPTIONS:name\x1e\x2ename\x1esize\x1eext\x1emod\x1eold\x1eacc\x1ecr\x1einode +SETUVAR __fish_initialized:3400 +SETUVAR _fisher_danhper_2F_fish_2D_ssh_2D_agent_files:\x7e/\x2econfig/fish/functions/__ssh_agent_is_started\x2efish\x1e\x7e/\x2econfig/fish/functions/__ssh_agent_start\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fish\x2dssh\x2dagent\x2efish +SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish +SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish +SETUVAR _fisher_plttn_2F_fish_2D_eza_files:\x7e/\x2econfig/fish/functions/eza_git\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fish\x2deza\x2efish +SETUVAR _fisher_plugins:danhper/fish\x2dssh\x2dagent\x1eplttn/fish\x2deza\x1epatrickf1/fzf\x2efish\x1ejorgebucaran/fisher +SETUVAR _fisher_upgraded_to_4_4:\x1d +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:green +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:brcyan +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:brcyan +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_greeting:\x1d +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:yellow\x1e\x2di +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_selected_background:\x2dr diff --git a/dot_config/fish/functions/__ssh_agent_is_started.fish b/dot_config/fish/functions/__ssh_agent_is_started.fish new file mode 100644 index 0000000..7d481ee --- /dev/null +++ b/dot_config/fish/functions/__ssh_agent_is_started.fish @@ -0,0 +1,14 @@ +function __ssh_agent_is_started -d "check if ssh agent is already started" + if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end + source $SSH_ENV > /dev/null + end + + if begin; test -z "$SSH_AGENT_PID"; and test -z "$SSH_CONNECTION"; end + return 1 + end + + ssh-add -l > /dev/null 2>&1 + if test $status -eq 2 + return 1 + end +end diff --git a/dot_config/fish/functions/__ssh_agent_start.fish b/dot_config/fish/functions/__ssh_agent_start.fish new file mode 100644 index 0000000..3766fe4 --- /dev/null +++ b/dot_config/fish/functions/__ssh_agent_start.fish @@ -0,0 +1,5 @@ +function __ssh_agent_start -d "start a new ssh agent" + ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV + chmod 600 $SSH_ENV + source $SSH_ENV > /dev/null +end diff --git a/dot_config/fish/functions/fisher.fish b/dot_config/fish/functions/fisher.fish index b1513d3..e915cb8 100644 --- a/dot_config/fish/functions/fisher.fish +++ b/dot_config/fish/functions/fisher.fish @@ -1,6 +1,6 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" set --query fisher_path || set --local fisher_path $__fish_config_dir - set --local fisher_version 4.4.4 + set --local fisher_version 4.4.5 set --local fish_plugins $__fish_config_dir/fish_plugins switch "$cmd" @@ -29,7 +29,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" set --local old_plugins $_fisher_plugins set --local new_plugins - test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins) + test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | string replace -- \~ ~) if ! set --query argv[2] if test "$cmd" != update @@ -206,7 +206,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin end - printf "%s\n" $commit_plugins >$fish_plugins + string replace --regex -- $HOME \~ $commit_plugins >$fish_plugins else set --erase _fisher_plugins command rm -f $fish_plugins diff --git a/dot_config/fish/themes/.keep b/dot_config/fish/themes/.keep new file mode 100644 index 0000000..e69de29