Created pip package
This commit is contained in:
parent
2dd68657f7
commit
09f9129e58
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
demos/
|
||||
.DS_Store
|
||||
build/
|
||||
CopilotTerminal.egg-info
|
||||
22
copilot.py
22
copilot.py
@ -4,6 +4,8 @@ import os
|
||||
import sys
|
||||
import time
|
||||
from os.path import expanduser
|
||||
import click
|
||||
|
||||
|
||||
# get a new github copilot token
|
||||
def get_token():
|
||||
@ -105,14 +107,14 @@ def get_suggestion(prompt, token):
|
||||
|
||||
return "Command not found"
|
||||
|
||||
# cursor_position_char = int(sys.argv[1])
|
||||
@click.group()
|
||||
def main():
|
||||
pass
|
||||
|
||||
# Read the input prompt from stdin.
|
||||
# buffer = sys.stdin.read()
|
||||
buffer = 'change python version to 3.10'
|
||||
|
||||
# ---
|
||||
prompt_prefix = "!/bin/bash\n\n" + buffer + ":\n"
|
||||
|
||||
token = get_token()
|
||||
print(get_suggestion(prompt_prefix, token))
|
||||
@main.command()
|
||||
@click.argument('prompt', nargs=-1)
|
||||
def generate_suggestion(prompt):
|
||||
prompt = " ".join(prompt)
|
||||
prompt = "!/bin/bash\n\n" + prompt + ":\n"
|
||||
token = get_token()
|
||||
print(get_suggestion(prompt, 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
|
||||
Loading…
x
Reference in New Issue
Block a user