Skip to content

A Vim-ish terminal emulator written and extendable in Python.

License

Notifications You must be signed in to change notification settings

Kharacternyk/viter

Repository files navigation

screenshot.png

Viter is a terminal emulator written and expandable in Python. It features Vim-like modes, key bindings, and status line and can act like a pager.

Installation

AUR

Install theviter-gitAUR package.

Manual installation

Viter requires VTE and PyGObject. They are packaged asPython -gobjectandvte3on Arch. Look for similarly named packages if you use another GNU/Linux distribution.

Usage

Runviterto launch the default shell in Viter. Runviter program [args]to launch programin Viter with[args](may be empty). Substituteviterfor /path/to/this/repo/viter.pyif you didn't use AUR to install Viter.

Viter starts up inNORMALmode where it behaves just like any other terminal emulator. PressCtrl+Shift+Spaceto switch toDETACHEDmode and access most of the features (seeKey bindingsandCommand interpreter). PressEscapeto return toNORMAL mode.

Key bindings

  • Switching modes:
    • Escape:switch toNORMALmode
    • Ctrl+Shift+Space:switch toDETACHEDmode
  • Navigating the scrollback
    • j:one line down
    • k:one line up
    • J:half page down
    • K:half page up
    • g:to the beginning
    • G:to the end
  • Zooming
    • +/=:make the font 25% larger
    • -:make the font 25% smaller
  • Search
    • /patternEnter:set the search pattern topattern
    • n:to the next occurrence of the search pattern
    • N:to the previous occurrence of the search pattern
  • Clipboard
    • c:copy selected text
    • ycharactersEnter: yank the first line that starts withcharacters(not counting whitespace)
    • vcharacters",countEnter: yank the block ofcountlines, where the first line starts withcharacters (not counting whitespace)
    • V:yank the whole window
    • Y:yank the message in the bar
    • p:paste
    • Ctrl+Shift+C/Ctrl+Shift+V:copy/paste inNORMALmode
  • Command line
    • :commandEnter: executecommandin the Python environment that executes the code of Viter
    • eexpressionEnter:evaluateexpressionand print the result in the bar

Command interpreter

A status bar at the bottom of the window is shown when the user is inDETACHEDmode. It displays data in the format of <Zoom> [TopLineNum-BottomLineNum] (TotalLines) |TerminalHeightxTerminalWidth|while being unfocused.

After the user typed some text into it and pressedEnter,the entered text is executed by Viter usingexec(a Python built-in).

Use thewinglobal variable to interact with the window. Some key bindings insert a call to one of the methods ofwin,for example:

  • /insertswin.search( "" )and places the cursor between "".
  • yinsertswin.yank_line( "" )and places the cursor between "".
  • einsertswin.echo()and places the cursor between ().

winis an instance of theWindowclass that inheritsGtk.Window. Calls to the inherited methods are also valid, for example:

  • win.set_title( "Terminal" )to set the title of the window toTerminal.
  • win.close()to close the window.
  • win.fullscreen()to make the window fullscreen.

winhas thetermfield of typeVte.Terminal.See the Gtk documentation on Gtk.Window[1]andVte.Terminal[2]for the full list of the methods and fields. See the source of Viter to see the methods that are provided additionally to that ofGtk.Window.

Pager mode

If Viter is invoked asviter-pager,Viter acts like a pager. It starts up directly intoDETACHEDmode. If there is no arguments,stdinis read, otherwise the arguments are interpreted as file names.

Here are some examples of preprocessing the input:

  • pygmentize | viter-pager— syntax highlighting.
  • ul | viter-pager— converting overstriking to properly underlined text.

If you want to use Viter as your$MANPAGER,make sure to cook the input viaul. The pages will lose formating (underlining, bold text) otherwise.

Configuration

Viter looks for the configuration file in the following order:

  • $VITER_CONFIG
  • $XDG_CONFIG_HOME/viter/viterrc.py
  • $HOME/.config/viter/viterrc.py

The first file that exists is read and then passed toexecjust before Viter enters the main loop. The file must be a valid Python script.

See an example of the configuration filehere.

About

A Vim-ish terminal emulator written and extendable in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages