Bashit.kak a kakoune editor command line gateway. *Relaunch*

BashIt.kak a kakoune editor command line gateway.

See or clone the docs/javadoc, docs/coverage, and docs/tests for the API.

Download pre-built bashit.jar with sha256 hash check.
$ openssl dgst -sha256 bashit.kak-<version>.jar



    USAGE:
      bashit [-i | -debug] <BINARY|JAR|OTHER> [FLAGS] [args ...]

    OPTIONS:
      -i:
        ignore output in Kakoune client

      -debug:
        terminal debugging of a java.lang.Process

    BINARY|JAR|OTHER:
      is on your PATH|CLASSPATH|OTHER

    FLAGS:
      are native to the BINARY|JAR|OTHER

    DISCUSSION:
      BashIt a Kakoune command line gateway. Easily invoke a 
      binary, jar, or any script/executable without leaving
      the kakoune command line. With automated temp file setup
      and teardown on stdin/out/err. Default invocation
      opens the temporary file in current kakoune client.
      The temporary file is deleted on programs exit,
      invoke kakoune :write command to save the buffers
      output to a file name and destination of your choosing.

    NOTE:
      :bashit stderr available in kakoune *debug* buffer
      java -jar is automatically prefixed to <name>.jar calls
      kotlinc -script is automatically prefixed to <name>.kts calls
    
    EXAMPLE:
      :bashit python3 --help
      :bashit perl --help
      :bashit bashit.run --help

      :bashit brew info shellcheck
      :bashit brew home shellcheck
      :bashit howdoi -c -n 5 catch an exception kotlin
      :bashit curl https://cheat.sh/:intro

      :ansi-render see https://github.com/eraserhd/kak-ansi
      :bashit open https://github.com/eraserhd/kak-ansi

Woman had me my man-pants, press play on the motivational song spotify Schubert: Ave Maria, D.839 or youtube and put yourself in scrutineers mode. Peer review time!

HTML format:
docs/javadoc docstrings with UML diagrams and Harvard referencing style.
docs/coverage 119 passing tests with 96% coverage.
docs/tests viewable results of all tests.


Building

@see gradle wrapper
@see shadowJar

Run the gradle command from the terminal in bashit.kak top level directory:
$ gradle wrapper

Linux/OSX:
$ ./gradlew shadowJar

Windows:
$ gradlew.bat shadowJar

The fat-jar is located:
$ bashit.kak/build/libs/bashit.kak-<version>.jar

Build with passing tests use:
$ ./gradlew build

Gradle is a command line tool:
$ ./gradlew --help
$ ./gradlew tasks
$ ./gradlew dependencies --configuration compileClasspath


NOTE:
Gradle can also build shared and static libraries, and executables in Assembler, C/C++ and Obj-C/C++


Installing


$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk version
$ sdk install java 11.0.5-zulu
$ sdk install kotlin
$ sdk install gradle  
$ sdk install kscript  // optional

NOTE:


# kakoune command
define-command -params .. bashit %{ evaluate-commands %sh{ java -jar <your-path-to>/bashit.kak-<version>.jar "${kak_session}" "${@:1}" } }


# .bashrc command
if [[ -d "$HOME/.local/jars" ]] ; then
    JARPATH="$HOME/.local/jars"
    export JARPATH
fi

javajar.sh
#! /usr/bin/env bash
# `.jar` suffix is no longer required from bash command line
exec java -jar "$JARPATH/$1.jar" "${@:2}"
exit 1

# .bash_alias command
alias jj=<your-path-to>/javajar.sh


