Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.venv
*.lastlogin
*__pycache__*
*.vscode*
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased]

##### Added
- Centralized proxy management system for remote aliases
- New `xts proxy` command group with `add`, `list`, and `remove` subcommands
- Proxies are defined once and can be reused across multiple aliases
- Proxy configurations stored in separate `~/.xts/proxies.json` file
- **Multiple proxy types supported**: HTTP (default), HTTPS, SOCKS5, and SSH tunnels
- `--type` parameter to specify proxy protocol when adding a proxy
- Example: `xts proxy add sky proxy.company.com:8080 --type http --username user --password pass`
- SOCKS5 support for SSH tunnels and flexible routing
- Reference proxy when adding alias: `xts alias add allocator http://server:5000/allocator.xts --proxy sky`
- Enhanced test.sh script with optional test filters (--proxy, --remote, --alias, --all)
- Virtual environment support in test.sh for better dependency isolation
- Documentation for proxy feature in `docs/PROXY_FEATURE.md` and `examples/proxy_example.md`
- Comprehensive test suite for proxy functionality (5 tests in `test_xts_alias_remote.py::TestProxySupport`)

##### Changed
- **BREAKING**: Proxy configuration format changed from inline parameters to named references
- Old: `xts alias add <name> <url> --proxy <host:port> --proxy-username <user> --proxy-password <pass>`
- New: First define proxy: `xts proxy add <name> <host:port> --username <user> --password <pass>`
- Then reference it: `xts alias add <name> <url> --proxy <proxy_name>`
- Alias metadata now stores `proxy_name` reference instead of full proxy configuration
- Proxy credentials (including passwords) now stored in separate `~/.xts/proxies.json` file

##### Security
- Proxy credentials now stored in dedicated `~/.xts/proxies.json` file
- Allows for better security practices (e.g., separate gitignore, file permissions)
- Centralized credential management improves maintainability

#### [1.3.0](https://github.com/rdkcentral/xts_core/compare/1.2.1...1.3.0)

- Update #9 - Create build script to simplify and standardise building the xts app [`ac40bdc`](https://github.com/rdkcentral/xts_core/commit/ac40bdc4d1d2d6e3be7f87cb77e2687faa40e6eb)
Expand Down
252 changes: 252 additions & 0 deletions COMMAND_HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
# XTS Command History & Recall

## Quick Command Recall

### 1. **Arrow Keys** (Simplest)
- **↑ (Up Arrow)** - Recall previous command
- **↓ (Down Arrow)** - Move forward in history
- Press up arrow, then edit the command, then Enter

```bash
$ xts allocator list
{"slots":[]}
$ ↑ # Brings back: xts allocator list
# Edit to: xts allocator list_free
```

### 2. **Ctrl+R** (Reverse Search)
Search through your command history:
```bash
$ <Ctrl+R>
(reverse-i-search)`alloc': xts allocator alloc_by_id [email protected] 1 2h
```
- Type to search
- Ctrl+R again to cycle through matches
- Enter to execute
- Ctrl+C to cancel

### 3. **History Expansion**
Bash shortcuts for command reuse:

```bash
# Repeat last command
$ xts allocator list
$ !! # Runs: xts allocator list

# Repeat last command with sudo
$ !!

# Use last argument from previous command
$ xts allocator alloc_by_id [email protected] 5 2h
$ xts allocator release !$ # !$ = "2h" (last arg)
# Better: xts allocator release [email protected] 5

# Use specific argument
$ xts allocator alloc_by_id [email protected] 5 2h
$ xts allocator release !:2 !:3 # !:2 = [email protected], !:3 = 5

# Repeat last command starting with "xts"
$ !xts

# Repeat last command containing "allocator"
$ !?allocator
```

### 4. **Edit Last Command**
Quickly fix typos:
```bash
$ xts allocator alloc_by_id [email protected] 5 2h # Typo: "usr"
$ ^usr^user # Replaces usr with user and runs
# Executes: xts allocator alloc_by_id [email protected] 5 2h
```

### 5. **History Command**
View and reuse from history:
```bash
# Show recent commands
$ history 20

# Execute command by number
$ !542 # Runs command #542 from history

# Show only xts commands
$ history | grep xts
```

## Enhanced Bash Configuration

Add these to your `~/.bashrc` for better history:

```bash
# Increase history size
export HISTSIZE=10000
export HISTFILESIZE=20000

# Don't store duplicate commands
export HISTCONTROL=ignoredups:erasedups

# Append to history (don't overwrite)
shopt -s histappend

# Save multi-line commands as one entry
shopt -s cmdhist

# Real-time history sharing across sessions
PROMPT_COMMAND="history -a; history -n"

# Enable Ctrl+S for forward search (reverse of Ctrl+R)
stty -ixon
```

After adding these, reload:
```bash
source ~/.bashrc
```

## XTS-Specific Aliases

Create bash aliases for common xts commands:

```bash
# Add to ~/.bashrc
alias xa='xts allocator'
alias xal='xts allocator list'
alias xalf='xts allocator list_free'
alias xaa='xts allocator alloc_by_id'
alias xar='xts allocator release'

