Skip to content

Commit 5ec23cb

Browse files
deploy: 74e6abb
0 parents  commit 5ec23cb

28 files changed

+8645
-0
lines changed

.nojekyll

Whitespace-only changes.

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssage.answer.ai

config.html

Lines changed: 692 additions & 0 deletions
Large diffs are not rendered by default.

config.html.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ShellSage Configuration
2+
3+
4+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5+
6+
## Imports
7+
8+
``` python
9+
_cfg_path()
10+
```
11+
12+
Path('/Users/nathan/.config/shell_sage/shell_sage.conf')
13+
14+
``` python
15+
providers
16+
```
17+
18+
{'anthropic': ['claude-3-opus-20240229',
19+
'claude-3-5-sonnet-20241022',
20+
'claude-3-haiku-20240307',
21+
'claude-3-5-haiku-20241022'],
22+
'openai': ('o1-preview',
23+
'o1-mini',
24+
'gpt-4o',
25+
'gpt-4o-mini',
26+
'gpt-4-turbo',
27+
'gpt-4',
28+
'gpt-4-32k',
29+
'gpt-3.5-turbo',
30+
'gpt-3.5-turbo-instruct')}
31+
32+
------------------------------------------------------------------------
33+
34+
<a
35+
href="https://github.com/AnswerDotAI/shell_sage/blob/main/shell_sage/config.py#L29"
36+
target="_blank" style="float:right; font-size:smaller">source</a>
37+
38+
### ShellSageConfig
39+
40+
> ShellSageConfig (provider:str='anthropic',
41+
> model:str='claude-3-5-sonnet-20241022', base_url:str='',
42+
> api_key:str='', history_lines:int=-1,
43+
> code_theme:str='monokai', code_lexer:str='python')
44+
45+
``` python
46+
cfg = ShellSageConfig()
47+
cfg
48+
```
49+
50+
ShellSageConfig(provider='anthropic', model='claude-3-5-sonnet-20241022', base_url='', api_key='', history_lines=-1, code_theme='monokai', code_lexer='python')
51+
52+
------------------------------------------------------------------------
53+
54+
<a
55+
href="https://github.com/AnswerDotAI/shell_sage/blob/main/shell_sage/config.py#L39"
56+
target="_blank" style="float:right; font-size:smaller">source</a>
57+
58+
### get_cfg
59+
60+
> get_cfg ()
61+
62+
``` python
63+
cfg = get_cfg()
64+
cfg
65+
```
66+
67+
{'provider': 'anthropic', 'model': 'claude-3-5-sonnet-20241022', 'base_url': '', 'api_key': '', 'history_lines': '-1', 'code_theme': 'monokai', 'code_lexer': 'python'}

core.html

Lines changed: 1154 additions & 0 deletions
Large diffs are not rendered by default.

core.html.md

Lines changed: 524 additions & 0 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 866 additions & 0 deletions
Large diffs are not rendered by default.

