diff --git a/.config/fish/completions/newrepo.fish b/.config/fish/completions/newrepo.fish new file mode 100644 index 00000000..e16ffb4a --- /dev/null +++ b/.config/fish/completions/newrepo.fish @@ -0,0 +1,7 @@ +complete -c newrepo -s h -l help -d 'Print help' +complete -c newrepo -s p -l private -d 'Set private visibility' +complete -c newrepo -s P -l public -d 'Set public visibility' +complete -c newrepo -s s -l srht -d 'Set sr.ht provider' +complete -c newrepo -s g -l github -d 'Set github provider' +complete -c newrepo -s a -l all -d 'Set all providers' +complete -c newrepo -s d -l description -d 'Set repo description' -r -f diff --git a/.config/fish/fish_plugins b/.config/fish/fish_plugins index 475c04a4..d9586a63 100644 --- a/.config/fish/fish_plugins +++ b/.config/fish/fish_plugins @@ -12,3 +12,4 @@ danhper/fish-ssh-agent ~ficd/jrnl.fish ~ficd/pb.fish meaningful-ooo/sponge +~ficd/newrepo.fish diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables index e9467e4e..6963c65e 100644 --- a/.config/fish/fish_variables +++ b/.config/fish/fish_variables @@ -7,6 +7,7 @@ SETUVAR Z_DATA_DIR:/home/fic/\x2elocal/share/z SETUVAR __fish_initialized:3800 SETUVAR _fisher__7E_ficd_2F_fisher_files:/home/fic/\x2econfig/fish/functions/fisher\x2efish\x1e/home/fic/\x2econfig/fish/completions/fisher\x2efish SETUVAR _fisher__7E_ficd_2F_jrnl_2E_fish_files:/home/fic/\x2econfig/fish/functions/jrnl\x2efish\x1e/home/fic/\x2econfig/fish/completions/jrnl\x2efish +SETUVAR _fisher__7E_ficd_2F_newrepo_2E_fish_files:/home/fic/\x2econfig/fish/functions/newrepo\x2efish\x1e/home/fic/\x2econfig/fish/completions/newrepo\x2efish SETUVAR _fisher__7E_ficd_2F_pb_2E_fish_files:/home/fic/\x2econfig/fish/functions/pb\x2efish SETUVAR _fisher__7E_ficd_2F_update_2E_fish_files:/home/fic/\x2econfig/fish/functions/update\x2efish\x1e/home/fic/\x2econfig/fish/completions/update\x2efish SETUVAR _fisher_danhper_2F_fish_2D_ssh_2D_agent_files:/home/fic/\x2econfig/fish/functions/__ssh_agent_is_started\x2efish\x1e/home/fic/\x2econfig/fish/functions/__ssh_agent_start\x2efish\x1e/home/fic/\x2econfig/fish/conf\x2ed/fish\x2dssh\x2dagent\x2efish @@ -18,7 +19,7 @@ SETUVAR _fisher_joseluisq_2F_gitnow_40_32_2E_31_32_2E_30__files:/home/fic/\x2eco SETUVAR _fisher_meaningful_2D_ooo_2F_sponge_files:/home/fic/\x2econfig/fish/functions/_sponge_clear_state\x2efish\x1e/home/fic/\x2econfig/fish/functions/_sponge_on_exit\x2efish\x1e/home/fic/\x2econfig/fish/functions/_sponge_on_postexec\x2efish\x1e/home/fic/\x2econfig/fish/functions/_sponge_on_preexec\x2efish\x1e/home/fic/\x2econfig/fish/functions/_sponge_on_prompt\x2efish\x1e/home/fic/\x2econfig/fish/functions/_sponge_remove_from_history\x2efish\x1e/home/fic/\x2econfig/fish/functions/sponge_filter_failed\x2efish\x1e/home/fic/\x2econfig/fish/functions/sponge_filter_matched\x2efish\x1e/home/fic/\x2econfig/fish/conf\x2ed/sponge\x2efish SETUVAR _fisher_nickeb96_2F_puffer_2D_fish_files:/home/fic/\x2econfig/fish/functions/_puffer_fish_expand_bang\x2efish\x1e/home/fic/\x2econfig/fish/functions/_puffer_fish_expand_dots\x2efish\x1e/home/fic/\x2econfig/fish/functions/_puffer_fish_expand_lastarg\x2efish\x1e/home/fic/\x2econfig/fish/conf\x2ed/puffer_fish_key_bindings\x2efish SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:/home/fic/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e/home/fic/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e/home/fic/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e/home/fic/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e/home/fic/\x2econfig/fish/completions/fzf_configure_bindings\x2efish -SETUVAR _fisher_plugins:patrickf1/fzf\x2efish\x1ejorgebucaran/replay\x2efish\x1ejorgebucaran/spark\x2efish\x1ejoseluisq/gitnow\x402\x2e12\x2e0\x1ejorgebucaran/autopair\x2efish\x1enickeb96/puffer\x2dfish\x1ewfxr/forgit\x1ejorgebucaran/nvm\x2efish\x1edanhper/fish\x2dssh\x2dagent\x1e\x7eficd/update\x2efish\x1e\x7eficd/fisher\x1e\x7eficd/jrnl\x2efish\x1e\x7eficd/pb\x2efish\x1emeaningful\x2dooo/sponge +SETUVAR _fisher_plugins:patrickf1/fzf\x2efish\x1ejorgebucaran/replay\x2efish\x1ejorgebucaran/spark\x2efish\x1ejoseluisq/gitnow\x402\x2e12\x2e0\x1ejorgebucaran/autopair\x2efish\x1enickeb96/puffer\x2dfish\x1ewfxr/forgit\x1ejorgebucaran/nvm\x2efish\x1edanhper/fish\x2dssh\x2dagent\x1e\x7eficd/update\x2efish\x1e\x7eficd/fisher\x1e\x7eficd/jrnl\x2efish\x1e\x7eficd/pb\x2efish\x1emeaningful\x2dooo/sponge\x1e\x7eficd/newrepo\x2efish SETUVAR _fisher_upgraded_to_4_4:\x1d SETUVAR _fisher_wfxr_2F_forgit_files:/home/fic/\x2econfig/fish/conf\x2ed/bin\x1e/home/fic/\x2econfig/fish/conf\x2ed/forgit\x2eplugin\x2efish\x1e/home/fic/\x2econfig/fish/completions/_git\x2dforgit\x1e/home/fic/\x2econfig/fish/completions/git\x2dforgit\x2ebash\x1e/home/fic/\x2econfig/fish/completions/git\x2dforgit\x2efish SETUVAR abbr_path:/home/fic/\x2econfig/fish/conf\x2ed/abbr\x2efish diff --git a/.config/fish/functions/newrepo.fish b/.config/fish/functions/newrepo.fish new file mode 100644 index 00000000..b84d1731 --- /dev/null +++ b/.config/fish/functions/newrepo.fish @@ -0,0 +1,65 @@ +function newrepo --description 'Create new repos on multiple providers' + argparse h/help p/private P/public s/srht g/github a/all d/description= -- $argv + function help + echo newrepo -- easily create sr.ht and github repos! + echo USAGE + echo \tnewrepo '[]' '[flags]' + echo FLAGS + echo \t-p/--private: set private + echo \t-P/--public: set public + echo \t-s/--srht: set srht provider + echo \t-g/--github: set github provider + echo \t-a/--all: set all providers + echo \t-d/--description '[]': set optional description + echo AUTHOR + echo \tDaniel Fichtinger '' + echo LICENSE + echo \tMIT + echo URL + echo \t'git.sr.ht/~ficd/newrepo.fish' + end + if set -lq _flag_h || test (count $argv) -eq 0 + help + return 0 + end + # check that some visibility is set + set -l errors + set -l visibility + if not set -lq _flag_p && not set -lq _flag_P + set -a errors 'Visibility must be either public or private!' + else if set -lq _flag_p && not set -lq _flag_P + set visibility private + else if not set -lq _flag_p && set -lq _flag_P + set visibility public + else + set -a errors 'Only one visibility can be set!' + end + # check that a provider is set + if not set -lq _flag_a && not set -lq _flag_s && not set -lq _flag_g + set -a errors 'Provider must be set!' + else if set -lq _flag_a && set -lq _flag_s || set -lq _flag_g + set -a errors 'provider: all must be alone!' + end + set -l name $argv[1] + if test (count $errors) -ne 0 + for i in $errors + echo ERROR: $i + end + help + return 1 + end + if set -lq _flag_s || set -lq _flag_a + set -l add + if set -lq _flag_d + set add --description "$_flag_d" + end + hut git create $name --visibility $visibility $add + end + if set -lq _flag_g || set -lq _flag_a + set -l add + if set -lq _flag_d + set add --description "$_flag_d" + end + gh repo create $name --disable-wiki "--$visibility" $add + end +end