ryochack / peep Goto Github PK
View Code? Open in Web Editor NEWThe CLI text viewer tool that works like less command on small pane within the terminal window.
License: MIT License
The CLI text viewer tool that works like less command on small pane within the terminal window.
License: MIT License
By default, when less exits, the text it was displaying is cleared and the user's terminal window is returned to the state it was in prior to less being invoked.
I think this is a vital feature of less, and of short-lived interactive CLI utilities in general (programs like fzf, bat, etc. also implement this feature).
Peep's selling point seems to be its focus on not displacing the surrounding terminal context; I think that the functionality I just described would be very complementary to this focus.
As a workaround, I wrote a little wrapper script which basically accomplishes this (requires ncurses):
#!/bin/bash
set -euo pipefail
function isset_help() {
local opt
for opt in "$@"; do
case "$opt" in
--)
echo 0
return 0
;;
--help)
echo 1
return 0
;;
esac
done
while getopts ':h' opt "$@"; do
case "$opt" in
h)
echo 1
return 0
;;
*)
continue
;;
esac
done
echo 0
return 0
}
function main() {
local -i h
h=$(isset_help "$@")
[[ $h -eq 0 ]] && tput sc
peep "$@"
local -i c=$?
[[ $c -eq 0 && $h -eq 0 ]] && tput rc
return $c
}
main "$@"
Before:
After:
It's far from ideal and doesn't work when the cursor line is at or within --lines
of the bottom of the terminal window, but it should give you an idea of what I am proposing.
Thanks for creating this project, I really love using it!
Whenever I use peep
to read from stdin cpu spikes and it seems to freeze.
Homebrewでインストールできたらいいなと思ったりしますが、いかがでしょうか?パッケージ作るのはそんな大きなハードルではないはずですし、よかったら作ってあげます。
The output of peep contains escape sequences.
This is a problem when using pipe or redirect.
$ cargo run -- -n 4 Cargo.toml > out.txt
$ vim out.txt
�[1G�[2K
lines�[2K
lines�[2K
lines�[2K
lines�[2K�[4F [package]�[m
name = "peep"�[m
edition = "2018"�[m
version = "0.1.4"�[m
So, I will add raw-output-mode to peep to fix it.
If you could implement the support of ansi color coding that would be fantastic. Right now if I use color codes, they get printed literally:
echo -e "\x1b[38;5;208mTEST" | peep
Output:
[38;5;208mTEST
Thank you so much
Can you please add a command to open the file in the default editor ($EDITOR
)? Preferably bind to the e
key.
標準アウトプットはTTYじゃないとき、パニックしてしまいます。もっとましなエラーメッセージがでたらいいなと思います。なお、TTYじゃない場合は初期設定のサイズのウィンドウで出力を出して終了するのもありかなと思ったりしますが、いかがでしょうか。
peep Hello.txt | cat
thread 'main' panicked at 'terminal_size get error: Os { code: 25, kind: Other, message: "Inappropriate ioctl for device" }', src/libcore/result.rs:999:5
stack backtrace:
0: std::panicking::default_hook::{{closure}}
1: std::panicking::default_hook
2: std::panicking::rust_panic_with_hook
3: std::panicking::continue_panic_fmt
4: rust_begin_unwind
5: core::panicking::panic_fmt
6: core::result::unwrap_failed
7: peep::pane::Pane::new
8: peep::app::App::run
9: peep::main
10: std::rt::lang_start::{{closure}}
11: std::panicking::try::do_call
12: __rust_maybe_catch_panic
13: std::rt::lang_start_internal
14: main
Could you please consider adding the following alternative key bindings?
DownArrow Scroll down
UpArrow Scroll up
PageDown Scroll down a page
PageUp Scroll up a page
RightArrow Scroll horizontally right
LeftArrow Scroll horizontally left
Home Go to the beggining of line
End Go to the end of line
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.