|News||Midnight Commander tutorial||Recommended Links||MC2 -- mc with LUA support||Bash Debugger||mcedit- Midnight Commander editor||Neatbash -- a simple bash prettyprinter||mcedit||mcview||mcdiff||Context Sensitive User Menu||MC Extension menu|
|Macro Substitution||Command line and command window||External panelize||History of commands||Colorizing||Color scheme|
|Cheetsheet||Midnight Commander version 4.8||mc does not display pseudo-graphic characters properly||Software and configuration management using RPM||Building RPMs||Colorizing||OFM YouTube Tutorials||Sysadmin Horror Storie||MC History||Tips||Humor||Etc|
Midnight commander can serve as the basis of simple yet efficient and flexible DIY bash IDE. The requires customarization are simple includes:
With OFMs it is possible to run Bash in diagnostic mode (option -n) with one keystroke. You can bind this command to letter c in user menu.
Also Code2HTML can convert Perl source code to syntax highlighted HTML. Some Perl editors has this capability too.
Typically documentation now is viewed via web using web browser. You can integrate test based WEB browser into MC. One suitable candidate is links.
By itself, Vim is one of the best editors for shell scripting. With a little tweaking, however, you can turn Vim into a full-fledged IDE for writing scripts. You could do it yourself, or you can just install Fritz Mehner's Bash Support plugin.To install Bash Support, download the zip archive, copy it to your ~/.vim directory, and unzip the archive. You'll also want to edit your ~/.vimrc to include a few personal details; open the file and add these three lines:
let g:BASH_AuthorName = 'Your Name' let g:BASH_Email = 'firstname.lastname@example.org' let g:BASH_Company = 'Company Name'
These variables will be used to fill in some headers for your projects, as we'll see below.
The Bash Support plugin works in the Vim GUI (gVim) and text mode Vim. It's a little easier to use in the GUI, and Bash Support doesn't implement most of its menu functions in Vim's text mode, so you might want to stick with gVim when scripting.
When Bash Support is installed, gVim will include a new menu, appropriately titled Bash. This puts all of the Bash Support functions right at your fingertips (or mouse button, if you prefer). Let's walk through some of the features, and see how Bash Support can make Bash scripting a breeze.
Header and comments
If you believe in using extensive comments in your scripts, and I hope you are, you'll really enjoy using Bash Support. Bash Support provides a number of functions that make it easy to add comments to your bash scripts and programs automatically or with just a mouse click or a few keystrokes.
When you start a non-trivial script that will be used and maintained by others, it's a good idea to include a header with basic information -- the name of the script, usage, description, notes, author information, copyright, and any other info that might be useful to the next person who has to maintain the script. Bash Support makes it a breeze to provide this information. Go to Bash -> Comments -> File Header, and gVim will insert a header like this in your script:
#!/bin/bash #=============================================================================== # # FILE: test.sh # # USAGE: ./test.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Joe Brockmeier, email@example.com # COMPANY: Dissociated Press # VERSION: 1.0 # CREATED: 05/25/2007 10:31:01 PM MDT # REVISION: --- #===============================================================================
You'll need to fill in some of the information, but Bash Support grabs the author, company name, and email address from your ~/.vimrc, and fills in the file name and created date automatically. To make life even easier, if you start Vim or gVim with a new file that ends with an .sh extension, it will insert the header automatically.
As you're writing your script, you might want to add comment blocks for your functions as well. To do this, go to Bash -> Comment -> Function Description to insert a block of text like this:
#=== FUNCTION ================================================================ # NAME: # DESCRIPTION: # PARAMETERS: # RETURNS: #===============================================================================
Just fill in the relevant information and carry on coding.
The Comment menu allows you to insert other types of comments, insert the current date and time, and turn selected code into a comment, and vice versa.
Statements and snippets
Let's say you want to add an if-else statement to your script. You could type out the statement, or you could just use Bash Support's handy selection of pre-made statements. Go to Bash -> Statements and you'll see a long list of pre-made statements that you can just plug in and fill in the blanks. For instance, if you want to add a while statement, you can go to Bash -> Statements -> while, and you'll get the following:
while _; do done
The cursor will be positioned where the underscore (_) is above. All you need to do is add the test statement and the actual code you want to run in the while statement. Sure, it'd be nice if Bash Support could do all that too, but there's only so far an IDE can help you.
However, you can help yourself. When you do a lot of bash scripting, you might have functions or code snippets that you reuse in new scripts. Bash Support allows you to add your snippets and functions by highlighting the code you want to save, then going to Bash -> Statements -> write code snippet. When you want to grab a piece of prewritten code, go to Bash -> Statements -> read code snippet. Bash Support ships with a few included code fragments.
Another way to add snippets to the statement collection is to just place a text file with the snippet under the ~/.vim/bash-support/codesnippets directory.
Running and debugging scripts
Once you have a script ready to go, and it's testing and debugging time. You could exit Vim, make the script executable, run it and see if it has any bugs, and then go back to Vim to edit it, but that's tedious. Bash Support lets you stay in Vim while doing your testing.
When you're ready to make the script executable, just choose Bash -> Run -> make
script executable. To save and run the script, press
Ctrl-F9, or go
to Bash -> Run -> save + run script.
Bash Support also lets you call the bash debugger (bashdb) directly from within
Vim. On Ubuntu, it's not installed by default, but that's easily remedied with
apt-get install bashdb. Once it's installed, you can debug the script
you're working on with
F9 or Bash -> Run -> start debugger.
If you want a "hard copy" -- a PostScript printout -- of your script, you can generate one by going to Bash -> Run -> hardcopy to FILENAME.ps. This is where Bash Support comes in handy for any type of file, not just bash scripts. You can use this function within any file to generate a PostScript printout.
Bash Support has several other functions to help run and test scripts from within
Vim. One useful feature is syntax checking, which you can access with
If you have no syntax errors, you'll get a quick OK. If there are problems, you'll
see a small window at the bottom of the Vim screen with a list of syntax errors.
From that window you can highlight the error and press
Enter, and you'll
be taken to the line with the error.
Put away the reference book...
Don't you hate it when you need to include a regular expression or a test in
a script, but can't quite remember the syntax? That's no problem when you're using
Bash Support, because you have Regex and Tests menus with all you'll need. For example,
if you need to verify that a file exists and is owned by the correct user ID (UID),
go to Bash -> Tests -> file exists and is owned by the effective UID. Bash Support
will insert the appropriate test (
[ -O _]) with your cursor
in the spot where you have to fill in the file name.
To build regular expressions quickly, go to the Bash menu, select Regex, then pick the appropriate expression from the list. It's fairly useful when you can't remember exactly how to express "zero or one" or other regular expressions.
Bash Support also includes menus for environment variables, bash builtins, shell options, and a lot more.
Vim users can access many of Bash Support's features using hotkeys. While not
as simple as clicking the menu, the hotkeys do follow a logical scheme that makes
them easy to remember. For example, all of the comment functions are accessed with
\c, so if you want to insert a file header, you use
if you want a date inserted, type
\cd; and for a line end comment,
Statements can be accessed with
\ac for a case
\aie for an "if then else" statement,
a "for in..." statement, and so on. Note that the online docs are incorrect here,
and indicate that statements begin with
\s, but Bash Support ships
with a PDF reference card (under .vim/bash-support/doc/bash-hot-keys.pdf) that gets
Run commands are accessed with
\r. For example, to save the file
and run a script, use
\rr; to make a script executable, use
and to start the debugger, type
\rd. I won't try to detail all of the
shortcuts, but you can pull up a reference using
when in Vim, or use the PDF. The full Bash Support reference is available within
Vim by running
:help bashsupport, or you can read it
Of course, we've covered only a small part of Bash Support's functionality. The next time you need to whip up a shell script, try it using Vim with Bash Support. This plugin makes scripting in bash a lot easier.
Google matched content
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2020 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|You can use PayPal to to buy a cup of coffee for authors of this site|
Last modified: March 05, 2020