# Now you can use:
$ xal # Instead of: xts allocator list
$ xaa [email protected] 5 2h # Allocate device 5
```

## Readline (inputrc) Enhancements

Add to `~/.inputrc` for better tab completion behavior:

```bash
# Create/edit ~/.inputrc
$ nano ~/.inputrc
```

Add these lines:
```
# Show all completions immediately
set show-all-if-ambiguous on

# Case-insensitive completion
set completion-ignore-case on

# Colored completion
set colored-stats on
set colored-completion-prefix on

# Menu completion - cycle through options with tab
"\t": menu-complete
"\e[Z": menu-complete-backward

# Show completion type indicators
set visible-stats on

# Immediately show completion matches
set show-all-if-unmodified on
```

Reload:
```bash
$ bind -f ~/.inputrc
```

## Practical Workflow Examples

### Example 1: Allocate, Test, Release
```bash
# Step 1: Allocate
$ xts allocator alloc_by_id [email protected] 5 2h
{"status":"success","device_id":5}

# Step 2: Use it (remember the command)
$ ↑ # Recall allocation command
# Edit to release: xts allocator release [email protected] 5
```

### Example 2: List, Then Allocate Specific Device
```bash
# See available devices
$ xts allocator list_free

# Pick one, reuse the alias name with tab completion
$ xts allocator alloc_<TAB> # Completes to alloc_by_id, alloc_by_platform, etc.
```

### Example 3: Repeat with Modifications
```bash
# Allocate device 5
$ xts allocator alloc_by_id [email protected] 5 2h

# Release it
$ ↑ # Recall
# Change "alloc_by_id" to "release" and remove "2h"
$ xts allocator release [email protected] 5
```

## Advanced: fzf Integration (Optional)

For even better history search, install [fzf](https://github.com/junegunn/fzf):

```bash
# Install
$ sudo apt install fzf # or: git clone https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install

# Add to ~/.bashrc
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
```

Now:
- **Ctrl+R** - Interactive fuzzy history search with preview
- **Ctrl+T** - Fuzzy file finder
- **Alt+C** - Fuzzy directory changer

## Tips & Tricks

1. **Quick Edit**: Start typing a command, then ↑ to search history for commands starting with those characters

2. **Job Control**:
```bash
$ xts allocator list # Takes a while...
<Ctrl+Z> # Suspend
$ bg # Continue in background
$ fg # Bring back to foreground
```

3. **Command Substitution**:
```bash
# Use output of one command in another
$ DEVICE=$(xts allocator list | jq -r '.slots[0].id')
$ xts allocator alloc_by_id [email protected] $DEVICE 2h
```

4. **For Loops for Batch Operations**:
```bash
# Release multiple devices
$ for id in 1 2 3; do xts allocator release [email protected] $id; done
```

## Summary

**Fastest methods for command recall:**

| Action | Method | Example |
|--------|--------|---------|
| Recall last command | `↑` | Press up arrow |
| Search history | `Ctrl+R` | Ctrl+R, type "alloc" |
| Repeat last command | `!!` | `!!` |
| Fix typo | `^old^new` | `^usr^user` |
| Use last argument | `!$` | `command !$` |

**After running a command, you can:**
1. Press `↑` to recall it
2. Press `Ctrl+R` and search for it
3. Type the start of the command and press `↑` to search matching history

Unfortunately, **tab completion cannot recall history** - that's a shell limitation. But the methods above are faster than tab-tab anyway!
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,35 @@ To check which commands are available run `xts --help`. This may need to be run,
xts run example --help
```

### Working with Aliases

XTS supports aliases for easy access to .xts files from any location:

```bash
# Add a local alias
xts alias add mytools ~/projects/tools.xts

# Add a remote alias
xts alias add demo https://example.com/demo.xts

# Add remote alias through a proxy
xts alias add sky http://server:5000/allocator.xts \
--proxy proxy.example.com:8080 \
--proxy-username user \
--proxy-password pass
Comment on lines +174 to +178
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This README example documents the old inline proxy flags on xts alias add, but the changelog in this PR states a breaking change to named proxy references (xts proxy add ... then xts alias add ... --proxy <proxy_name>). Update this snippet (and any surrounding text) to reflect the new CLI so users don’t copy/paste a now-invalid command.

Copilot uses AI. Check for mistakes.

# Use the alias
xts mytools some_command

# List aliases
xts alias list

# Refresh an alias
xts alias refresh demo
```

**Proxy Support**: When adding remote aliases behind a corporate firewall or proxy, use the `--proxy`, `--proxy-username`, and `--proxy-password` options. The proxy configuration is saved with the alias and automatically used for updates and refreshes.

### Write a custom .xts file
Any file with the extension `.xts` will be picked up by the tool. Therefore, creating a file with this extension and filling it with valid command definitions will create a custom `.xts` file.

Expand Down
Loading
Loading