Skip to content

Commit

Permalink
feat: add --tmux flag (deprecates sk-tmux, fixes #596) (#603)
Browse files Browse the repository at this point in the history
* feat: add `--tmux` flag (deprecates sk-tmux, fixes #596)

* clippy & fmt

* chore: generate doc & completions

* fix: copy stdin to tmux call

* fix: ignore stdin if not piped

* fix: stream stdin instead of punctual copy

* remove tmp dir & clippy

* fmt

* test: add basic tmux test

* fix tests

* use regex to fix tests on macos

* add unittests

* add deprecation warning to the readme

* use tmux flag in key-bindings

* fix tests on macos

* chore: improve PR ci (#617)

* Bump unicode-width from 0.1.14 to 0.2.0 (#616)

Bumps [unicode-width](https://github.com/unicode-rs/unicode-width) from 0.1.14 to 0.2.0.
- [Commits](unicode-rs/unicode-width@v0.1.14...v0.2.0)

---
updated-dependencies:
- dependency-name: unicode-width
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump nix from 0.25.1 to 0.29.0 (#614)

Bumps [nix](https://github.com/nix-rust/nix) from 0.25.1 to 0.29.0.
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](nix-rust/nix@v0.25.1...v0.29.0)

---
updated-dependencies:
- dependency-name: nix
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump env_logger from 0.9.3 to 0.11.5 (#615)

Bumps [env_logger](https://github.com/rust-cli/env_logger) from 0.9.3 to 0.11.5.
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](rust-cli/env_logger@v0.9.3...v0.11.5)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: LoricAndre <57358788+LoricAndre@users.noreply.github.com>

* chore: improve PR ci

* disable cache on fmt job

* add title check

* clean

* Create pr.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: LoricAndre <loric.andre@pm.me>

* revert mangen & compgen for merge

* merge master

* fix

* revert readme merge issues

* make TmuxOptions private

* directly invoke tmux

* better handling of tmux

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: LoricAndre <loric.andre@pm.me>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent be53f1f commit a2d8c3f
Show file tree
Hide file tree
Showing 11 changed files with 508 additions and 38 deletions.
157 changes: 145 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ skim provides a single executable: `sk`. Anywhere you would want to use
The skim project contains several components:

1. `sk` executable -- the core.
2. `sk-tmux` -- script for launching `sk` in a tmux pane.
2. **DEPRECATED in favor of `sk --tmux`** `sk-tmux` -- script for launching `sk` in a tmux pane.
3. Vim/Nvim plugin -- to call `sk` inside Vim/Nvim. Check [skim.vim](https://github.com/skim-rs/skim/blob/master/plugin/skim.vim) for Vim support.

## Package Managers
Expand Down
1 change: 1 addition & 0 deletions bin/sk-tmux
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

# sk-tmux: starts sk in a tmux pane
# usage: sk-tmux [LAYOUT OPTIONS] [--] [SK OPTIONS]
echo "[WRN] This script is deprecated in favor or \`sk --tmux\` and will be removed in a later release" >&2

fail() {
>&2 echo "$1"
Expand Down
2 changes: 2 additions & 0 deletions skim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ crossbeam = "0.8.2"
beef = "0.5.2" # compact cow
defer-drop = "1.3.0"
indexmap = "2.6.0"
rand = "0.8.5"
which = "7.0.0"

[features]
default = ["cli"]
Expand Down
36 changes: 18 additions & 18 deletions skim/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,28 @@ fn sk_main() -> Result<i32, SkMainError> {
output_ending: String::from(if opts.print0 { "\0" } else { "\n" }),
};

//------------------------------------------------------------------------------
// read from pipe or command
let rx_item = if !io::stdin().is_terminal() {
let rx_item = cmd_collector.borrow().of_bufread(BufReader::new(std::io::stdin()));
Some(rx_item)
} else {
None
};

//------------------------------------------------------------------------------
// filter mode
if opts.filter.is_some() {
return Ok(filter(&bin_options, &opts, rx_item)?);
}

//------------------------------------------------------------------------------
// output

let Some(result) = Skim::run_with(&opts, rx_item) else {
return Ok(0);
let Some(result) = (match opts.tmux {
Some(_) => crate::tmux::run_with(&opts),
None => {
// read from pipe or command
let rx_item = if !io::stdin().is_terminal() {
let rx_item = cmd_collector.borrow().of_bufread(BufReader::new(std::io::stdin()));
Some(rx_item)
} else {
None
};
// filter mode
if opts.filter.is_some() {
return Ok(filter(&bin_options, &opts, rx_item)?);
}
Skim::run_with(&opts, rx_item)
}
}) else {
return Ok(135);
};

if result.is_abort {
return Ok(130);
}
Expand Down
1 change: 1 addition & 0 deletions skim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub mod reader;
mod selection;
mod spinlock;
mod theme;
pub mod tmux;
mod util;

//------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions skim/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,6 @@ pub struct SkimOptions {
#[arg(long, short, help_heading = "Scripting")]
pub filter: Option<String>,

/// Reserved for later use
///
/// Run in a tmux popup
///
/// Format: sk --tmux <center|top|bottom|left|right>[,SIZE[%]][,SIZE[%]]
Expand Down
Loading

0 comments on commit a2d8c3f

Please sign in to comment.