Compare commits

..

14 commits

Author SHA1 Message Date
SW
ed99f78ec9 ci: remove corrupted .deb files before dpkg-scanpackages
All checks were successful
Release / release (push) Successful in 33s
2026-09-10 15:43:17 +02:00
SW
588a425e2c ci: build .deb manually with dpkg-deb instead of cargo-deb
Some checks failed
Release / release (push) Failing after 34s
2026-09-10 15:38:08 +02:00
SW
7e577d641c ci: use cargo deb without --no-build, add .deb debug output
Some checks failed
Release / release (push) Failing after 1m13s
2026-09-10 15:29:14 +02:00
SW
42e9f2e865 ci: drop macOS build and Homebrew tap, keep Linux + .deb + APT only
Some checks failed
Release / release (push) Failing after 1m13s
2026-09-10 15:23:09 +02:00
SW
8b74afd8d0 ci: make macOS build optional, skip Homebrew tap if it fails
Some checks failed
Release / release (push) Failing after 2m24s
2026-09-10 15:14:55 +02:00
SW
b679a9e1a2 ci: install zig into /usr/local/bin with symlink
Some checks failed
Release / release (push) Failing after 2m26s
2026-09-10 15:01:05 +02:00
SW
28b571817c ci: download zig binary directly instead of apt
Some checks failed
Release / release (push) Failing after 52s
2026-09-10 14:58:43 +02:00
SW
be17563131 ci: install zig for cargo-zigbuild macOS cross-compile
Some checks failed
Release / release (push) Failing after 3s
2026-09-10 14:55:57 +02:00
SW
8c578e46a4 ci: fix SSH deploy key mount path for Forgejo runner
Some checks failed
Release / release (push) Failing after 2m1s
2026-09-10 14:51:47 +02:00
SW
13081b4d4a ci: switch release workflow to Forgejo, update repo URLs
Some checks failed
Release / release (push) Failing after 59s
- Add Forgejo release workflow with .deb, Homebrew tap and APT updates.
- Remove obsolete GitHub Actions release workflow.
- Update Cargo.toml repository and homepage URLs to git.janvete.com.
2026-09-10 14:37:48 +02:00
SW
57f734c41a docs: update install instructions for Forgejo 2026-09-10 14:22:09 +02:00
SW
a8fb33fa9f fix(main): enable bracketed paste so multi-line paste is handled as one event 2026-07-16 12:43:59 +02:00
SW
5906cddbbf fix(events): handle bracketed paste in custom/search inputs 2026-07-16 12:38:26 +02:00
SW
498803fc55 feat(custom): escape variables so they expand on remote host
feat(ui): show command in global search results

chore: bump version to 0.1.19
2026-07-16 12:21:09 +02:00
9 changed files with 285 additions and 56 deletions

View file

