NYAGOS - The hybrid Commandline Shell between UNIX & DOS

Build status GoDoc Go Report Card Github latest Releases

The Nihongo Yet Another GOing Shell

English / Japanese

NYAGOS is the commandline-shell written with the Programming Language GO and Lua.

demo-animation

There are some shells in Windows compatible with ones in UNIX.
But, most of them do not support Windows's traditional PATH-style like X:\DIR\FILE.EXT though a lot of applications need them as arguments.

So, I created a new shell like below:

  • UNIX-Like Shell
    • Keybinding
      • Features are bound to keys like Bash on default
      • Customized like
        • nyagos.key.c_u = "KILL_WHOLE_LINE" on %USERPROFILE%\.nyagos (Lua)
      • A lua-functions can be bound to a key like
        • nyagos.key.escape = function(this) nyagos.exec("start vim.exe") end
    • History (Ctrl-P and !-mark)
    • Alias
      • like DOSKEY
        • nyagos.alias["g++"]="g++.exe -std=gnu++17 $*"
      • ones implemented by Lua functions
        • nyagos.alias["lala"]=function(args) nyagos.exec("ls","-al",unpack(args)) end
    • Custom completions
            nyagos.complete_for["go"] = function(args)
                if #args == 2 then
                    return {
                        "bug","doc","fmt","install","run","version",
                        "build","env","generate","list","test","vet",
                        "clean","fix","get","mod","tool" }
                else
                    return nil -- files completion
                end
            end
  • Shell that follows the Windows' style like CMD.EXE
    • Windows' path format C:\path\to\file are able to be used.
    • Each drive has its own current directory.
    • copy,move and some dos-like built-in commands work.
    • No additional DLL are required.
    • Registry are not used.
  • Support Unicode. Windows unicode APIs are used.
    • Can paste unicode character on clipboard and edit them.
    • Unicode-literal %U+XXXX%
    • Prompt Macro $Uxxxx
  • Built-in ls
    • color support (-o option)
    • print hard-link,symbolic-link and junction's target-path
  • Support OS:
    • Windows 8.1 & 10
    • Linux (experimental)

Download Binary

Contents

Release note

Documents

  1. Install
  2. Option for NYAGOS
  3. Editor
  4. Built-in commands
  5. What is done on the Startup
  6. Substitution
  7. Lua functions extenteded by NYAGOS
  8. Uninstall
  9. How To Build

License

You can use, copy and modify under the New BSD License.

Acknowledgement

Author

Comments
  • Zero width char deletion problem?

    Zero width char deletion problem?

    Example 👨‍👩 This emoji is 👨 and ZWJ (zero width joiner) and 👩

    Paste nyagos console and back space. then remain display dot char But clear all chars(return to no error/no exec)


    notepadへコピーして確認できると思いますが(notepadなら👨‍👩を張り付けると👨 (ZWJ) 👩になると思います) この状態でのバックスペースでの絵文字の結合分解削除で、表示にゴミが残ります... なんとなくですが、👨 や 👩が2文字幅で表示不能文字(計4つ)が出てて、そこで合計3文字削除するので1文字残る感じです。

    削除する文字によってカーソル制御する+表示が2文字のとき、2文字分は後退させる必要はあるかもしれません。

    もっともUnicodeでいくと幅がきまらないものとか可変とかあるので、そういう仕様、でもいい気もしますが...

  • `nyagos.prompt`, `nyagos.alias`, `nyagos.on_command_not_found`の実行が排他になっていない

    `nyagos.prompt`, `nyagos.alias`, `nyagos.on_command_not_found`の実行が排他になっていない

    nyagos.prompt, nyagos.alias, nyagos.on_command_not_found この辺のluaを使うコマンド、フックなどの処理がぶつかるとpanicになるようです。

    重めの処理の代わりにsleepを入れた再現パターン用.nyagos https://gist.github.com/nocd5/2a0ed6c2dabf682e946a

    $ foo | bar
    

    を実行するとpanicで落ちます(barは存在しないコマンド)。

    以下デバッグした時のパッチですが Call関数に入れてるmutexは、あるとdead lockしてしまうので実際はNGですが 挙動の違いは確認できると思います https://gist.github.com/nocd5/f6f4fce05769fb299f53

  • "" in command line

    いつもありがとうございます. 少し前のバージョン以降,コマンドライン文字列における""が無視されるようになっているようですが,これを空文字列として扱う仕様に戻していただけないでしょうか? 例えば,オプション-oのオプション引数を期待する以下のコマンドラインで空文字列を指定したと解釈する仕様に戻してほしいと思っています(以前はそのように解釈され動作していたと思います): some_script -i ARGI-o "" あるいはなにか実装上の理由があるのでしょうか?

  • Feature request: command exec preexec/precmd(like postexec) hook

    Feature request: command exec preexec/precmd(like postexec) hook

    like https://github.com/rcaloras/bash-preexec

    現在、starship/starship を使うことでプロンプトを改善しています。

    code

    -- prompt
    nyagos.prompt = function(this)
      -- path,title,prompt
      local path = getCompressedPath(3):gsub('\\', '/')
      local title = path .. " - NYAGOS"
      local admin = nyagos.elevated()
      if admin then
        title = title .. "(admin)"
      end
    
      local prompt = ''
      if nyagos.which("starship") then
        prompt = prompt .. nyagos.eval('starship prompt 2> nul') ..  '$e[37;1m' .. ' '
      else
        local pathBlock = ''
        if admin then
          pathBlock = '$e[30;40;1m[$e[40;31;1m'..path..'$e[30;40;1m]$e[37;1m'
        else
          pathBlock = '$e[30;40;1m[$e[40;36;1m'..path..'$e[30;40;1m]$e[37;1m'
        end
        prompt = prompt .. makePrompt(pathBlock)
      end
    
      return nyagos.default_prompt(prompt,title)
    end
    

    (不明な関数などはおいといてください...)

    Image from Gyazo

    ただし、いくつかの機能が使えません。 その内の1つである、「コマンド実行から次のプロンプト復帰までの時間の表示(cmd_duration)」は、コンソールの処理実行前(preexec)に時間を記録し、再プロンプト表示時(bashはその前処理 precmd)の時間との差で表示を行っています。

    独自ログ系とか、機能としては汎用なので、機能追加について検討していただけたら、と思います。

  • 環境変数PATHに含まれているPATH中にある.bat ファイルが実行できない。

    環境変数PATHに含まれているPATH中にある.bat ファイルが実行できない。

    使用しているバージョンは Nihongo Yet Another GOing Shell 4.3.3_3-amd64 by go1.11.1 です。 バッチファイルだと下記のような出力が表示されます。 exec: "": executable file not found in %PATH%

    同じパスにある.exe は正常に実行できます。

    ls -la で見ても実行権限は付与されています。 -rwxa-- 23 Feb 5 2010 XXXX.bat*

  • box.lua : history cd でのboxの移動がおかしい

    box.lua : history cd でのboxの移動がおかしい

    rel #354

    $ d:
    $ cd repo
    <ctrl-x> -> h
    

    としたとき

    D:\repo D:\            
    D:\repo D:\            
    D:\repo D:\            
    D:\repo D:\            
    D:\repo D:\            
    D:\repo D:\            
    D:\repo D:\            
    

    のように、要素選択で表示が上にずりあがり、画面を埋めてしまうようです。

    $ ls | box
    

    は問題なく(1行に複数要素)、履歴のコマンド/git revも大丈夫(長いため1行1要素だから?)でした。

    Nihongo Yet Another GOing Shell 4.4.2_0-windows-amd64 by go1.12 (c) 2014-2019 NYAOS.ORG http://www.nyaos.org

  • don't work git/svn/hg in subcomplete.lua

    don't work git/svn/hg in subcomplete.lua

    不具合

    gitの補完が動かない

    経緯

    先日 gitの2.20.0でgit --helpがバグっていて、補完がうまくいかなくなる(というかプロセスが刺さる)ということがありました。 これは、git側不具合ですので、修正をwatchしており、2.20.1で修正されましたが、修正後でも補完できませんでした。

    デバッグ

    調べたところ、helpの表示文面が多少変化したため、コマンドパースに失敗しているようでした。

    修正

    このあと修正をPRします。 ただ、2つ問題があります。

    ロバストネス

    なるべく今後問題がでないようにロバストになるように修正しましたが、仕組み上表示フォーマットが大幅に変化したときはどうにもなりません。(既知の特性)

    git以外

    幸いすべてのコマンドがあるので、確認をすすめたのですが、svnとhgでも効きません。 テストコードを書いてみた限りだと、現行コードでパースできるはずなのですが...なので合せての修正はできませんでした。

    なおrcloneは問題ないです。


    修正リスト

    • [x] git
    • [x] svn
    • [x] hg
  • NYAGOS 4.2.5_beta でバッチファイルがエラーになります。

    NYAGOS 4.2.5_beta でバッチファイルがエラーになります。

    日本語ご容赦です。 以下のバッチファイルを 4.2.5_beta 上で実行するとバッチ処理完了後にエラーになります。

    @echo off
    setlocal
    
    setlocal enabledelayedexpansion
    
    set /a n = %~1
    set /a b1 = 0
    set /a b2 = 0
    
    if %n% == 1 echo 1: %b2% && goto :end
    echo 1: %b2%
    set /a b2 = 1
    if %n% == 2 echo 2: %b2% && goto :end
    echo 2: %b2%
    for /l %%i in (3, 1, %n%) do (
    	set /a fib = !b1! + !b2!
    	set /a b1 = !b2!
    	set /a b2 = !fib!
    	echo %%i: !b2!
    )
    
    :end
    endlocal && set /a fib = %b2%
    
    echo %~1th Fibonacci number is %fib%
    endlocal
    

    エラー内容はこんな感じです。

    $ fibonacci.cmd 10
    1: 0
    2: 1
    3: 1
    4: 2
    5: 3
    6: 5
    7: 8
    8: 13
    9: 21
    10: 34
    10th Fibonacci number is 34
    't' は、内部コマンドまたは外部コマンド、
    操作可能なプログラムまたはバッチ ファイルとして認識されていません。
    'd' は、内部コマンドまたは外部コマンド、
    操作可能なプログラムまたはバッチ ファイルとして認識されていません。
    指定されたパスが見つかりません。
    open C:\Users\userbame\AppData\Local\Temp\nyagos-6296.tmp: The system cannot find the file specified.
    

    ちょっと意地悪なコードかなぁという気もしますが,報告まで。

  • Recovery issue 390 Unicode

    Recovery issue 390 Unicode

    The issue 390 is forbidden. This is recovery issue from notification mail

    @.nu8 wrote (Sep. 21,2020)

    I see that 2 byte characters are currently supported:

    https://en.wikipedia.org/wiki/UTF-8

    that is, essentially everything up to U+07FF. Example:

    Ç (U+00C7) You can paste this or enter it with Alt + 128 on Windows, assuming Windows Terminal is being used. However it seems 3 and 4 byte characters are not supported. Example:

    ₧ (U+20A7) with PowerShell, you can paste the character, or on Windows you can enter as Alt + 158. However Yori does not accept paste or keyboard input of this character.

  • [regression] AltGR issue

    [regression] AltGR issue

    Hi,

    On a french keyboard, to type a pipe, we do AltGR+6. In the version 4.3.3_5, everything works fine. But in the later version, this character appears ^[|.

    It seems that it is some special character because It can't be erased properly.

    I try to use CTRL+ALT+6, I obtains the same result.

    This issue occurs with all AltGR+... combination.

    Thanks

  • 4.3.1_1 complettion args fail

    4.3.1_1 complettion args fail

    以下の環境でサブコマンド補完時に挙動がおかしいです。

    Nihongo Yet Another GOing Shell 4.3.1_1-amd64 by go1.10.3 Powered by GopherLua 0.1
    

    Windows 10 Pro 1803

    症状ですが、

    $ rclone listremotes
    exec: "map[rawargs:map[1:listremotes 0:rclone] 0:rclone 1:--ask-password=false 2:listremotes]": file does not exist
    $
    

    listremotes という補完は効きます。ただ実行時にエラーします。

    おそらく、次のaliasが悪さをしています。

    -- alias
    nyagos.alias.rclone = function(args)
      -- password detect
      local password = ''
      password = nyagos.eval('gpg --no-verbose --quiet --batch --decrypt --output - ~\\.password-store\\Storage\\Rclone.gpg 2> nul')
      nyagos.env["RCLONE_CONFIG_PASS"] = password
      table.insert(args,1,'--ask-password=false') -- prompt off
      assert(nyagos.rawexec(args))
    end
    

    table.insertした結果が内部にとって意図しないものになっているのでしょうか? それともトリッキーなrcloneの定義がうまく扱えないのでしょうか? 以前はrcloneのaliasとしてrclone.exeを呼べていたのですが...

    これもLua5.3互換問題かもしれませんので、症状の報告まで。

  • `start` command completion only work executable item

    `start` command completion only work executable item

    https://github.com/nyaosorg/nyagos/blob/ae9f3228e6652a1332ec66742f9fd8963ee6452e/completion/completion.go#L86

    Currently naygos built-in start has "completion" that completing arguments only executable file.

    But windows cmd start supported below these:

    • start "exec" , then open new window and execute "exec" (Win32GUI app directly start, CLI item run as new cmd) - now support
    • start "file", then open "file" with system file handler.
    • start "dir", then open "dir" explorer and other (directory handler)

    Nyagos start manually set and open file/dir OK, work fine.

    Suggestion:

    Support both document and directory add to start completion.

  • Add compatible functions with Lua 5.2-5.3

    Add compatible functions with Lua 5.2-5.3

    • [x] utf8.char
    • [x] utf8.charpattern
    • [ ] utf8.codepoint
    • [x] utf8.codes (implemented by #318)
    • [x] utf8.len
    • [ ] utf8.offset
    • [ ] bit32.arshift
    • [x] bit32.band (implemented by #318)
    • [ ] bit32.bnot
    • [x] bit32.bor
    • [ ] bit32.btest
    • [x] bit32.bxor
    • [ ] bit32.extract
    • [ ] bit32.lrotate
    • [ ] bit32.lshift
    • [ ] bit32.replace
    • [ ] bit32.rrotate
    • [ ] bit32.rshift
A component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product
A component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product

What is PolarDB Stack Daemon? PolarDB Stack Daemon is a component on PolarStack, a hybrid cloud Alibaba Cloud DBaaS product, and is designed mainly fo

Nov 21, 2021
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式

ap -- auto-pager ap 是一个 shell 工具,可以让其它 shell 命令的输出能够自动进入交互翻页模式。 ap 由两部分组成,一个 Go 语言编写的二进制程序,负责捕获命令的输出并支持翻页, 和一组 shell 脚本,负责为用户指定的命令清单创建与之同名的 wrapper。 经

Apr 12, 2022
Commandline Utility To Create Secure Password Hashes (scrypt / bcrypt / pbkdf2)

passhash Create Secure Password Hashes with different algorithms. I/O format is base64 conforming to RFC 4648 (also known as url safe base64 encoding)

Oct 10, 2022
Robust, flexible and resource-efficient pipelines using Go and the commandline
Robust, flexible and resource-efficient pipelines using Go and the commandline

Robust, flexible and resource-efficient pipelines using Go and the commandline Project links: Documentation & Main Website | Issue Tracker | Chat Why

Dec 25, 2022
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.

Read the docs at docs.gomplate.ca, chat with developers and community in the #gomplate channel on Gophers Slack gomplate is a template renderer which

Jan 5, 2023
An alternative syntax to generate YAML (or JSON) from commandline

yo An alternative syntax to generate YAML (or JSON) from commandline. The ultimate commanline YAML (or JSON) generator! ... I'm kidding of course! but

Jul 30, 2022
Commandline tool to generate Cistercian numerals

cistercian Commandline tool to generate Cistercian numerals. Installation go get github.com/rhardih/cistercian Example usage Text $ cistercian 7323

Sep 30, 2022
A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

URI Are you tired to build, concat, replace URL(s) (via shell scripts sed/awk/tr) from your awesome commandline pipeline? Well! here is the missing pi

Jun 9, 2021
Teardown API for Commandline Based Applications
Teardown API for Commandline Based Applications

Building go build -ldflags "-s -w" -o ./build/api.exe ./ Get the latest XML from https://www.teardowngame.com/modding/api.xml Commands help list searc

Mar 1, 2022
tigrfont is a commandline tool for creating bitmap font sheets for TIGR from TTF or BDF font files.
tigrfont is a commandline tool for creating bitmap font sheets for TIGR from TTF or BDF font files.

tigrfont - bitmap font sheet generator for TIGR tigrfont is a commandline tool for creating bitmap font sheets for TIGR from TTF or BDF font files. TI

Dec 5, 2022
Curried commandline

curry Install $ go install github.com/lambdasawa/curry@latest $ brew tap lambdasawa/tap $ brew install lambdasawa/tap/curry Usage Basic usage. $ curry

Dec 10, 2021
A simple golang marshaller from commandline to a struct

flagmarshal SYNOPSIS A simple golang marshaller from commandline to a struct ParseFlags(structptr interface{}) error DESCRIPTION Very simple implement

Jan 22, 2022
Waiton - Commandline for executing command and waiting on output

waiton Commandline for executing command and waiting on output Output of waiton

Feb 4, 2022
The slightly more awesome standard unix password manager for teams
The slightly more awesome standard unix password manager for teams

gopass Introduction gopass is a password manager for the command line written in Go. It supports all major operating systems (Linux, MacOS, BSD) as we

Jan 4, 2023
A modern UNIX ed (line editor) clone written in Go

ed (the awesome UNIX line editor) ed is a clone of the UNIX command-line tool by the same name ed a line editor that was nortorious for being and most

May 29, 2021
A go library for easy configure and run command chains. Such like pipelining in unix shells.

go-command-chain A go library for easy configure and run command chains. Such like pipelining in unix shells. Example cat log_file.txt | grep error |

Dec 27, 2022
Pack a Go workflow/function as a Unix-style pipeline command
Pack a Go workflow/function as a Unix-style pipeline command

tpack Pack a Go workflow/function as a Unix-style pipeline command. Wiki In Unix-like computer operating systems, a pipeline is a mechanism for inter-

Nov 9, 2022
Jan 6, 2023