All Projects → imomaliev → ptrepl

imomaliev / ptrepl

Licence: MIT License
Run command as REPL with completion(based on prompt_toolkit)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ptrepl

Replay.jl
Replay your REPL instructions
Stars: ✭ 24 (-36.84%)
Mutual labels:  repl
text-engine
A browser-based text adventure game engine and sample game
Stars: ✭ 146 (+284.21%)
Mutual labels:  repl
clojure
Practicalli Clojure REPL Driven Development
Stars: ✭ 40 (+5.26%)
Mutual labels:  repl
ocamline
👨🏻‍💻 Command line interface for user input
Stars: ✭ 32 (-15.79%)
Mutual labels:  repl
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (+194.74%)
Mutual labels:  repl
aik
Frontend Playground
Stars: ✭ 43 (+13.16%)
Mutual labels:  repl
burrow
burrow is a helper for building and managing a gopher hole
Stars: ✭ 43 (+13.16%)
Mutual labels:  bash-completion
moses-smt
Dock You a Moses: Moses Statistical MT in a container
Stars: ✭ 12 (-68.42%)
Mutual labels:  repl
repl
Framework Agnostic REPL For Node.js. Used by AdonisJS
Stars: ✭ 76 (+100%)
Mutual labels:  repl
replay-csharp
An editable C# REPL (Read Eval Print Loop) powered by Roslyn and .NET Core
Stars: ✭ 69 (+81.58%)
Mutual labels:  repl
Clojure-Sublimed
Clojure support for Sublime Text 4
Stars: ✭ 268 (+605.26%)
Mutual labels:  repl
dirac-sample
An example integration of Dirac DevTools
Stars: ✭ 17 (-55.26%)
Mutual labels:  repl
pytezos
🐍 Python SDK & CLI for Tezos | Michelson REPL and testing framework
Stars: ✭ 93 (+144.74%)
Mutual labels:  repl
dotfiles
my dot files with git and docker extension for windows and linux
Stars: ✭ 13 (-65.79%)
Mutual labels:  bash-completion
repline
Haskeline wrapper for GHCi-like REPL interfaces
Stars: ✭ 98 (+157.89%)
Mutual labels:  repl
vue-code-view
A Vue 2 component like Vue SFC REPL `@vue/repl` : u can edit, run and preview the code effect display in real time on the web page.
Stars: ✭ 67 (+76.32%)
Mutual labels:  repl
lambda-dti
Interpreter of the ITGL with dynamic type inference
Stars: ✭ 18 (-52.63%)
Mutual labels:  repl
ts-c99-compiler
ANSI C 16bit Compiler + NASM Assembler + Intel 8086 / 80186 + X87 emulator written entirely in TypeScript
Stars: ✭ 78 (+105.26%)
Mutual labels:  repl
await-outside
Await outside of async functions
Stars: ✭ 19 (-50%)
Mutual labels:  repl
ReplCustoms
A database of users, posts, and comments from the ReplTalk API
Stars: ✭ 17 (-55.26%)
Mutual labels:  repl

ptrepl

https://travis-ci.com/imomaliev/ptrepl.svg?branch=master

About

Make REPL out of any bash command

  • has bash completion
  • has vi mode
  • has PS1 parsing(experimental)
  • stores history in $XDG_DATA_HOME/ptrepl/history
  • bash like history expansion
  • list history
  • command mode
  • aliases

Installation

Requires python>=3.6, prompt_toolkit>=2.0.7,<3.0.0, pygments

Recommended way of installation is via pipx

pipx install ptrepl

ptrepl vendors https://github.com/xonsh/py-bash-completion

Usage

Basic Usage

$ ptrepl --help
Usage: ptrepl [OPTIONS] COMMAND

Options:
--prompt TEXT  Override prompt
--help         Show this message and exit.
$ ptrepl git
$ git >
# to call "git status"
$ git > status
# if you need execute some other bash command see system mode below

Custom prompt command

$ ptrepl git --prompt g
$ g >

Multiword command

$ ptrepl "echo prefix"
$ echo prefix > 1
echo prefix 1

Config

Place settings file in :bash:$XDG_CONFIG_HOME/ptrepl/config.json

Here is example of config with enabled vi mode and git alias

{
    "settings": {
        "EXIT_COMMAND": "exit",
        "EDITING_MODE": "vi",
        "SHOW_MODE_IN_PROMPT": true,
        "EMACS_MODE_STRING": "@",
        "VI_INS_MODE_STRING": "+",
        "VI_CMD_MODE_STRING": ":",
        "READLINE_COMPLETION": false,
        "PARSE_PS1": false,
        "LOCAL_SHADA": false,
        "LOCAL_SHADA_PATH": "$PWD/.ptrepl/",
    },
    "alias": {
        "git st": "git status"
    }
}

Available settings

  • EXIT_COMMAND - change exit command
  • EDITING_MODE - choose mode vi/emacs
  • SHOW_MODE_IN_PROMPT - show editing mode string in prompt
  • EMACS_MODE_STRING - set emacs mode prompt string
  • VI_INS_MODE_STRING - set vi insert mode prompt string
  • VI_CMD_MODE_STRING - set vi command mode prompt string
  • READLINE_COMPLETION: use readline like completion instead of dropdown one
  • PARSE_PS1 {experimental} - will try to adgust ptrepl's prompt according to your PS1 setting
  • LOCAL_SHADA - store shada(history) in LOCAL_SHADA_PATH
  • LOCAL_SHADA_PATH - path to local shada

Default settings

{
    "EXIT_COMMAND": "exit",
    "EDITING_MODE": "emacs",
    "SHOW_MODE_IN_PROMPT": false,
    "EMACS_MODE_STRING": "@",
    "VI_INS_MODE_STRING": "(ins)",
    "VI_CMD_MODE_STRING": "(cmd)",
    "READLINE_COMPLETION": false,
    "PARSE_PS1": false,
    "LOCAL_SHADA": false,
    "LOCAL_SHADA_PATH": "$DIRENV_DIR/.direnv/ptrepl/",
}

Features

Parsing PS1(requires PARSE_PS1 set to true)

Here is how my bash prompt(PS1) looks like by default

{ptrepl} ~/Development/Python/ptrepl [master] |19:18:36 07-Feb-18|
+ ❯ ptrepl git
{ptrepl} ~/Development/Python/ptrepl [master] |19:20:15 07-Feb-18|
+ git ❯

Completion

$ ptrepl git
$ git > sta (press TAB)
# result
$ git > sta
        status
        stage
        stash

Readline like completion(requires READLINE_COMPLETION set to true)

$ ptrepl git
$ git > sta (press TAB)
# result
$ git > sta
stage  stash  status

System mode

$ ptrepl git
$ git > (press Escape + !)
# result
# you could enter your shell commands here
Shell command: ls

Command mode

$ ptrepl git
$ git > (press Escape + :)
# result
# you could enter your command mode commands here
# to list history
Command mode: history

Bash like history expansion

$ ptrepl git
$ git > status
# repeat last command
$ git > !!
# repeat 10th command
$ git > !10
# repeat 10th command from bottom of history stack
$ git > !-10

Bash like aliases

$ ptrepl git
$ git > (press Escape + :)
# you could enter your command mode commands here
# to list alias
Command mode: alias
alias "git st"="git status"
$ git > st

Similar projects

Written in Ruby

https://github.com/defunkt/repl

Written in Bash

https://github.com/joh6nn/shrepl

https://github.com/mchav/with

Written in Python

https://github.com/mbr/repl

https://github.com/renanivo/with

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].