index.html.md

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# ShellSage
2+
3+
4+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5+
6+
## Overview
7+
8+
ShellSage works by understanding your terminal context and leveraging
9+
powerful language models (Claude or GPT) to provide intelligent
10+
assistance for:
11+
12+
- Shell commands and scripting
13+
- System administration tasks
14+
- Git operations
15+
- File management
16+
- Process handling
17+
- Real-time problem solving
18+
19+
What sets ShellSage apart is its ability to:
20+
21+
- Read your terminal context through tmux integration
22+
- Provide responses based on your current terminal state
23+
- Accept piped input for direct analysis
24+
- Target specific tmux panes for focused assistance
25+
26+
Whether you’re a seasoned sysadmin or just getting started with the
27+
command line, ShellSage acts as your intelligent terminal companion,
28+
ready to help with both simple commands and complex operations.
29+
30+
## Installation
31+
32+
Install ShellSage directly from PyPI using pip:
33+
34+
``` sh
35+
pip install shell_sage
36+
```
37+
38+
### Prerequisites
39+
40+
1. **API Key Setup**
41+
42+
``` sh
43+
# For Claude (default)
44+
export ANTHROPIC_API_KEY=sk...
45+
46+
# For OpenAI (optional)
47+
export OPENAI_API_KEY=sk...
48+
```
49+
50+
2. **tmux Configuration**
51+
52+
We recommend using this optimized tmux configuration for the best
53+
ShellSage experience. Create or edit your `~/.tmux.conf`:
54+
55+
``` sh
56+
# Enable mouse support
57+
set -g mouse on
58+
59+
# Show pane ID and time in status bar
60+
set -g status-right '#{pane_id} | %H:%M '
61+
62+
# Keep terminal content visible (needed for neovim)
63+
set-option -g alternate-screen off
64+
65+
# Enable vi mode for better copy/paste
66+
set-window-option -g mode-keys vi
67+
68+
# Improved search and copy bindings
69+
bind-key / copy-mode\; send-key ?
70+
bind-key -T copy-mode-vi y \
71+
send-key -X start-of-line\; \
72+
send-key -X begin-selection\; \
73+
send-key -X end-of-line\; \
74+
send-key -X cursor-left\; \
75+
send-key -X copy-selection-and-cancel\; \
76+
paste-buffer
77+
```
78+
79+
Reload tmux config:
80+
81+
``` sh
82+
tmux source ~/.tmux.conf
83+
```
84+
85+
This configuration enables mouse support, displays pane IDs (crucial for
86+
targeting specific panes), maintains terminal content visibility, and
87+
adds vim-style keybindings for efficient navigation and text selection.
88+
89+
## Getting Started
90+
91+
### Basic Usage
92+
93+
ShellSage is designed to run within a tmux session. Here are the core
94+
commands:
95+
96+
``` sh
97+
# Basic usage
98+
ssage hi ShellSage
99+
100+
# Pipe content to ShellSage
101+
cat error.log | ssage explain this error
102+
103+
# Target a specific tmux pane
104+
ssage --pid %3 what is happening in this pane?
105+
106+
# Automatically fill in the command to run
107+
ssage --c how can I list all files including the hidden ones?
108+
```
109+
110+
The `--pid` flag is particularly useful when you want to analyze content
111+
from a different pane. The pane ID is visible in your tmux status bar
112+
(configured earlier).
113+
114+
### Using Alternative Model Providers
115+
116+
ShellSage supports using different LLM providers through base URL
117+
configuration. This allows you to use local models or alternative API
118+
endpoints:
119+
120+
``` sh
121+
# Use a local Ollama endpoint
122+
ssage --provider openai --model llama3.2 --base_url http://localhost:11434/v1 --api_key ollama what is rsync?
123+
124+
# Use together.ai
125+
ssage --provider openai --model mistralai/Mistral-7B-Instruct-v0.3 --base_url https://api.together.xyz/v1 help me with sed # make sure you've set your together API key in your shell_sage conf
126+
```
127+
128+
This is particularly useful for:
129+
130+
- Running models locally for privacy/offline use
131+
- Using alternative hosting providers
132+
- Testing different model implementations
133+
- Accessing specialized model deployments
134+
135+
You can also set these configurations permanently in your ShellSage
136+
config file (`~/.config/shell_sage/shell_sage.conf`). See next section
137+
for details.
138+
139+
## Configuration
140+
141+
ShellSage can be customized through its configuration file located at
142+
`~/.config/shell_sage/shell_sage.conf`. Here’s a complete configuration
143+
example:
144+
145+
``` ini
146+
[DEFAULT]
147+
# Choose your AI model provider
148+
provider = anthropic # or 'openai'
149+
model = claude-3-5-sonnet-20241022 # or 'gpt-4o-mini' for OpenAI
150+
base_url = # leave empty to use default openai endpoint
151+
api_key = # leave empty to default to using your OPENAI_API_KEY env var
152+
153+
# Terminal history settings
154+
history_lines = -1 # -1 for all history
155+
156+
# Code display preferences
157+
code_theme = monokai # syntax highlighting theme
158+
code_lexer = python # default code lexer
159+
```
160+
161+
You can find all of the code theme and code lexer options here:
162+
https://pygments.org/styles/
163+
164+
### Command Line Overrides
165+
166+
Any configuration option can be overridden via command line arguments:
167+
168+
``` sh
169+
# Use OpenAI instead of Claude for a single query
170+
ssage --provider openai --model gpt-4o-mini "explain this error"
171+
172+
# Adjust history lines for a specific query
173+
ssage --history-lines 50 "what commands did I just run?"
174+
```
175+
176+
### Advanced Use Cases
177+
178+
#### Git Workflow Enhancement
179+
180+
``` sh
181+
# Review changes before commit
182+
git diff | ssage summarize these changes
183+
184+
# Get commit message suggestions
185+
git diff --staged | ssage suggest a commit message
186+
187+
# Analyze PR feedback
188+
gh pr view 123 | ssage summarize this PR feedback
189+
```
190+
191+
#### Log Analysis
192+
193+
``` sh
194+
# Quick error investigation
195+
journalctl -xe | ssage what's causing these errors?
196+
197+
# Apache/Nginx log analysis
198+
tail -n 100 /var/log/nginx/access.log | ssage analyze this traffic pattern
199+
200+
# System performance investigation
201+
top -b -n 1 | ssage explain system resource usage
202+
```
203+
204+
#### Docker Management
205+
206+
``` sh
207+
# Container troubleshooting
208+
docker logs my-container | ssage "what is wrong with this container?"
209+
210+
# Image optimization
211+
docker history my-image | ssage suggest optimization improvements
212+
213+
# Compose file analysis
214+
cat docker-compose.yml | ssage review this compose configuration
215+
```
216+
217+
#### Database Operations
218+
219+
``` sh
220+
# Query optimization
221+
psql -c "EXPLAIN ANALYZE SELECT..." | ssage optimize this query
222+
223+
# Schema review
224+
pg_dump --schema-only mydb | ssage review this database schema
225+
226+
# Index suggestions
227+
psql -c "\di+" | ssage suggest missing indexes
228+
```
229+
230+
## Tips & Best Practices
231+
232+
### Effective Usage Patterns
233+
234+
1. **Contextual Queries**
235+
236+
- Keep your tmux pane IDs visible in the status bar
237+
- Use `--pid` when referencing other panes
238+
- Let ShellSage see your recent command history for better context
239+
240+
2. **Piping Best Practices**
241+
242+
``` sh
243+
# Pipe logs directly
244+
tail log.txt | ssage "summarize these logs"
245+
246+
# Combine commands
247+
git diff | ssage "review these changes"
248+
```
249+
250+
### Getting Help
251+
252+
``` sh
253+
# View all available options
254+
ssage --help
255+
256+
# Submit issues or feature requests
257+
# https://github.com/AnswerDotAI/shell_sage/issues
258+
```
259+
260+
## Contributing
261+
262+
ShellSage is built using [nbdev](https://nbdev.fast.ai/). For detailed
263+
contribution guidelines, please see our
264+
[CONTRIBUTING.md](CONTRIBUTING.md) file.
265+
266+
We welcome contributions of all kinds:
267+
268+
- Bug reports
269+
- Feature requests
270+
- Documentation improvements
271+
- Code contributions
272+
273+
Please visit our [GitHub
274+
repository](https://github.com/AnswerDotAI/shell_sage) to get started.

robots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sitemap: https://AnswerDotAI.github.io/shell_sage/sitemap.xml

0 commit comments

Comments
 (0)