Alternate Setup (linux/osx/*nix)


# kakoune command
define-command -params .. bashit %{ evaluate-commands %sh{ bashit.run "${kak_session}" "${@:1}" } }


jars-linux.sh
#!/bin/sh

MYSELF=`which "$0" 2>/dev/null`

[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"

java=java

if test -n "$JAVA_HOME"; then
    java="$JAVA_HOME/bin/java"
fi

exec "$java" $java_args -jar $MYSELF "$@"

exit 1


$ cat jars-linux.sh bashit.kak-<version>.jar > bashit.run && chmod u+x bashit.run && mv bashit.run ~/.local/bin/

@author Tommaso, P 2019, How to make a JAR file Linux executable, corderwall.com, viewed on 6 Jan 2019, https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable


TODO:

/*
 * bitbucket repo  ✅
 * uml diagrams  ✅
 * logger  ✅
 * mockk   ✅
 * tests with coverage  ✅
 * dokka api, docstrings and references  ✅
 * build fatjar  ✅
 * post on discuss.kakoune  ✅
 */

NOTE:
Before running ./gradlew command run:
$ ps aux | grep java
Note the process_id of all current running java processes.
Then run all the required ./gradlew commands, after re-run the previous ps command for any additional unclosed java process noting their process_id.
You can then use the:
$ kill process_id
to terminate the additional running java process.
The cause is strictly ./gradlew command and NOT bashit.run or bashit.jar.


Kakoune General Information

Kakoune is an open source modal editor. The source code lives on github mawww/kakoune.
A discussion on the repository structure of ’community plugins’ for Kakoune can be reviewed here: Standardi(s|z)ation of plugin file-structure layout #2402.
Read the Kakoune wiki for information on install options via a Plugin Manager.

And thank you to the Kakoune community 180+ contributors for a great modal editor in the terminal. I use it everyday for those keyboard shortcuts.

bashit-graalvm

First: the standard java application bashit.kak-4.0.jar
Second: with the use of jars-linux.sh bashit.run
Third: compiled with GraalVM native bashit.kak

$GRAALVM_HOME/bin/native-image -cp ./bashit.kak-4.0.jar -H:Name=bashit.kak -H:Class=org.kjd.bashit.kak.BashItKt -H:+ReportUnsupportedElementsAtRuntime --allow-incomplete-classpath

bashit.kak is language agnostic so insert your favourite language here *.* I am using *.kt for demo purposes only. Below are the commands I use in the asciinema cast. Please note that compile time is a little slower than most as I am on an iMac-2011 with 2008 parts.

$ kak ToUpper.kt

fun main(args: Array<String>) {
  args.forEach { println(it.toUpperCase()) }
}
:bashit ktnative.sh toUpper ToUpper.kt
:bashit mv toUpper.kexe toUpper

$ ./toUpper wtf? bashit.kak

I did not quite get what bashi.kak provides compared to say :nop %sh{ my bash command }. Could you eleaborate ?

Sure and thanks for your interest. Answer: absolutely nothing! Honesty is always refreshing though.
Just doing something a little different from the pack and having fun with the jvm and kotlin.
I am not running any competitions @mawww , so view or use with a smile.

No need to context switch to preform tasks, if complied with GraalVM a ahead of time VM you can spawn multiple native VM tasks without leaving Kakoune editor. Process auto closes within 20 seconds which is a design choice, so no long-running tasks.

All stdout/err is available inside the Kakoune editor for you to view e.g. :bashit ghc --show-options . You can now view without leaving the kak editor the 1305 lines of options.

You can also use the -debug to see additional details from your terminal not via kakoune editor.

Like everything, limited by our imagination, hence a community of ideas and feedback propels growth. So how can I improve it? Let me know.

Alternately I could do this to view the stdout:
:bashit toUpper wtf? bashit.kak
:buffer-next

That’s bashIt.kak a kakoune editor command line gateway.

kotlinx.cli for extending cli options/flags and parsing is on the todo list.

Thanks @mawww and keep up the good work mate. Bye :wave:

Wimmer, C. et al., 2019. Initialize once, start fast: application initialization at build time. Proceedings of the ACM on Programming Languages, 3(OOPSLA), pp.1–29. Available at: Initialize once, start fast: application initialization at build time | Proceedings of the ACM on Programming Languages.

BashIt.kak v5.0 GraalVM Native Image Compliant.

After pulling an all nigher to impress the boss (@mawww ) and with @andreyorst I’m human after all post in mind, here’s a tune for the day after spotify Road Trip Skegss or youtube.

Sincerely I appreciate the Kakoune editor and the work done by all the community more than I could ever express. Bye. :wave:

bashit-v5.0-graalvm