digital literacy for everyone
alex line executive[lit]
if you are looking for a "state of the art" python shell, alex isnt the solution for you. while organising a tonne of files, i wrote a tool called "figsh" to help me take care of some of the more repetitive tasks.
figsh lacked a real command line, but it had enough features to let me do a lot of work without dropping back to the shell-- or switching to another window. alex is a lot closer to what i would have liked to use.
with various features cobbled together, alex certainly wouldnt replace bash but i do use it more and more:
[lit]*[lit] as a command shell
[lit]*[lit] as a shell for running one-liner scripts
[lit]*[lit] as a bash enhancer [lit]/[lit] scripting toolbox
[lit]*[lit] as a tool for teaching the shell
[lit]*[lit] as the only shell i would want to use in windows
i have used bash for more than a decade, and its a fascinating mix of power and reliability and-- being extremely demanding when it comes to little stupid things.
i am not a powershell fan-- too complicated for a shell-- i havent loved using the dos command line since i finally figured out how to get stuff done with bash, but ive also tried bash in windows and i didnt like it.
so alex is bash for windows users, right?
no, its a dos shell for bash fans. or whatever, alex is a nifty python tool that doesnt use real pipes because i couldnt make them work on both platforms--
so it just calls the shell you use in your debian[lit]/[lit]devuan-based or windows-based operating system.
and while i do still switch back and forth between shells (i never said i could or that anyone /should/ write a bash replacement-- version from 0.1 is from just 4 months ago as of this writing) i have to say i love mixing its built-in tools with other command line stuff.
find | isoname .pdf | tops 10 | bots 5 | arrdo pdf-loader
no, alex doesnt have its own pdf loader-- i use evince personally.
[lit]*[lit] find ... lists files in the current folder (find [lit]/[lit] or in windows find \ also works)
[lit]*[lit] | isoname .pdf ... only show files that contain ".pdf" in them
[lit]*[lit] | tops 10 ... show only the top 10 lines
[lit]*[lit] | bots 5 ... show only the bottom 10 lines
[lit]*[lit] | arrdo pdf-loader ... *for each line*, open with /pdf-loader/ line
find | dc d2018 # find stuff from just this year
echo "what is your name?" ; setinput t ; echo "hello, $t"
arrdo is very powerful, and getting strings to work as similarly as possible in both bash and windows (i develop the windows part using wine) is a fun goal. so i tell people *dont use arrdo*, not that they have to listen.
alex line executive COMES WITH NO WARRANTY, etc, etc.
alex 2.8, mar 2019 mn
alex run the alex line executive
alex --help show this help information and exit
sleep [n] pause for one second or [n] seconds
arrcurl [-a] url write contents of url as output
pserver run a mini http server using the current folder
locate row column change the cursor position
colour colour highlight change the text colours
cat file1 [file2] [-n] concatenate files and/or number all lines
set vname value set vname to value
setrandint vname min max set vname to a random number between min / max
setinput vname set vname to whatever is input from the keyboard
setnum vname num set vname to numeric num (variable or value)
setadd vname v1 v2 set vname to sum of v1 and v2 (string or numeric)
find | fsortplus find files, show size / sha256 / date / time
find | fsortplusnows fsortplus, but create hash without whitespace
find | dc [n] [d[srchdate]] [+/-szlimit] list name/size/time, colour by type
| isoname text only show lines containing "text"
| isoplus text only list files with lines containing "text"
| minusname text remove lines containing "text"
| isoleft text include if left equals text
| isoright text include if right equals text
| isonotleft text include if left != text
| isonotright text include if right != text
| lcase [or] ucase convert lines to lower or upper case
| fields 1 2 3 4 _ show 1st, 2nd, 3rd, 4th, _all fields/tokens
| replace what with replace "what" with "with"
| arrdo "do what" very powerful / do not use
| tops n only show top n lines
| bots n only show bottom n lines
| noreps only show each line once, regardless of sort
| var varname pipe output to varname
| ascii [-h] display text as ascii codes (-h for hex)
| rainbow rotate colours by -f field, -p pos, -l level
| findsim find similar files
| isogroup text show only groups containing text
| groupbyleft howmuch uniq/sep by howmuch (includes singles)
| groupsortlen sort groups by size
| arrlen prepend each line with length
while ; repeatedly do part after ;
forin vname 500 ; do part after ; ...500 times
forin vname array ; do part after ; ...loop through array
next mark the bottom of a while or forin loop
break exit a while or forin loop
clear clear the screen
pset x y c draw a dot at x, y in colour c
chr asciicode [or unicode] output a character from ascii or unicode
line x y x2 y2 c draw a line from x, y to x2, y2 in colour c
echo $varname output $varname
quit, exit quit the shell
alex is a prototype, which i use frequently. like with any shell you are not fully aquainted with the quirks of, i would recommend playing with it carefully and obviously not running it on a production system.
versions *1.8, 1.9, 2.0 and 2.1* i would stay away from too. theyre alright on the windows side, version 2.2 (included on this page) fixes the nasty variable output that only gets you when there are multiple lines.
if this wasnt cross-platform i wouldnt be using string formatting, i would be using proper calls. but this is meant to interface with the windows cmd shell and also the bash shell, and also use pipes to connect programs [lit]/[lit] output together.
so far ive only managed to do that by calling the shell. and while bash can easily do 100x as much, spending a decade on those skills is about as much as i want to do with that.
highly recommended features: *--dc*, *--fsortplus*, and (with caution) *| variablename* ...*the variables still need to be isolated* (im oldschool and just use the word "alex" as a variable prefix, whatever) so *| var t* works and *| var great* works, but *| var p* can still get you into trouble for the moment.
youre more than welcome to take part of alex (like dc) and fork it into a separate tool, please feel free. alex 2.2 is in the public domain.
[lit]alex18.py[lit] 1.8 (*not recommended*)
[lit]alex19.py[lit] 1.9 (*not recommended*)
[lit]alex20.py[lit] 2.0 (*not recommended*)
[lit]alex21.py[lit] 2.1 (*not recommended*)
versions 1.8 - 2.1 will not run without modification, they are disabled due to a bug in the *| var* feature; this is fixed in 2.2.