Skip to content

arnavgr/gemini_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gemini_cli

A fast, feature-rich Gemini AI client for macOS/linux written in bash

$ gemini "explain how sed works"

sed (stream editor) processes text line by line using pattern-action rules...
  • -e allows multiple expressions in one command
  • -i edits files in-place
  • s/old/new/g is the substitution command

[↑ 12 tokens  ↓ 184 tokens  •  gemini-2.0-flash]

Install

One-liner (recommended):

curl -sL https://raw.githubusercontent.com/arnavgr/gemini-cli/main/install.sh | bash

Custom install prefix (ensure it is in $PATH) (no sudo needed):

curl -sL https://raw.githubusercontent.com/arnavgr/gemini-cli/main/install.sh | bash -s -- --prefix ~/.local/bin

Manual:

git clone https://github.com/YOUR_USERNAME/gemini-cli
cd gemini-cli
chmod +x gemini
sudo mv gemini /usr/local/bin/gemini

Uninstall:

curl -sL https://raw.githubusercontent.com/YOUR_USERNAME/gemini-cli/main/install.sh | bash -s -- --uninstall

Requirements

Tool Purpose Install
curl HTTP requests + streaming usually pre-installed
jq JSON parsing sudo apt install jq
sed / awk Markdown rendering pre-installed everywhere

Optional (for --copy): xclip, xsel, wl-copy (Wayland), or pbcopy (macOS).


API Key

On first run, gemini will ask you to paste your API key and save it automatically.

Get a free key at: https://aistudio.google.com/app/apikey

The key is stored in ~/.config/gemini/api_key with chmod 600.
You can also set it as an environment variable (takes priority):

export GEMINI_API_KEY="your-key-here"

Usage

gemini [flags] "your prompt"
echo "context" | gemini "your prompt"
cat file.txt   | gemini "summarize this"

Flags

Flag Description
--model <name> Use a specific model (persists to config)
--session <name|number> Use a named or numbered conversation session
--system <text> Set a system instruction for this call
--new Clear current session and start fresh
--list-sessions List all saved sessions with numbers
--delete-session <name|#> Delete a session by name or number
--rename-session <name|#> <new> Rename a session
--copy Copy response to clipboard
--update Update to the latest version from GitHub
--raw Print raw markdown without rendering
--version Show version
--help Show help

Sessions

Sessions let you maintain separate ongoing conversations.

# Start or continue a named session
gemini --session work "what tasks did I list earlier?"

# Use a session by its number (from --list-sessions)
gemini --session 3 "continue"

# See all sessions
gemini --list-sessions

#   NUM    NAME                 TURNS    LAST MODIFIED
#   ───    ────────────────────  ─────    ─────────────
#   001    default               4t       2025-01-10 14:32  ←
#   002    work                  12t      2025-01-10 09:15
#   003    debugging             2t       2025-01-09 22:41

# Rename session 2
gemini --rename-session 2 project-alpha

# Delete by name or number
gemini --delete-session work
gemini --delete-session 3

# Clear history but keep the session
gemini --session work --new

Sessions are stored in ~/.local/share/gemini/sessions/ as numbered JSON files (e.g. 002_work.json).


Models

# Switch model (saved for future calls)
gemini --model gemini-3.1-pro-preview "explain quantum entanglement"

Gemini 3 series (preview — cutting edge)

Model Speed Best for
gemini-3.1-pro-preview Hardest tasks, complex reasoning & coding
gemini-3-flash-preview ⚡⚡⚡ Frontier-class at a fraction of the cost
gemini-3.1-flash-lite-preview ⚡⚡⚡⚡ Fastest Gemini 3, budget-friendly

Gemini 2.5 series (stable — production ready)

Model Speed Best for
gemini-2.5-pro Best reasoning, 1M token context
gemini-2.5-flash ⚡⚡⚡ Best price/performance — default
gemini-2.5-flash-lite ⚡⚡⚡⚡ Fastest & cheapest of the 2.5 family

The selected model persists to ~/.config/gemini/config — no need to repeat it.


Examples

# Basic question
gemini "what is the difference between tcp and udp?"

# Pipe a file
cat server.log | gemini "what errors are here and why?"

# Pipe + prompt combined
cat script.py | gemini "refactor this to be more readable"

# System prompt (persona)
gemini --system "you are a terse linux sysadmin" "how do I find files over 1GB?"

# Copy response to clipboard
gemini --copy "write a git commit message for adding dark mode"

# Named session for ongoing work
gemini --session myproject "here's my project structure: ..."
gemini --session myproject "now write tests for the auth module"

# Update to latest version
gemini --update

Configuration

Config is stored in ~/.config/gemini/config:

# gemini config
model=gemini-2.0-flash

You can edit this file directly. Currently supported keys: model.


File locations

Path Purpose
~/.config/gemini/api_key API key (chmod 600)
~/.config/gemini/config Persistent settings
~/.local/share/gemini/sessions/ Conversation history

License

MIT

About

runs gemini in terminal using bash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages