рџ§ Intelli Shell рџђљ
This is a handler that runs on top of the Bash shell and implements command autocomplete using a dropdown list in real time.
You can view the history of executed commands with support for filtering and regular expressions, select and execute them from a list, and use directory navigation without leaving the current input line. In addition, it supports outputting variables, searching with filtering by the output of the last executed command, searching for executable commands and displaying a list of examples for them via cheet.sh.
I created this little project to make working with the console easier and faster. I haven't been able to find a solution for passing commands within a single session (examples can be found in the test directory).
Because execution of each individual command occurs in external and independent processes, some actions may not perform as you expect. For example, calling functions again in subsequent commands is not supported, nor are any interactive scripts that require the user to provide input.
вњЁ Implemented:
To read the output of the last command, a second thread is used. To compare performance on my 1 core system I used cat
to read the output of a 160k lines file which takes on average 4 seconds, when using two threads the reading time increases on 300-400 milliseconds.
Use two !
characters at the end of a line and call it to get extended prompts with command comments or a brief syntax example.
/home/lifailon [0.009s] > test !!
# test
# Check file types and compare values.
# Returns 0 if the condition evaluates to true, 1 if it evaluates to false.
# More information: <https://www.gnu.org/software/coreutils/test>.
# Test if a given variable is equal to a given string:
test "$MY_VAR" == "/bin/zsh"
# Test if a given variable is empty:
test -z "$GIT_BRANCH"
# Test if a file exists:
test -f "path/to/file_or_directory"
# Test if a directory does not exist:
test ! -d "path/to/directory"
# If A is true, then do B, or C in the case of an error (notice that C may run even if A fails):
test condition && echo "true" || echo "false"
/home/lifailon [0.009s] > js function !!
(function(){
// code
})();
!function(){
// code
}();
function(){
// code
}();
рџ’Ў To do:
вЊЁпёЏ Hotkeys:
right
– select a command without executing it, which is convenient for continuing recording or moving to the next directory to quickly display its contents.backspace
- in addition to deleting, updates the history to reflect the changes.ctrl+c
- clears the current input line (buffer) without moving to a new line and does not terminate the executed command (has no effect on stopping a running program, which can also be interrupted).ctrl+l
- completely clears the output console without affecting the input console and without changing the last execution command.ctrl+q
- hides the drop-down list until the next input.
рџљЂ Install from PyPi
For quick installation on your system, use the PyPi package manager:
pip install intellishell
To run use the command:
insh
рџ”Ё Install from GitHub
To work, you need to install the Python prompt-toolkit library on the system, which is responsible for creating a drop-down list:
pip install prompt_toolkit
If you have any difficulties with installation, please refer to the official manual.
Other dependencies in the form of external libraries are not required.
Download the script to the system and set access rights:
mkdir -p ~/.local/bin
curl -s https://raw.githubusercontent.com/Lifailon/intellishell/rsa/src/insh.py -o ~/.local/bin/insh
chmod +x ~/.local/bin/insh
Add the directory with the executables to the PATH
environment variable, if not already done:
export PATH="$HOME/.local/bin:$PATH"
source ~/.bashrc
To run, use the insh
command. If you get errors, simply change in hebang the version of the Python interpreter for which the prompt-toolkit library was installed:
pythonVersion=python3.10
sed -i '1s|^.*|#!/usr/bin/env '"$pythonVersion"'|' ~/.local/bin/insh
insh