Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec181c5

Browse files
authored
Add fish shell support (#82)
* feat: Add Google Gemini provider This commit adds a new provider for Google Gemini, allowing users to select Gemini as their LLM provider in ShellOracle. The following changes were made: - Created `src/shelloracle/providers/google.py` with the `Google` provider class. - Added `google-generativeai` as a dependency in `pyproject.toml`. - Modified `src/shelloracle/providers/__init__.py` to include the new provider. - Updated `~/.shelloracle/config.toml` to include a configuration section for the Google provider.
1 parent 79f9b9c commit ec181c5

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Upgrading to the latest version of ShellOracle is just as simple!
6060

6161
## Usage
6262

63-
ShellOracle is designed to be used as a BASH/ZSH widget activated by the CTRL+F keyboard shortcut.
63+
ShellOracle is designed to be used as a BASH/ZSH/fish widget activated by the CTRL+F keyboard shortcut.
6464

6565
1. Press CTRL+F
6666
2. Describe your command
@@ -122,7 +122,7 @@ behavior.
122122
123123
### Software
124124
125-
ShellOracle supports BASHand ZSH on macOS and Linux.
125+
ShellOracle supports BASH, ZSH and fish on macOS and Linux.
126126
127127
### Hardware
128128

‎src/shelloracle/bootstrap.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import shutil
55
from pathlib import Path
6+
import os
67
from typing import TYPE_CHECKING, Any
78

89
import tomlkit
@@ -38,7 +39,7 @@ def replace_home_with_tilde(path: Path) -> Path:
3839
return Path("~") / relative_path
3940

4041

41-
supported_shells = ("zsh", "bash")
42+
supported_shells = ("zsh", "bash", "fish")
4243

4344

4445
def get_installed_shells() -> list[str]:
@@ -49,18 +50,24 @@ def get_bundled_script_path(shell: str) -> Path:
4950
shell_dir = Path(__file__).parent / "shell"
5051
if shell == "zsh":
5152
return shell_dir / "shelloracle.zsh"
53+
if shell == "fish":
54+
return shell_dir / "shelloracle.fish"
5255
return shell_dir / "shelloracle.bash"
5356

5457

5558
def get_script_path(shell: str) -> Path:
5659
if shell == "zsh":
5760
return Path.home() / ".shelloracle.zsh"
61+
if shell == "fish":
62+
return Path.home() / ".shelloracle.fish"
5863
return Path.home() / ".shelloracle.bash"
5964

6065

6166
def get_rc_path(shell: str) -> Path:
6267
if shell == "zsh":
6368
return Path.home() / ".zshrc"
69+
if shell == "fish":
70+
return Path.home() / ".config/fish/config.fish"
6471
return Path.home() / ".bashrc"
6572

6673

@@ -75,10 +82,13 @@ def update_rc(shell: str) -> None:
7582
rc_path = get_rc_path(shell)
7683
rc_path.touch(exist_ok=True)
7784
with rc_path.open("r") as file:
78-
zshrc = file.read()
79-
shelloracle_script = get_script_path(shell)
80-
line = f"[ -f {shelloracle_script} ] && source {shelloracle_script}"
81-
if line not in zshrc:
85+
rc_content = file.read()
86+
if shell == "fish":
87+
line = f"source {get_script_path(shell)}"
88+
else:
89+
shelloracle_script = get_script_path(shell)
90+
line = f"[ -f {shelloracle_script} ] && source {shelloracle_script}"
91+
if line not in rc_content:
8292
with rc_path.open("a") as file:
8393
file.write("\n")
8494
file.write(line)
@@ -119,16 +129,14 @@ def install_keybindings() -> None:
119129
if not (shells := get_installed_shells()):
120130
print_warning(
121131
"Cannot install keybindings: no compatible shells found. "
122-
f"Supported shells: {', '.join(supported_shells)}"
132+
f"Supported shells: {' '.join(supported_shells)}"
123133
)
124134
return
125135
if confirm("Enable terminal keybindings and update rc?", suffix=" ([y]/n) ") is False:
126136
return
127-
for shell in shells:
137+
for shell in get_installed_shells():
128138
write_script_home(shell)
129139
update_rc(shell)
130-
131-
132140
def user_configure_settings(provider: type[Provider]) -> dict[str, Any]:
133141
settings = {}
134142
for name, setting in get_settings(provider):

‎src/shelloracle/providers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from collections.abc import AsyncIterator
1010

1111
system_prompt = (
12-
"Based on the following user description, generate a corresponding Bash command. Focus solely "
12+
"Based on the following user description, generate a corresponding shell command. Focus solely "
1313
"on interpreting the requirements and translating them into a single, executable Bash command. "
14-
"Ensure accuracy and relevance to the user's description. The output should be a valid Bash "
14+
"Ensure accuracy and relevance to the user's description. The output should be a valid shell "
1515
"command that directly aligns with the user's intent, ready for execution in a command-line "
1616
"environment. Do not output anything except for the command. No code block, no English explanation, "
1717
"no newlines, and no start/end tags."

‎src/shelloracle/shell/shelloracle.fish

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function __shelloracle__
2+
set -l output (shor)
3+
if test $status -ne 0
4+
return $status
5+
end
6+
commandline -r -- $output
7+
end
8+
9+
bind \cf __shelloracle__

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /