pyc-shell

Crates.iopyc-shell
lib.rspyc-shell
version0.3.0
sourcesrc
created_at2020-05-26 19:04:25.171458
updated_at2020-11-14 10:55:41.617596
descriptionPyc is a simple CLI application, which allows you to perform shell commands in cyrillic and other alphabets, through command and output transliteration.
homepagehttps://github.com/ChristianVisintin/Pyc
repositoryhttps://github.com/ChristianVisintin/Pyc
max_upload_size
id246320
size536,909
Christian Visintin (veeso)

documentation

https://docs.rs/pyc-shell

README

Pyc

License: GPL v3 Stars Issues Crates.io Build codecov

~ Use your alphabet with your favourite shell ~
Developed by Christian Visintin
Current version: 0.3.0 (14/11/2020)



About Рус

Рус (Pronounced "Rus") is a simple CLI application, written in Rust, which allows you to interface with your favourite shell, giving you the possibility to perform commands in cyrillic and other alphabets, through command and output transliteration.

Why Рус

Well, basically I started studying russian and to become practical with the cyrillic alphabet I wanted to use it whenever was possible, even while typing on the console; but then I found out that there's not a single console which allow people which use a different alphabet to use it, so I came out with this project.

Pyc's goal

The goal of this project is to give everybody who uses an alphabet different from latin, to use the computer shell without having to switch the keyboard layout.

How it works

Basically Рус is a shell interface, which means that it reads the user input, it converts it according to the configured alphabet and then it sends the translated input to the shell which processes it; then the output is read from the shell's stdout and is (if enabled) translated back to the original alphabet and printed to user's output.

Features

  • Different alphabets support
  • Implementing translators for other alphabets is extremely easy.
  • Conversion of both input and output.
  • Escaping for latin strings.
  • Interactive, oneshot and file modes.
  • Prompt is fully customizable
  • Shell aliases support
  • Supports bash, sh, zsh and fish
  • Allows you to use your shell aliases and functions
  • Text editors support

Supported alphabets

Planned alphabets

  • in Devanagari - Planned for 2021 (0.4.0)
  • mk Macedonian Cyrillic - Planned for 2021 (0.4.0)
  • me Montenegrin Cyrillic - Planned for 2021 (0.4.0)

Other alphabets are not planned for the moment.


Can't find yours? Contribute to the project implementing it 😀 ! Read More

Installation

If you're considering to install Pyc I want to thank you 💛 ! I hope this project can be useful for you!
If you want to contribute to this project, don't forget to check out our contribute guide. Read More

Cargo

#Install pyc through cargo
cargo install pyc-shell
#Install configuration
mkdir -p $HOME/.config/pyc/
#Copy configuration file from repository
wget -O $HOME/.config/pyc/pyc.yml https://raw.githubusercontent.com/ChristianVisintin/Pyc/master/pyc.yml

Deb / Rpm

Coming soon

Usage

Pyc can be started with the following options:

  • -c, --command <command> Runs the provided command and return
  • -C, --config <config> Specify Pyc configuration file location.
  • -l, --lang <ru|рус> Specify the language used by Pyc
  • -s, --shell </bin/bash> Specify the shell binary path
  • -v, --version Print version info
  • -h, --help Print help page

Configuration

Pyc supports a user configuration which adds some features and customization. The configuration must be stored at $HOME/.config/pyc/pyc.yml. A default configuration is located in the repository in pyc.yml.

Let's see how the configuration is written

language: ru
shell:
  exec: "bash"
  args:
    - "-l"
alias:
  - чд: cd
  - пвд: pwd
  - уич: which
output:
  translate: true
prompt:
  prompt_line: "${USER} on ${HOSTNAME} in ${WRKDIR} ${GIT_BRANCH} ${GIT_COMMIT} ${CMD_TIME}"
  history_size: 256
  translate: false
  break:
    enabled: true
    with: "❯"
  duration:
    min_elapsed_time: 2000
  rc:
    ok: "✔"
    error: "✖"
  git:
    branch: "on  "
    commit_ref_len: 8
    commit_prepend: "("
    commit_append: ")"
  • shell: Shell configuration
    • exec: shell binary (can be absolute or in PATH)
    • args: shell CLI arguments
  • alias: list of alias. When the first word of a command is one of the configured alias, it is automatically replaced with the associated latin expression.
  • language: Pyc default language (can be overridden with cli options)
    • Belarusian: by | бел
    • Bulgarian: bg | бг | блг
    • Russian: ru | рус
    • Serbian: rs | срб
    • Ukrainian : ua | укр
  • output: output configuration
    • translate: indicates to pyc whether the output has to be converted to cyrillic or not
  • prompt: Prompt configuration (See Prompt Configuration)
    • prompt_line: String describing the prompt line syntax
    • history_size: Pyc history size
    • translate: should the prompt line be translated
    • break: Break line after prompt
      • enabled: should the prompt break or not?
    • duration: command duration configuration
      • enabled: module enabled
      • with: break with provided string
    • rc: return code module
      • ok: string to write in case of successful command
      • error: string to write in case of error
    • git: git module
      • branch: string to write before writing branch name
      • commit_ref_len: length of commit reference
      • commit_prepend: string to prepend to commit ref
      • commit_append: string to append to commit ref

Prompt Line Configuration

The prompt configuration is used to setup the prompt line when using the interactive mode. The prompt configuration provides parameters to customize the line printed when interacting with the shell. In addition to the parameters described before, here the prompt line keys are illustrated.

Each prompt line key must have the following syntax ${VAR_NAME}

General keys

Key Description
USER Username
HOSTNAME Hostname
WRKDIR Current directory
LANG The language configured for Pyc in flag colors of the associated country
CMD_TIME Execution time of the last command if >= min_elapsed_time
RC Shows the string associated to a successful exitcode or to an error

Colors keys

Key Description
KYEL Yellow
KRED Red
KBLU Blue
KMAG Magenta
KGRN Green
KWHT White
KBLK Black
KGRY Gray
KBOLD Bold text
KBLINK Blinking text
KSELECT Selected text
KRST Reset

Git keys

Key Description
GIT_BRANCH The current git branch
GIT_COMMIT The current git commit ref

Documentation

The developer documentation can be found on Rust Docs at https://docs.rs/pyc-shell

The documentation related to translator modules can be instead found here:

Escape text

It is possible to escape texts (only when the prompt line is visible, not while a program is running), preventing it from being transliterated to latin. To do so, just use quotes:

#Touch foobar.txt
тоуч фообар.ткст

Escaped:

#Touch фообар.мксм
тоуч "фообар.ткст"

Known issues

Unicode Replacement character while typing (�)

If you see this character when you're typing cyrillic characters, these steps may fix the problem:

Reconfigure locales:

sudo dpkg-reconfigure locales

Select all the locales you need from the list, but most important select ru_RU.UTF-8.

Regenerate locales:

sudo locale-gen

If this didn't solve your problem it's probably an issue of your terminal. Up to now I've found out that some terminals just don't let you type non-ascii characters when executing an application. These are the terminals which I've used or have been reported which DON'T work.

  • Windows Terminal (Older version I guess, I noticed it has been fixed around april 2020).

Cd command in oneshot mode doesn't work

Yep. Unfortunately it seems there's no way to make it work in oneshot mode. If you know a possible way to make it work, please contribute to this project to implement it.

Fish doesn't work

Uuhm, I don't know why, I need some time to investigate why, maybe it doesn't use stdout to write (?).

Shell alias not working

I will fix this soon

Text editors dont' work

An integrated text editor will be available in 0.4.0


Upcoming Features and Releases

Development Status

Pyc-shell is an active project, development effort is minimum at the moment due to my spare time and to the little interest from the community. In addition I'm working on other bigger projects.

Planned releases

Pyc 0.4.0

Planned for 2021

  • translators:
    • Devanagari
    • Macedonian
    • Montenegrin
  • Fish support
  • Text editors support

Contributions

Contributions are welcome! 😉

If you think you can contribute to Рус, please follow Рус's contributions guide

Changelog

See the enire changelog HERE


License

Licensed under the GNU GPLv3 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.gnu.org/licenses/gpl-3.0.txt

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can read the entire license HERE

Commit count: 214

cargo fmt