5个稳定版本
使用旧Rust 2015
1.7.1 | 2019年12月8日 |
---|---|
1.7.0 | 2019年11月29日 |
1.6.1 | 2019年3月17日 |
1.6.0 | 2019年3月2日 |
1.5.0 | 2017年1月9日 |
#565 in 文本处理
40 每月下载量
63KB
1.5K SLoC
Heatseeker是对Gary Bernhardt的
重写的目的是将Selecta的简单性和通用性与原生代码的速度和可移植性结合起来。
安装
可以从GitHub 下载最新版本的编译二进制文件.
要在Windows上使用Chocolatey安装,请运行
choco install heatseeker
要在OS X上使用Homebrew安装,请运行
brew tap rschmitt/heatseeker
brew install heatseeker
要在Linux上安装,请运行
wget -q -O - https://github.com/rschmitt/heatseeker/releases/download/v1.7.1/heatseeker-v1.7.1-x86_64-unknown-linux-musl.tar.gz | tar -zxf -
# To install globally:
sudo install hs /usr/local/bin/
# To install in your home directory:
install -D hs ~/bin/hs
使用
Heatseeker支持与Selecta基本相同的键,以及一些用于支持多选的其他键
- ^T 选择或取消选择当前高亮的匹配项
- Enter 选择当前高亮的匹配项,或之前使用^T高亮的任何匹配项
- ^G、^C 或 Escape 退出不选择匹配项
- Backspace 删除最后输入的查询字符
- ^U 删除整个查询
- ^N、下箭头或Tab 高亮下一个匹配项
- ^P 或上箭头 高亮上一个匹配项
PowerShell
使用PSReadLine,可以直接将Heatseeker集成到Windows命令行中。将以下代码添加到您的 $profile
文件中。可以使用Ctrl-S调用文件选择器。
$ps = $null
try {
# On Windows 10, PSReadLine ships with PowerShell
$ps = [Microsoft.PowerShell.PSConsoleReadline]
} catch [Exception] {
# Otherwise, it can be installed from the PowerShell Gallery:
# https://github.com/lzybkr/PSReadLine#installation
Import-Module PSReadLine
$ps = [PSConsoleUtilities.PSConsoleReadLine]
}
Set-PSReadlineKeyHandler `
-Chord 'Ctrl+s' `
-BriefDescription "InsertHeatseekerPathInCommandLine" `
-LongDescription "Run Heatseeker in the PWD, appending any selected paths to the current command" `
-ScriptBlock {
$choices = $(Get-ChildItem -Name -Attributes !D -Recurse | hs)
$ps::Insert($choices -join " ")
}
Vim
使用一些Vimscript,您可以使用Heatseeker在Vim中打开文件,而无需任何特殊插件。
Selecta README中的Vimscript 示例基本上可以正常工作,但最好修改它们以用于Heatseeker,以便添加对Windows和多选的支持。
function! HeatseekerCommand(choice_command, hs_args, first_command, rest_command)
try
let selections = system(a:choice_command . " | hs " . a:hs_args)
catch /Vim:Interrupt/
redraw!
return
endtry
redraw!
let first = 1
for selection in split(selections, "\n")
if first
exec a:first_command . " " . selection
let first = 0
else
exec a:rest_command . " " . selection
endif
endfor
endfunction
if has('win32')
nnoremap <leader>f :call HeatseekerCommand("dir /a-d /s /b", "", ':e', ':tabe')<CR>
else
nnoremap <leader>f :call HeatseekerCommand("find . ! -path '*/.git/*' -type f -follow", "", ':e', ':tabe')<cr>
endif
同样也适用于缓冲区选择。在Windows上这有点复杂,因为将缓冲区列表发送到Heatseeker的最直接方式是写入一个临时文件。
function! HeatseekerBuffer()
let bufnrs = filter(range(1, bufnr("$")), 'buflisted(v:val)')
let buffers = map(bufnrs, 'bufname(v:val)')
let named_buffers = filter(buffers, '!empty(v:val)')
if has('win32')
let filename = tempname()
call writefile(named_buffers, filename)
call HeatseekerCommand("type " . filename, "", ":b", ":b")
silent let _ = system("del " . filename)
else
call HeatseekerCommand('echo "' . join(named_buffers, "\n") . '"', "", ":b", ":b")
endif
endfunction
" Fuzzy select a buffer. Open the selected buffer with :b.
nnoremap <leader>b :call HeatseekerBuffer()<cr>
项目状态
- Heatseeker 已完全实现。它在所有支持的平台上运行顺畅,包括 Windows;它甚至已经在 Windows 10 技术预览版上成功进行了烟测试(包括构建和运行)。
- Heatseeker 不需要不稳定的语言特性,可以使用稳定的 Rust 工具链进行编译。
构建
通过调用以下命令执行构建:
$ cargo build --release
生成的二进制文件将位于 target/release
目录中。(注意,省略 --release
标志会导致编译器优化被跳过;这会加快编译速度,但会导致程序运行非常缓慢。)可以通过运行以下命令来调用单元测试:
$ cargo test
依赖项
~1MB
~14K SLoC