Giter Club home page Giter Club logo

peep's Introduction

crates.io test

peep

peep is the CLI text viewer tool.
This tool works interactively like less command on small pane within the terminal window.
And leave the output on the terminal when quit like cat command.

Demos

Pane on Terminal Window

peep can view text file freely.

Pane on Terminal Window

Read from Pipe

Pipe Input

Print Line Number

Print Line Number

Resize Pane

Resize Pane

Incremental Regex Search

Incremental Regex Search

Wide Width Character Support

Wide Width Character Support

Follow Mode

peep has the follow mode that can monitor file updates and read them continuously like tail -f or less +F.
Also, peep can switch between the normal mode and follow mode with F command.

Follow Mode

Highlighting on Follow Mode

peep can highlight the regex word on the follow mode.

Highlighting on Follow Mode

Text Line Wrapping

Text Line Wrapping

Installation

cargo install peep

If you don't have Rust toolchains, please refer to The Rust Programming Language.

Or, you can download peep binary file from GitHub peep Releases :)

Usage

peep [OPTION]... [FILE]

Options

-n, --lines LINES        set height of pane
-s, --start START        set start line of data at startup
-t, --tab-width WIDTH    set tab width
-N, --print-line-number  print line numbers
-f, --follow             output appended data as the file grows
-h, --help               show this usage
-v, --version            show version

Commands

Format

KEY-BIND            OPERATION

Example 1

0 Ctr-a             Go to the beggining of line

Type 0 OR Ctrl-a, then Go to the beggining of line.

Example 2

(num)+              Increment screen height

(num) means that entering a number is optional.
If you omit the number input, the number will be processed as 1.

Example 3

[num]=              Set screen height to [num]

[num] means that entering a number is mandatory.

Commands on Normal Mode

(num)j Ctr-j Ctr-n  Scroll down
(num)k Ctr-k Ctr-p  Scroll up
(num)d Ctr-d        Scroll down half page
(num)u Ctr-u        Scroll up half page
(num)f Ctr-f SPACE  Scroll down a page
(num)b Ctr-b        Scroll up a page
(num)l              Scroll horizontally right
(num)h              Scroll horizontally left
(num)L              Scroll horizontally right half page
(num)H              Scroll horizontally left half page
0 Ctr-a             Go to the beggining of line
$ Ctr-e             Go to the end of line
g                   Go to the beggining of file
G                   Go to the end of file
[num]g [num]G       Go to line [num]
/pattern            Search forward in the file for the regex pattern
n                   Search next
N                   Search previous
q Ctr-c             Quit
Q                   Quit with clearing pane
(num)+              Increment screen height
(num)-              Decrement screen height
[num]=              Set screen height to [num]
#                   Toggle line number printing
!                   Toggle line wrapping
ESC                 Cancel
F                   Toggle to follow mode

Commands on Follow Mode

/pattern            Highlight the regex pattern
q Ctr-c             Quit
(num)+              Increment screen height
(num)-              Decrement screen height
[num]=              Set screen height to [num]
#                   Toggle line number printing
!                   Toggle line wrapping
ESC                 Cancel
F                   Toggle to normal mode

Supported Platforms

  • Linux
  • MacOS

License

MIT License. Please refer to LICENSE file.

peep's People

Contributors

mic92 avatar moredread avatar ryochack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

peep's Issues

Feature: Support clearing peep output on exit

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:

2021-01-12_23-43-44_Alacritty.mp4

After:

2021-01-12_23-47-02_Alacritty.mp4

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!

Support ansi color codes

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

Fix Inappropriate ioctl for device

標準アウトプットは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

Support raw output mode

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.

Support moving with arrows, PageUp, PageDown, …

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.