alman 0.1.2

A command-line tool and TUI for managing shell aliases with intelligent suggestions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# alman - Intelligent Alias Manager

[![Last Commit](https://img.shields.io/github/last-commit/vaibhav-mattoo/alman)](https://github.com/vaibhav-mattoo/alman/commits)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Crates.io](https://img.shields.io/crates/v/alman)](https://crates.io/crates/alman)
[![AUR version](https://img.shields.io/aur/version/alman?logo=arch-linux)](https://aur.archlinux.org/packages/alman)

A command-line tool and TUI for managing shell aliases with intelligent suggestions based on your command history. Alman helps you organize, create, and manage aliases across multiple files and shells, making your workflow faster and smarter.

## 🎨 Showcase

Watch alman in action! See how it can transform your command-line workflow with intelligent alias suggestions and intuitive management.



https://github.com/user-attachments/assets/53ae73cf-15ff-4f9e-af31-51ac2b4f3c5e



## 🚀 Installation

> [!IMPORTANT]
> **Shell Configuration Required**: After installation, you **must** add the shell configuration line to your shell config file (check with `which $SHELL`) or the app will not work. See the [Shell Configuration]#%EF%B8%8F-shell-configuration section below for detailed instructions.

### Universal Install Script

The easiest way to install `alman` on any system:

```bash
curl -sSfL https://raw.githubusercontent.com/vaibhav-mattoo/alman/main/install.sh | sh
```

This script will automatically detect your system and install the appropriate binary.

> [!NOTE]
> Remember to add `~/.local/bin` to your `$PATH` if prompted by the install script, by adding `export PATH="$HOME/.local/bin:$PATH"` in the end of your shell config (~/.bashrc, ~/.zshrc etc).

### From Cargo

```bash
cargo install alman
```

### From AUR (Arch Linux)

Using `yay`:
```bash
yay -S alman
```

Using `paru`:
```bash
paru -S alman
```

### From Source

```bash
git clone https://github.com/vaibhav-mattoo/alman.git
cd alman
cargo install --path .
```

## ⚙️ Shell Configuration

After installation, you need to configure your shell to use alman. The installer will detect your shell and provide specific instructions, but here are the general steps:

> [!NOTE]
> The installer will automatically detect your shell and show you the exact configuration line to add to your shell config file.

### Bash
Add this line to your `~/.bashrc`:
```bash
eval "$(alman init bash)"
```

Then reload your configuration:
```bash
source ~/.bashrc
```

### Zsh
Add this line to your `~/.zshrc`:
```bash
eval "$(alman init zsh)"
```

Then reload your configuration:
```bash
source ~/.zshrc
```

### Fish
Add this line to your `~/.config/fish/config.fish`:
```fish
alman init fish | source
```

Then reload your configuration:
```fish
source ~/.config/fish/config.fish
```

> [!TIP]
> Alman automatically initializes with your shell history when first run, so you'll have intelligent suggestions right from the start!

## 📋 Table of Contents

<!-- disabledMarkdownTOC autolink="false" markdown_preview="github" -->

- [Showcase]#-showcase
- [Installation]#-installation
    - [Universal Install Script]#universal-install-script
    - [From Cargo]#from-cargo
    - [From AUR (Arch Linux)]#from-aur-arch-linux
    - [From Source]#from-source
- [Shell Configuration]#%EF%B8%8F-shell-configuration
    - [Bash]#bash
    - [Zsh]#zsh
    - [Fish]#fish
- [Quick Start]#-quick-start
    - [Interactive Mode]#interactive-mode
    - [Command Line Mode]#command-line-mode
- [Interactive Mode]#-interactive-mode
    - [Navigation]#navigation
    - [TUI Features]#tui-features
- [Command Line Usage]#-command-line-usage
    - [Basic Commands]#basic-commands
- [Usage Examples]#-usage-examples
    - [Basic Usage]#basic-usage
    - [Advanced Usage]#advanced-usage
    - [Change Command Examples]#change-command-examples
- [Advanced Usage]#-advanced-usage
    - [Multi-file Management]#multi-file-management
    - [Suggestion Management]#suggestion-management
    - [Alias Management]#alias-management
- [TUI Navigation]#-tui-navigation
    - [Key Bindings]#key-bindings
    - [Features]#features
- [Command Line Options]#-command-line-options
    - [Output Options]#output-options
    - [Examples]#examples
- [Output Format]#-output-format
- [Ranking Algorithm]#-ranking-algorithm
    - [Scoring Formula]#scoring-formula
    - [Time-Based Multipliers]#time-based-multipliers
    - [Factors Explained]#factors-explained
- [Alias Suggestion Schemes]#-alias-suggestion-schemes
    - [Vowel Removal]#vowel-removal
    - [Abbreviation]#abbreviation
    - [First Letter Combination]#first-letter-combination
    - [Smart Truncation]#smart-truncation
    - [Prefix Matching]#prefix-matching
- [Use Cases]#-use-cases
- [Uninstallation]#-uninstallation
- [License]#-license

<!-- /MarkdownTOC -->

## 🚀 Quick Start

### Interactive Mode
Launch the interactive alias manager:

```bash
alman
# or
alman tui
```

Navigate with arrow keys or `jk`, select aliases, and manage them interactively.

### Command Line Mode
Add, remove, list, and get suggestions for aliases directly from the command line:

```bash
# Add an alias
alman add -c "git status" gs

# Remove an alias
alman remove gs

# List all aliases
alman list

# Get alias suggestions
alman get-suggestions -n 10
```

## 🖥️ Interactive Mode

The Terminal User Interface (TUI) provides an intuitive way to browse, add, remove, and change aliases:

### Navigation
- **Arrow keys** or **jk**: Move cursor
- **Enter**: Select
- **a**: Add alias
- **r**: Remove alias
- **l**: List aliases
- **q** or **Ctrl+C**: Quit

### TUI Features
- **Visual selection**: Selected items are highlighted
- **Alias suggestions**: Get smart suggestions based on your command history
- **Multi-file support**: Manage aliases across multiple files

## 💻 Command Line Usage

### Basic Commands

```bash
# Add a new alias
alman add -c "ls -la" ll

# Remove an alias
alman remove ll

# List all aliases
alman list

# Get intelligent suggestions
alman get-suggestions -n 5
```

## 📝 Usage Examples

### Basic Usage

```bash
# Add a new alias
alman add -c "ls -la" ll

# Remove an alias
alman remove ll

# List all aliases
alman list

# Get intelligent suggestions
alman get-suggestions -n 5
```

### Advanced Usage

```bash
# Change an alias name (keeps the same command)
alman change old-alias new-alias

# Delete suggestions for an alias
alman delete-suggestion gs

# Use a specific alias file
alman --alias-file-path ~/.my-aliases add -c "htop" h
```

> [!IMPORTANT]
> After running `alman change old new` and sourcing your aliases, only the new alias will work. The old alias will be completely removed from all managed alias files.

## 🔧 Advanced Usage

### Multi-file Management

```bash
# Add alias to a specific file
alman --alias-file-path ~/.bash_aliases add -c "ls -lh" lh

# List aliases from a specific file
alman --alias-file-path ~/.zsh_aliases list
```

### Suggestion Management

```bash
# Get more suggestions
alman get-suggestions -n 10

# Delete a specific suggestion
alman delete-suggestion gs
```

## 🎮 TUI Navigation

The Terminal User Interface provides an intuitive way to manage aliases:

> [!TIP]
> The TUI mode is perfect for browsing your command history and discovering new alias opportunities!

### Key Bindings
- **Arrow keys** or **jk**: Navigate through aliases
- **Enter**: Select an alias or action
- **a**: Add a new alias
- **r**: Remove selected alias
- **l**: List all aliases
- **q** or **Ctrl+C**: Exit the interface

### Features
- **Visual feedback**: Selected items are highlighted
- **Smart suggestions**: Get intelligent alias suggestions
- **Multi-file support**: Manage aliases across different files

## ⚙️ Command Line Options

### Output Options
- `-c, --command <COMMAND>`: Command to associate with the alias (for `add` and `change`)
- `-n, --num <N>`: Number of suggestions to display (for `get-suggestions`)
- `--alias-file-path <PATH>`: Path to the alias file to use

### Examples

```bash
# Add an alias to a specific file
alman --alias-file-path ~/.bash_aliases add -c "ls -lh" lh

# Get 10 suggestions
alman get-suggestions -n 10
```

## 📊 Output Format

Alman displays aliases in a clear, tabular format:

```
┌─────────┬───────────────┐
│ ALIAS   │ COMMAND       │
├─────────┼───────────────┤
│ gs      │ git status    │
│ ll      │ ls -la        │
└─────────┴───────────────┘
```

## 🧠 Ranking Algorithm

Alman uses a sophisticated scoring algorithm to rank commands based on three key factors:

### Scoring Formula
```
Score = Time Multiplier × Length^(3/5) × Frequency
```

### Time-Based Multipliers
- **≤ 1 hour**: 4.0× (recent commands get highest priority)
- **≤ 1 day**: 2.0× (recent commands)
- **≤ 1 week**: 0.5× (older commands)
- **> 1 week**: 0.25× (very old commands)

### Factors Explained
- **Recency**: Recently used commands score higher, encouraging current workflow patterns
- **Frequency**: More frequently used commands get higher scores
- **Length**: Longer commands get slightly higher scores (using length^(3/5) to avoid excessive bias)
- **Automatic Reset**: When total score exceeds 70,000, all frequencies are reduced by 50% to prevent score inflation

> [!TIP]
> The algorithm automatically adapts to your usage patterns, prioritizing commands you use most frequently and recently!

## 🎯 Alias Suggestion Schemes

Alman employs multiple intelligent schemes to generate meaningful alias suggestions:

### Vowel Removal
Removes vowels to create shorter, memorable aliases:
- `git status``gst` (removes 'i', 'a', 'u')
- `docker ps``dckr ps` (removes 'o', 'e')

### Abbreviation
Creates abbreviations from command words:
- `git pull``gp`
- `ls -la``ll`
- `npm install``ni`

### First Letter Combination
Combines first letter of first word and rest:
- `git status``gstatus`
- `docker compose``dcompose`
- `systemctl status``sstatus`

### Smart Truncation
Truncates long commands intelligently:
- `git checkout``gco`
- `docker build``db`
- `npm run dev``nrd`

### Prefix Matching
Suggests aliases based on common command prefixes:
- `git` commands → `g` + first letter of subcommand
- `docker` commands → `d` + first letter of subcommand

> [!NOTE]
> Alman evaluates all these schemes and ranks suggestions by their effectiveness and memorability, ensuring you get the most useful aliases first.

## 🎯 Use Cases

Perfect for managing your shell aliases, discovering new shortcuts, and keeping your workflow efficient:

```bash
# Quick alias management
alman tui

# Add and remove aliases on the fly
alman add -c "git pull" gp
alman remove gp

# Get suggestions for new aliases
alman get-suggestions -n 5
```

> [!TIP]
> Try the interactive TUI mode (`alman tui`) for the most intuitive alias management experience!

## 🗑️ Uninstallation

To uninstall `alman`, you can run the command:

```bash
curl -sSfL https://raw.githubusercontent.com/vaibhav-mattoo/alman/main/uninstall.sh | sh
```

Or download and run the uninstall script manually:

```bash
curl -sSfL https://raw.githubusercontent.com/vaibhav-mattoo/alman/main/uninstall.sh -o uninstall.sh
chmod +x uninstall.sh
./uninstall.sh
```

> [!NOTE]
> After uninstalling, remember to remove the shell configuration lines from your shell config files:
> - From `~/.bashrc`: Remove `eval "$(alman init bash)"`
> - From `~/.zshrc`: Remove `eval "$(alman init zsh)"`
> - From `~/.config/fish/config.fish`: Remove `eval (alman init fish)`

## 📄 License

MIT License - see LICENSE file for details.