Created pip package
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
demos/
|
demos/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
build/
|
||||||
|
CopilotTerminal.egg-info
|
||||||
22
copilot.py
22
copilot.py
@@ -4,6 +4,8 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
# get a new github copilot token
|
# get a new github copilot token
|
||||||
def get_token():
|
def get_token():
|
||||||
@@ -105,14 +107,14 @@ def get_suggestion(prompt, token):
|
|||||||
|
|
||||||
return "Command not found"
|
return "Command not found"
|
||||||
|
|
||||||
# cursor_position_char = int(sys.argv[1])
|
@click.group()
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
# Read the input prompt from stdin.
|
@main.command()
|
||||||
# buffer = sys.stdin.read()
|
@click.argument('prompt', nargs=-1)
|
||||||
buffer = 'change python version to 3.10'
|
def generate_suggestion(prompt):
|
||||||
|
prompt = " ".join(prompt)
|
||||||
# ---
|
prompt = "!/bin/bash\n\n" + prompt + ":\n"
|
||||||
prompt_prefix = "!/bin/bash\n\n" + buffer + ":\n"
|
token = get_token()
|
||||||
|
print(get_suggestion(prompt, token))
|
||||||
token = get_token()
|
|
||||||
print(get_suggestion(prompt_prefix, token))
|
|
||||||
22
setup.py
Normal file
22
setup.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
from setuptools.command.install import install
|
||||||
|
import os
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='CopilotTerminal',
|
||||||
|
version='0.1.0',
|
||||||
|
description='zsh plugin to use copilot command predictions in the terminal',
|
||||||
|
author='Victor Mylle',
|
||||||
|
author_email='victor.mylle@hotmail.com',
|
||||||
|
license='MIT',
|
||||||
|
py_modules=['copilot'],
|
||||||
|
install_requires=[
|
||||||
|
'requests',
|
||||||
|
'click',
|
||||||
|
],
|
||||||
|
entry_points='''
|
||||||
|
[console_scripts]
|
||||||
|
ct=copilot:generate_suggestion
|
||||||
|
''',
|
||||||
|
|
||||||
|
)
|
||||||
@@ -1 +1 @@
|
|||||||
{"expires_at": 1669911119, "public_suggestions": "disabled", "refresh_in": 1500, "sku": "free_educational", "telemetry": "disabled", "token": "tid=d47460691ef58366f713e508d59d807b;exp=1669911119;sku=free_educational:ecb129f512a32bd216e89485725dc7a8edae9d8930ab38c05c0e14022af4903e", "tracking_id": "d47460691ef58366f713e508d59d807b"}
|
{"expires_at": 1669917293, "public_suggestions": "disabled", "refresh_in": 1500, "sku": "free_educational", "telemetry": "disabled", "token": "tid=d47460691ef58366f713e508d59d807b;exp=1669917293;sku=free_educational:f9553e702e2a159aa3459e09a3b0b2c0ca83a11c4042ea928c8af5cf8732063b", "tracking_id": "d47460691ef58366f713e508d59d807b"}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
# This ZSH plugin reads the text from the current buffer
|
|
||||||
# and uses a Python script to complete the text.
|
|
||||||
|
|
||||||
|
|
||||||
create_completion() {
|
|
||||||
# Get the text typed until now.
|
|
||||||
text=${BUFFER}
|
|
||||||
#echo $cursor_line $cursor_col
|
|
||||||
completion=$(echo -n "$text" | python3 /Users/victormylle/Nextcloud/Documents/Projects/CopilotTerminal/copilot.py $CURSOR)
|
|
||||||
|
|
||||||
# new line
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# print completion without formatting
|
|
||||||
print -Pn -- "%F{green}$completion%f\n"
|
|
||||||
|
|
||||||
print -Pn -- "Accept command (%F{green}y%f,%F{red}n%f,e)"
|
|
||||||
read -sk
|
|
||||||
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
BUFFER=$completion
|
|
||||||
zle accept-line
|
|
||||||
elif [[ $REPLY =~ ^[Ee]$ ]]; then
|
|
||||||
BUFFER=$completion
|
|
||||||
# set cursor to end of line
|
|
||||||
|
|
||||||
zle redisplay
|
|
||||||
zle end-of-line
|
|
||||||
else
|
|
||||||
zle redisplay
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Bind the create_completion function to a key.
|
|
||||||
zle -N create_completion
|
|
||||||
Reference in New Issue
Block a user