@ -0,0 +1,165 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
container:
image: rust:bookworm
volumes:
- /opt/runner/keys:/keys:ro
steps:
- name: Install tools
run: |
apt-get update
apt-get install -y dpkg-dev git curl openssh-client
- name: Setup SSH
run: |
test -r /keys/forgejo_runner || { echo "Deploy key /keys/forgejo_runner chybi"; exit 1; }
install -m 600 /keys/forgejo_runner /tmp/forgejo_runner
echo "GIT_SSH_COMMAND=ssh -p 554 -i /tmp/forgejo_runner -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR" >> "$GITHUB_ENV"
- name: Checkout source
run: |
git clone ssh://git@git-ssh.janvete.com:554/seth/lines.git src
cd src
git checkout "${{ github.ref_name }}"
- name: Build Linux release binary and .deb
working-directory: src
run: |
VERSION=${{ github.ref_name }}
VER=${VERSION#v}
mkdir -p dist
cargo build --release
# .deb package
DEB_DIR="lines_${VER}_amd64"
mkdir -p "${DEB_DIR}/DEBIAN" "${DEB_DIR}/usr/bin"
cp target/release/lines "${DEB_DIR}/usr/bin/lines"
chmod 755 "${DEB_DIR}/usr/bin/lines"
cat > "${DEB_DIR}/DEBIAN/control" << CONTROL
Package: lines
Version: ${VER}
Section: utils
Priority: optional
Architecture: amd64
Maintainer: janvete <jan.vete@example.com>
Description: TUI for running frequently used commands from markdown files
CONTROL
dpkg-deb --build "${DEB_DIR}" "dist/${DEB_DIR}.deb"
# Linux tarball
STAGING=$(mktemp -d)
cp target/release/lines "${STAGING}/lines"
tar -czf "dist/lines-${VERSION}-linux-amd64.tar.gz" -C "${STAGING}" lines
rm -rf "${STAGING}"
- name: Print checksums
working-directory: src
run: |
echo "=== SHA256 checksums ==="
sha256sum dist/*
- name: Create Forgejo Release
working-directory: src
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
FORGEJO_URL: https://git.janvete.com
run: |
VERSION=${{ github.ref_name }}
API="${FORGEJO_URL}/api/v1/repos/seth/lines"
RELEASE_JSON=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"${VERSION}\",\"draft\":false,\"prerelease\":false}" \
"${API}/releases")
echo "Create release response: ${RELEASE_JSON}"
RELEASE_ID=$(echo "${RELEASE_JSON}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "${RELEASE_ID}" ]; then
echo "Release may already exist, fetching existing release..."
EXISTING=$(curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
"${API}/releases/tags/${VERSION}")
echo "Existing release response: ${EXISTING}"
RELEASE_ID=$(echo "${EXISTING}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
fi
if [ -z "${RELEASE_ID}" ]; then
echo "Failed to create or fetch release"
exit 1
fi
for ARCHIVE in dist/*; do
[ -e "${ARCHIVE}" ] || continue
NAME=$(basename "${ARCHIVE}")
case "${NAME}" in
*.tar.gz) CONTENT_TYPE="application/gzip" ;;
*.deb) CONTENT_TYPE="application/vnd.debian.binary-package" ;;
*) CONTENT_TYPE="application/octet-stream" ;;
esac
curl -sS -H "Authorization: token ${FORGEJO_TOKEN}" \
-H "Content-Type: ${CONTENT_TYPE}" \
--data-binary "@${ARCHIVE}" \
"${API}/releases/${RELEASE_ID}/assets?name=${NAME}"
echo "Uploaded ${NAME}"
done
- name: Update APT repository
working-directory: src
run: |
VERSION=${{ github.ref_name }}
git clone ssh://git@git-ssh.janvete.com:554/seth/apt.git apt-repo
cp dist/*.deb apt-repo/
cd apt-repo
# Remove any corrupted .deb files left from previous failed runs
for f in *.deb; do
[ -e "$f" ] || continue
if ! dpkg-deb -I "$f" >/dev/null 2>&1; then
echo "Removing corrupted package: $f"
rm -f "$f"
fi
done
dpkg-scanpackages . > Packages
gzip -k -f Packages
cat > Release << RELEASE
Origin: janvete
Label: janvete
Suite: stable
Codename: stable
Version: 1.0
Architectures: amd64
Components: main
Description: janvete tools APT repository
Date: $(date -Ru)
RELEASE
{
echo "SHA256:"
for f in Packages Packages.gz *.deb; do
[ -e "$f" ] || continue
printf " %s %16d %s\n" "$(sha256sum "$f" | cut -d' ' -f1)" "$(stat -c%s "$f")" "$f"
done
} >> Release
git config user.email "forgejo-actions[bot]@janvete.com"
git config user.name "forgejo-actions[bot]"
git add -A
git commit -m "chore: add lines ${VERSION}"
git push

View file

@ -1,34 +0,0 @@
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-deb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build release binary
run: cargo build --release
- name: Build .deb package
run: cargo deb --no-build
- name: Upload .deb to release
uses: softprops/action-gh-release@v2
with:
files: target/debian/*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
Cargo.lock generated
View file

@ -825,7 +825,7 @@ dependencies = [
[[package]] [[package]]
name = "lines" name = "lines"
version = "0.1.17" version = "0.1.21"
dependencies = [ dependencies = [
"base64", "base64",
"chrono", "chrono",

View file

@ -1,12 +1,12 @@
[package] [package]
name = "lines" name = "lines"
version = "0.1.18" version = "0.1.21"
edition = "2024" edition = "2024"
authors = ["janvete"] authors = ["janvete"]
description = "TUI for running frequently used commands" description = "TUI for running frequently used commands"
license = "MIT" license = "MIT"
repository = "https://github.com/janvete/lines" repository = "https://git.janvete.com/seth/lines"
homepage = "https://github.com/janvete/lines" homepage = "https://git.janvete.com/seth/lines"
keywords = ["cli", "tui", "ssh", "commands"] keywords = ["cli", "tui", "ssh", "commands"]
categories = ["command-line-utilities"] categories = ["command-line-utilities"]

View file

@ -7,24 +7,22 @@ A TUI app for quickly running frequently used commands — ideal for SSH scripts
### macOS (Homebrew) ### macOS (Homebrew)
```bash ```bash
brew tap janvete/tools brew tap janvete/tools https://git.janvete.com/seth/homebrew-tools.git
brew install lines brew install lines
``` ```
### Debian / Ubuntu (.deb) ### Debian / Ubuntu (APT)
Download the latest `.deb` from the [GitHub Releases](https://github.com/janvete/lines/releases) page and install it:
```bash ```bash
sudo apt install ./lines_*.deb echo "deb [trusted=yes] https://git.janvete.com/seth/apt/raw/branch/main ./" | sudo tee /etc/apt/sources.list.d/janvete.list
# or sudo apt update
sudo dpkg -i lines_*.deb sudo apt install lines
``` ```
### From source ### From source
```bash ```bash
cargo install --git https://github.com/janvete/lines cargo install --git ssh://git@git-ssh.janvete.com:554/seth/lines
``` ```
## Usage ## Usage
@ -123,6 +121,8 @@ Use `{}` as a placeholder if your lines are just addresses:
ssh {} lsblk ssh {} lsblk
``` ```
Variables like `$HOME` or `$USER` are treated as remote-shell variables, so they are expanded on the target host, not by your local shell.
## Global search ## Global search
Press `/` to search across all commands, files, groups, and section names. Type your query, use `↑/↓` to select a result, and press `Enter` to run it. Press `/` to search across all commands, files, groups, and section names. Type your query, use `↑/↓` to select a result, and press `Enter` to run it.

View file

@ -26,15 +26,32 @@ pub fn build_commands(state: &CustomState) -> Vec<String> {
let built = if command.is_empty() { let built = if command.is_empty() {
line.to_string() line.to_string()
} else if command.contains("{}") { } else if command.contains("{}") {
command.replace("{}", line) escape_dollars(&command.replace("{}", line))
} else { } else {
format!("{} \"{}\"", line, command.replace('"', "\\\"")) let escaped = escape_dollars(command).replace('"', "\\\"");
format!("{} \"{}\"", line, escaped)
}; };
format!("{}{}", prefix, built) format!("{}{}", prefix, built)
}) })
.collect() .collect()
} }
/// Escape `$` as `\$` unless it is already escaped, so that variables are
/// expanded by the remote shell rather than the local one when the built
/// command is passed to `ssh`.
fn escape_dollars(command: &str) -> String {
let mut result = String::with_capacity(command.len());
let mut prev_backslash = false;
for c in command.chars() {
if c == '$' && !prev_backslash {
result.push('\\');
}
result.push(c);
prev_backslash = c == '\\' && !prev_backslash;
}
result
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -125,4 +142,41 @@ mod tests {
let state = make_state(vec!["ssh root@ip1", "ssh root@ip2"], vec![false, true], "", "lview"); let state = make_state(vec!["ssh root@ip1", "ssh root@ip2"], vec![false, true], "", "lview");
assert_eq!(build_commands(&state), vec!["lview ssh root@ip2"]); assert_eq!(build_commands(&state), vec!["lview ssh root@ip2"]);
} }
#[test]
fn test_build_commands_escapes_dollar_variables() {
let state = make_state(
vec!["ssh root@ip1"],
vec![true],
"echo $HOME && echo $USER",
"",
);
assert_eq!(
build_commands(&state),
vec!["ssh root@ip1 \"echo \\$HOME && echo \\$USER\""]
);
}
#[test]
fn test_build_commands_preserves_already_escaped_dollars() {
let state = make_state(
vec!["ssh root@ip1"],
vec![true],
"echo \\$HOME",
"",
);
assert_eq!(
build_commands(&state),
vec!["ssh root@ip1 \"echo \\$HOME\""]
);
}
#[test]
fn test_build_commands_placeholder_escapes_dollars() {
let state = make_state(vec!["root@ip1"], vec![true], "ssh {} echo $HOSTNAME", "");
assert_eq!(
build_commands(&state),
vec!["ssh root@ip1 echo \\$HOSTNAME"]
);
}
} }

View file

@ -11,6 +11,7 @@ pub enum AppEvent {
Tick, Tick,
Key(event::KeyEvent), Key(event::KeyEvent),
Mouse(event::MouseEvent), Mouse(event::MouseEvent),
Paste(String),
} }
pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> { pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> {
@ -18,6 +19,7 @@ pub fn poll_event(timeout: Duration) -> io::Result<Option<AppEvent>> {
match event::read()? { match event::read()? {
Event::Key(key) => Ok(Some(AppEvent::Key(key))), Event::Key(key) => Ok(Some(AppEvent::Key(key))),
Event::Mouse(mouse) => Ok(Some(AppEvent::Mouse(mouse))), Event::Mouse(mouse) => Ok(Some(AppEvent::Mouse(mouse))),
Event::Paste(text) => Ok(Some(AppEvent::Paste(text))),
_ => Ok(Some(AppEvent::Tick)), _ => Ok(Some(AppEvent::Tick)),
} }
} else { } else {
@ -50,6 +52,7 @@ pub fn handle_event(app: &mut App, event: AppEvent) -> bool {
} }
_ => true, _ => true,
}, },
AppEvent::Paste(text) => handle_paste_event(app, &text),
} }
} }
@ -239,6 +242,35 @@ fn pop_from_active_input(state: &mut CustomState) {
} }
} }
fn handle_paste_event(app: &mut App, text: &str) -> bool {
match app.screen {
Screen::Main => true,
Screen::Custom => {
let Some(state) = app.custom_state.as_mut() else {
app.exit_custom();
return true;
};
match state.focus {
CustomFocus::Input => state.command.push_str(text),
CustomFocus::PreCommand => state.pre_command.push_str(text),
CustomFocus::Lines => {}
}
true
}
Screen::Search => {
let Some(state) = app.search_state.as_mut() else {
app.exit_search();
return true;
};
// Search queries are single-line; keep only the first pasted line.
let query = text.lines().next().unwrap_or(text);
state.query.push_str(query);
app.update_search();
true
}
}
}
fn handle_search_event(app: &mut App, key: event::KeyEvent) -> bool { fn handle_search_event(app: &mut App, key: event::KeyEvent) -> bool {
let Some(state) = app.search_state.as_mut() else { let Some(state) = app.search_state.as_mut() else {
app.exit_search(); app.exit_search();

View file

@ -14,7 +14,9 @@ use std::time::Duration;
use clap::Parser; use clap::Parser;
use crossterm::{ use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture}, event::{
DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture,
},
execute, execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
}; };
@ -54,7 +56,12 @@ fn main() -> io::Result<()> {
enable_raw_mode()?; enable_raw_mode()?;
let mut stdout = io::stdout(); let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; execute!(
stdout,
EnterAlternateScreen,
EnableMouseCapture,
EnableBracketedPaste
)?;
let backend = CrosstermBackend::new(stdout); let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?; let mut terminal = Terminal::new(backend)?;
@ -64,7 +71,8 @@ fn main() -> io::Result<()> {
execute!( execute!(
terminal.backend_mut(), terminal.backend_mut(),
LeaveAlternateScreen, LeaveAlternateScreen,
DisableMouseCapture DisableMouseCapture,
DisableBracketedPaste
)?; )?;
terminal.show_cursor()?; terminal.show_cursor()?;

View file

@ -173,11 +173,15 @@ fn draw_search(f: &mut Frame, app: &mut App) {
} else { } else {
Style::default() Style::default()
}; };
ListItem::new(format!( let label = if result.command.is_empty() {
"[{}] {} — {}", format!("[{}] {} — {}", result.group, result.file, result.section)
result.group, result.file, result.section } else {
)) format!(
.style(style) "[{}] {} — {} — {}",
result.group, result.file, result.section, result.command
)
};
ListItem::new(label).style(style)
}) })
.collect(); .collect();