Latest recipes tagged "terminal"http://code.activestate.com/recipes/tags/terminal/new/2013-12-17T23:02:37-08:00ActiveState Code RecipesNo more UnicodeDecodeErrors when printing (Python)
2013-12-17T23:02:37-08:00Ádám Szieberthhttp://code.activestate.com/recipes/users/4188745/http://code.activestate.com/recipes/578788-no-more-unicodedecodeerrors-when-printing/
<p style="color: grey">
Python
recipe 578788
by <a href="/recipes/users/4188745/">Ádám Szieberth</a>
(<a href="/recipes/tags/decode/">decode</a>, <a href="/recipes/tags/error/">error</a>, <a href="/recipes/tags/print/">print</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/unicode/">unicode</a>).
Revision 2.
</p>
<p>I hate getting UnicodeDecodeErrors when I use print() for bugtracing or for some other reason. I decided to make a module which spares me the headache.</p>
A Simple Clock, Well Maybe Not That Simple... (Bash)
2013-07-17T17:40:18-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578610-a-simple-clock-well-maybe-not-that-simple/
<p style="color: grey">
Bash
recipe 578610
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/clock/">clock</a>, <a href="/recipes/tags/digital/">digital</a>, <a href="/recipes/tags/digits/">digits</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/large/">large</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/readout/">readout</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>Hi all...</p>
<p>Do you remember this little snippet?</p>
<p><a href="http://code.activestate.com/recipes/578079-pure-fun-for-text-mode-python/?in=user-4177147" rel="nofollow">http://code.activestate.com/recipes/578079-pure-fun-for-text-mode-python/?in=user-4177147</a></p>
<p>Well it was voted down, but who cares? I surely don't!
So to those that voted this FUN piece of Python coding down, you are now about to see what
the aim was.</p>
<p>However although I have subsequently done what I said I would, that is, to create large digits
as an _at_a_glance_ digital readout for a project in Python I have decided not to upload it.
However I have decided to let this one go as a bash/shell script instead.</p>
<p>It is a nothing but a simple clock, well, maybe not that simple; but as I am into shell
stuff at the moment I thought I would share this with you.</p>
<p>The terminal does have its colours changed and the cursor disabled for the session but
I expect you big guns to be able to return back to normal in a jiffy.</p>
<p>I am an amateur coder and if that is easy for me then you pros should have no problems.</p>
<p>This code is not like most of my other stuff as is NOT Public Domain...</p>
<p>It is only a DEMO to see what an at a glance display would look like in a terminal.</p>
<p>Move away to a distance and see which of the two time readings you can still read... ;o)</p>
<p>It is for a Macbook Pro 13" OSX 10.7.5 and uses bash imode.
It will probably work on most Linux machines too but I haven't tested it...</p>
<p>This is purely a DEMO only and any other special effects, (e.g. flashing colon every second),
alram, etc, I have already experimented with and is easy enough to do...</p>
<p>My intention is to use this as a kids level text mode digital voltmeter I am doing.</p>
<p>Enjoy...</p>
<p>Bazza...</p>
Bash Script For An Oscilloscope... (Bash)
2013-06-19T19:06:50-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578570-bash-script-for-an-oscilloscope/
<p style="color: grey">
Bash
recipe 578570
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/audioscope/">audioscope</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/sound_exchange/">sound_exchange</a>, <a href="/recipes/tags/sox/">sox</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>This code is the latest as of 19-06-2013. It is an AudioScope designed around a Macbook Pro 13"
of which only has ONE microphone input. It works under Linux variants too. Read the code for
much more info.</p>
<p>It was my way of learning Bash scripting.</p>
<p>It is resident here at this site:-</p>
<p><a href="http://www.unix.com/shell-programming-scripting/212939-start-simple-audio-scope-shell-script.html" rel="nofollow">http://www.unix.com/shell-programming-scripting/212939-start-simple-audio-scope-shell-script.html</a></p>
<p>It started off as a fun idea and is now becoming a very serious project.</p>
<p>As it stands this is fully working but it is uncalibrated and this is where it will stay on this site.</p>
<p>As the above site is the host then all future uploads will be there...</p>
<p>To do list...</p>
<p>DC input. [1]
DC polarity. [1]
2 more Internal sync modes.
External triggering.
Zoom facility - if possible in text mode.
Vertical calibration. [2]
Frequency measurement. {3]
(Others.)</p>
<p>[1] I have simple HW built as an idea but yet to prove it...
[2] Preliminary HW built but not yet used. Calibration SW and circuit(s) to be built into script as it progresses.
[3] I already have a working script but not completely satisfied at it at this point...</p>
<p>I am noing to say much else except that it has already been given a 5 star rating on the above UNIX site...</p>
<p>As it stands this code is entirely Public Domian and you may do with it as you please...</p>
<p>Enjoy something completely different using Bash scripting...</p>
<p>Finally the code defaults to a DEMO mode which requires no HW access at all but everything is still functional...</p>
<p>__Thoroughly__ read the code for more information...</p>
<p>As a circuit is inside the script then it is best viewed in plan text mode.</p>
<p>Bazza, G0LCU.</p>
A Shell, Binary To Hexadecimal To Decimal Demo... (Bash)
2013-01-11T18:31:03-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578413-a-shell-binary-to-hexadecimal-to-decimal-demo/
<p style="color: grey">
Bash
recipe 578413
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/hexadecimal/">hexadecimal</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>This little DEMO may be common knowledge to the big guns but not to amateurs like myself, so......</p>
<p>This is an Apple Macbbok Shell/Terminal DEMO shell script to show how to:-</p>
<p>1) Create a binary file...
2) Save it to your DEFAULT /directory/drwawer/folder/...
3) Display a hexadecimal dump of said binary file to prove that it is binary...
4) Select a single BYTE of that file and save it as an ASCII text decimal _number_, also to your DEFAULT /directory/drawer/folder/...
5) Read this ASCII text decimal number back in again...
6) Add this string representation to a number...
7) Stop...</p>
<p>It was intended purely for OSX 10.7.5 and above using the default terminal and shell...</p>
<p>It does work on many Linux flavours and shells/terminals also however.</p>
<p>Written so the anyone can understand what is going on.</p>
<p>The two files generated and saved in this DEMO to your DEFAULT /directory/drawer/folder/ are:-</p>
<p>BinaryString.dat
BinaryString.txt</p>
<p>This WILL lead to something very unusual in the not too distant future...</p>
<p>This is Public Domain and you may do with it as you wish...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza, G0LCU...</p>
A DEMO To Show How To Expand A Standard Python Terminal On The Fly... (Python)
2012-12-17T12:47:14-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578383-a-demo-to-show-how-to-expand-a-standard-python-ter/
<p style="color: grey">
Python
recipe 578383
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/campimeter/">campimeter</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/size/">size</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/window/">window</a>).
</p>
<p>This code shows how to open up a default Terminal running Python to tha maximum allowed on the _desktop_. I decided on writing code to do a crude emulation of a Campimeter. Anyone who has worn spectacles for a long time has had this test done at the optician's. Originally written for a Macbook Pro, OSX 10.7.5 but also tested on Debian Linux 6.0.x. READ the code for more information!!! This code WILL alter the size of the Terminal window AND changes the colours too, although it is very easy to return back to the default state it is NOT included in the code... I EXPECT professionals to know how to doo that.</p>
<p>Before running Python inside the Terminal ensure the Terminal window is at the uppermost left hand corner of your desktop...</p>
<p>I needed the maximised Python Terminal for something else but this was the easiest way to demonstrate ho to do it through Python...</p>
<p>Written so that kids can understand what is going on...</p>
<p>Enjoy finding simple solutions to often very difficult problems... ;o)</p>
<p>Bazza, G0LCU...</p>
Bash Prompt Rainbow Color Chart (Bash)
2011-10-02T21:39:21-07:00userendhttp://code.activestate.com/recipes/users/4179007/http://code.activestate.com/recipes/577889-bash-prompt-rainbow-color-chart/
<p style="color: grey">
Bash
recipe 577889
by <a href="/recipes/users/4179007/">userend</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/prompt/">prompt</a>, <a href="/recipes/tags/ps1/">ps1</a>, <a href="/recipes/tags/rainbow/">rainbow</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>This is a simple loop that displays a rainbow of different colors.</p>
Bash completed man and info pages generation (Python)
2011-08-24T03:14:13-07:00Josh Dhttp://code.activestate.com/recipes/users/4179060/http://code.activestate.com/recipes/577854-bash-completed-man-and-info-pages-generation/
<p style="color: grey">
Python
recipe 577854
by <a href="/recipes/users/4179060/">Josh D</a>
(<a href="/recipes/tags/a/">a</a>, <a href="/recipes/tags/all/">all</a>, <a href="/recipes/tags/and/">and</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/be/">be</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/completed/">completed</a>, <a href="/recipes/tags/consume/">consume</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/first/">first</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/get/">get</a>, <a href="/recipes/tags/in/">in</a>, <a href="/recipes/tags/info/">info</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/man/">man</a>, <a href="/recipes/tags/modify/">modify</a>, <a href="/recipes/tags/must/">must</a>, <a href="/recipes/tags/only/">only</a>, <a href="/recipes/tags/pages/">pages</a>, <a href="/recipes/tags/possibilties/">possibilties</a>, <a href="/recipes/tags/possiblities/">possiblities</a>, <a href="/recipes/tags/py/">py</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/run/">run</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/so/">so</a>, <a href="/recipes/tags/tab/">tab</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/the/">the</a>, <a href="/recipes/tags/this/">this</a>, <a href="/recipes/tags/to/">to</a>).
Revision 6.
</p>
<p>The script it self is very self explaining - the task is simple.
*NIX only unless with cygwin perhaps?</p>
<p>To start this open a terminal and strike the "Tab" key to get all possibilities (strike y, and strike the space key alot). Select all then Copy and save in "comms.txt"
Modify the file so ONLY the possiblities consume a line; no prompts or extra newlines.
(first line must be a command, the last line must be a command)</p>
<p>Save the file ("~/Documents/bashing/comms.txt" is my path) then run this script in "~/Documents/bashing/".</p>
<p>This generates two (2) files: "bash_help_man.sh", "bash_help_info.sh".</p>
<p>Then it runs these files: "bash bash_help_man.sh", "bash bash_help_info.sh".</p>
<p>This produces 2 files for every command (every line) in "comms.txt".
All manpages are wrote in "mans/", all infopages are wrote in "infos/"</p>
<p>There is now alot of files to read and organize; lets separate these by size.
Directories are under1kb, under2kb, etc.</p>
<p>Once complete do as you wish the files less than 128 kb;
these files are COPIED into there new respective home, I repeat COPIED.</p>
<p>The files 128 kb and higher ARE NOT copied to anywhere!</p>
Terminal directory changer (GUI) (Python)
2010-10-21T18:58:04-07:00Anton Vredegoorhttp://code.activestate.com/recipes/users/2667360/http://code.activestate.com/recipes/577435-terminal-directory-changer-gui/
<p style="color: grey">
Python
recipe 577435
by <a href="/recipes/users/2667360/">Anton Vredegoor</a>
(<a href="/recipes/tags/cd/">cd</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python_scripts/">python_scripts</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 2.
</p>
<p>Start this script from a terminal to change the terminal itself to a new directory, using a graphical tree view.</p>
Linux Terminal Color Setter (Python)
2008-09-11T17:08:30-07:00Collin Stockshttp://code.activestate.com/recipes/users/4149235/http://code.activestate.com/recipes/576503-linux-terminal-color-setter/
<p style="color: grey">
Python
recipe 576503
by <a href="/recipes/users/4149235/">Collin Stocks</a>
(<a href="/recipes/tags/just_for_fun/">just_for_fun</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/unix/">unix</a>).
</p>
<p>This module can move the cursor around in the terminal, change the text color, highlighting color, et cetera, bold, underlined, flashing (if supported). It also has a word wrap function, and can center text.</p>
Handling ANSI Terminal. (Python)
2010-02-09T05:51:23-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/574451-handling-ansi-terminal/
<p style="color: grey">
Python
recipe 574451
by <a href="/recipes/users/4035877/">Louis RIVIERE</a>
(<a href="/recipes/tags/ansi/">ansi</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/system/">system</a>, <a href="/recipes/tags/terminal/">terminal</a>).
Revision 9.
</p>
<p>This function can be used, with or instead of print, to get <a href="http://en.wikipedia.org/wiki/ANSI_escape_code">ANSI</a> output.</p>