From 6eba57b25152d0d7e85ede98598485a64270de85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?As=C4=B1m=20Tahir?= Date: Fri, 20 Dec 2024 18:46:05 +0300 Subject: [PATCH] feat: add `ghcs` and `ghce` abbrs --- .editorconfig | 9 ++++ LICENSE | 21 +++++++++ README.md | 59 ++++++++++++++++++++++++ conf.d/github-copilot-cli.fish | 7 +++ functions/_github-copilot-cli.abbrs.fish | 4 ++ functions/_github-copilot-cli.init.fish | 4 ++ init.fish | 10 ++++ 7 files changed, 114 insertions(+) create mode 100644 .editorconfig create mode 100644 LICENSE create mode 100644 README.md create mode 100644 conf.d/github-copilot-cli.fish create mode 100644 functions/_github-copilot-cli.abbrs.fish create mode 100644 functions/_github-copilot-cli.init.fish create mode 100644 init.fish diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c87f4a9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +charset = utf-8 +end_of_line = lf +tab_width = 1 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4a91d84 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2025 Asim Tahir + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5638c81 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ + + + +### `github-copilot-cli.fish` + +> `GitHub Copilot CLI` plugin for [Oh My Fish][omf] and [Fisher][fisher], + +[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE) +[![Fish Shell v3.6.0](https://img.shields.io/badge/fish-v3.6.0-007EC7.svg?style=flat-square)](https://fishshell.com) +[![Oh My Fish Framework](https://img.shields.io/badge/Oh%20My%20Fish-Framework-007EC7.svg?style=flat-square)][omf] + +
+ +## Prerequisites + +- [GitHub CLI](https://cli.github.com/) installed and authenticated. +- [GitHub Copilot CLI extension](https://docs.github.com/en/copilot/managing-copilot/configure-personal-settings/installing-github-copilot-in-the-cli) installed. + +## Install + +[Oh My Fish][omf]: + +```fish +omf install https://github.com/Asim-Tahir/github-copilot-cli.fish +``` + +[Fisher][fisher]: + +```fish +fisher install Asim-Tahir/github-copilot-cli.fish +``` + +## Abbreviations Usage + +After installing the [`github-copilot-cli.fish`][repo] plugin, can inspect the abbreviations with the following command: + +```fish +abbr --show | grep ghcs +``` + +| Abbreviation | Command | +| ------------ | -------------------- | +| `ghcs` | `gh copilot suggest` | +| `ghce` | `gh copilot explain` | + +# Credit + +Base structure heavily inspired from [`jhillyerd/plugin-git`](https://github.com/jhillyerd/plugin-git). Thanks for the amazing plugin. + +# License + +[MIT][license] © [Asim Tahir][author] + +[author]: https://github.com/Asim-Tahir +[repo]: https://github.com/Asim-Tahir/github-copilot-cli.fish +[license]: https://opensource.org/licenses/MIT +[omf]: https://github.com/oh-my-fish/oh-my-fish +[fisher]: https://github.com/jorgebucaran/fisher +[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square diff --git a/conf.d/github-copilot-cli.fish b/conf.d/github-copilot-cli.fish new file mode 100644 index 0000000..1d141f6 --- /dev/null +++ b/conf.d/github-copilot-cli.fish @@ -0,0 +1,7 @@ +# Fisher initialization +# protected as omf also tries to run it. +set -q fisher_path; or set -l fisher_path $__fish_config_dir +if test -f $fisher_path/functions/_github-copilot-cli.init.fish + source $fisher_path/functions/_github-copilot-cli.init.fish + _github-copilot-cli.init +end diff --git a/functions/_github-copilot-cli.abbrs.fish b/functions/_github-copilot-cli.abbrs.fish new file mode 100644 index 0000000..9320df7 --- /dev/null +++ b/functions/_github-copilot-cli.abbrs.fish @@ -0,0 +1,4 @@ +function _github-copilot-cli.abbrs -d "Initialize GitHub Copilot Command Line Interface(CLI) abbreviations" + abbr -a -g ghcs gh copilot suggest + abbr -a -g ghce gh copilot explain +end diff --git a/functions/_github-copilot-cli.init.fish b/functions/_github-copilot-cli.init.fish new file mode 100644 index 0000000..d066c67 --- /dev/null +++ b/functions/_github-copilot-cli.init.fish @@ -0,0 +1,4 @@ +function _github-copilot-cli.init -d "Initialize GitHub Copilot Command Line Interface(CLI) plugin" + # Initialize GitHub Copilot CLI abbreviations + _github-copilot-cli.abbrs +end diff --git a/init.fish b/init.fish new file mode 100644 index 0000000..38152f2 --- /dev/null +++ b/init.fish @@ -0,0 +1,10 @@ +# Oh My Fish initialization +# $path is only defined for oh-my-fish. home-manager activates this plugin by +# adding the full path of functions/ to fish_function_path, and then sourcing +# init.fish, so let's skip sourcing _github-copilot-cli.init.fish before calling _github-copilot-cli.init. +set -l _github_copilot_cli_init_path "$path/functions/_github-copilot-cli.init.fish" +if [ -f "$_github_copilot_cli_init_path" ]; + source "$_github_copilot_cli_init_path" +end + +_github-copilot-cli.init \ No newline at end of file