rembook 0.1.0
A simple CLI tool for bookmarking SSH connections from your bash history
License: BSD-3-Clause
Requires Python: >=3.10
Keywords: ssh, bookmark, cli, terminal, bash-history

# rembook

**rembook** is a simple CLI tool that helps you bookmark and manage SSH connections from your bash history. Stop scrolling through `.bash_history` to find that one server you accessed last week!

## Features

- 📚 **Automatic History Parsing**: Scans your `.bash_history` for SSH connections
- 🔖 **Bookmark Management**: Save frequently used SSH commands with memorable names
- 🎯 **Quick Access**: Launch saved connections with a single command
- 📊 **Interactive Selection**: Browse available connections in a neat table
- 🔢 **Smart Sorting**: Shows most frequently used connections first

## Installation

### From PyPI

```bash
pip install rembook
```

### From Source

```bash
git clone git@github.com:Glucksistemi/rembook.git
cd rembook
pip install -e .
```

## Usage

### Basic Usage

Simply run `rembook` to see an interactive list of all available SSH connections:

```bash
rembook
```

This will display a table with:
- All your bookmarked connections
- SSH commands from your bash history (sorted by frequency)

Select a connection by entering its number, or type a new SSH command directly.

### Launch a Saved Bookmark

```bash
rembook myserver
```

This will execute the SSH command associated with the bookmark `myserver`.

### Create a Bookmark

Add a bookmark interactively:

```bash
rembook -a
```

You'll be prompted to select a connection and give it a name.

Or create a bookmark directly:

```bash
rembook mybookmark -a
```

This will prompt you to select a connection to save as `mybookmark`.

### Delete a Bookmark

```bash
rembook mybookmark -d
```

Or delete interactively:

```bash
rembook -d
```

## Examples

### Example 1: Browse and connect

```bash
$ rembook
No  Connection              Bookmark
--  ----------------------  ----------
1   ssh user@server1.com    prod
2   ssh admin@192.168.1.1   router
3   ssh dev@staging.com

Enter number of connection or ssh command [1]: 1
# Connects to server1.com
```

### Example 2: Save a bookmark

```bash
$ rembook production -a
No  Connection              Bookmark
--  ----------------------  ----------
1   ssh user@prod.app.com
2   ssh admin@192.168.1.1   router

Enter number of connection or ssh command [1]: 1
# Saves ssh user@prod.app.com as "production"
```

### Example 3: Use a saved bookmark

```bash
$ rembook production
# Immediately connects to ssh user@prod.app.com
```

### Example 4: Quick SSH with custom command

```bash
$ rembook
No  Connection              Bookmark
--  ----------------------  ----------
1   ssh user@server1.com    prod

Enter number of connection or ssh command [1]: user@newserver.com
# Connects to ssh user@newserver.com
```

## How It Works

1. **History Parsing**: rembook scans your `~/.bash_history` file for SSH commands
2. **Frequency Analysis**: Commands are ranked by how often you've used them
3. **Persistent Bookmarks**: Saved bookmarks are stored in your user config directory
4. **Quick Execution**: Selected commands are executed directly via `os.system()`

## Requirements

- Python 3.10+
- Bash shell (uses `.bash_history`)
- Linux or macOS

## Dependencies

- [typer](https://typer.tiangolo.com/) - CLI framework
- [tabulate](https://github.com/astanin/python-tabulate) - Table formatting
- [appdirs](https://github.com/ActiveState/appdirs) - Cross-platform config directory

## Configuration

Bookmarks are stored in a JSON file at:
- **Linux**: `~/.config/rembook/bookmarks.json`
- **macOS**: `~/Library/Application Support/rembook/bookmarks.json`

## License

BSD 3-Clause License. See LICENSE file for details.

## Author

**Kirill Nikolsky** - [glucksistemi@gmail.com](mailto:glucksistemi@gmail.com)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Repository

<https://github.com/Glucksistemi/rembook>