diff --git a/scripts/bash_plugin.sh b/scripts/bash_plugin.sh index 9984c92..e04f9fd 100644 --- a/scripts/bash_plugin.sh +++ b/scripts/bash_plugin.sh @@ -20,6 +20,17 @@ create_completion() # Get the text typed until now text=${READLINE_LINE} completion=$(echo -n "$text" | $CODEX_CLI_PATH/src/codex_query.py) + + # add # to the beginning of $text if it doesnt start with # + # get the first non whitespace char + # first_char=$(echo $line | sed -e 's/^[[:space:]]*//') + # get the first char of the line + first_char=$(echo $text | cut -c 1) + if [ "$first_char" != "#" ]; then + text="# $text" + fi +# note: add multiline fix + # Add completion to the current buffer READLINE_LINE="${text}${completion}" # Put the cursor at the end of the line diff --git a/scripts/powershell_plugin.ps1 b/scripts/powershell_plugin.ps1 index ac6d35b..ea8aadc 100644 --- a/scripts/powershell_plugin.ps1 +++ b/scripts/powershell_plugin.ps1 @@ -30,6 +30,15 @@ Set-PSReadLineKeyHandler -Key Ctrl+g ` # get response from create_completion function $output = create_completion($line) + + # get first char of the response + # if its not #, add # to the beginning of the response + if ($output[0] -ne "#") { + $output = "# $output" + } + # note: add multiline fix + + # check if output is not null if ($output -ne $null) { diff --git a/scripts/zsh_plugin.zsh b/scripts/zsh_plugin.zsh index c194d58..b7b7acc 100644 --- a/scripts/zsh_plugin.zsh +++ b/scripts/zsh_plugin.zsh @@ -7,6 +7,18 @@ create_completion() { # Get the text typed until now. text=${BUFFER} completion=$(echo -n "$text" | $CODEX_CLI_PATH/src/codex_query.py) + + + # add # to the beginning of $text if it doesnt start with # + # get the first non whitespace char + # first_char=$(echo $line | sed -e 's/^[[:space:]]*//') + # get the first char of the line + first_char=$(echo $text | cut -c 1) + if [ "$first_char" != "#" ]; then + text="# $text" + fi + # note: add multiline fix + # Add completion to the current buffer. BUFFER="${text}${completion}" # Put the cursor at the end of the line.