[BL] Simplistic File Manager - Manual
lforrestster at gmail.com
Tue Feb 6 23:17:29 EST 2007
sfm = simplistic file manager
sfm is a simple tool to facilitate (speed up) browsing the
directory tree, examining and editing files, and performing other
basic file ops.
It is not meant to be substitute for shell knowhow or a permanent
It is meant to be part of a TDE (textmode desktop environment),
the other main part being a menu tree that allows easy execution
of common commands (template available as tdemenu.sh).
The liberal use of aliases is a must for the commandline linux
runner. Here are some example:
alias 'e=nvi' # my editor of choice
alias 'p=less' # pager
alias 'b=links-0.90' # browser
A file devoted to one's aliases is very helpful. Mine is named
/etc/.aliases and it is sourced by my /etc/profile with this
command at the bottom of that file: '. /etc/.aliases'
(More on aliases below.)
Installation & configuration
Copy code to a file named "sfm.sh". Make it executable with
'chmod +rx sfm.sh'. Move to directory in your PATH (I use
/usr/local/bin for most scripts). 'echo $PATH' to see what
directories are available.
Find a single letter that is not being used for an alias or
executable by testing your choice with 'type f'. (f being an
Set your choice by putting this in your /etc/profile:
alias f='. sfm.sh'
(The "." causes the script to be "sourced", which means run in
the current shell rather than a subshell, which is necessary for
cd to work as it does from the regular commandline, and for your
aliases to be available.)
Now restart X or do '. /etc/profile' in all open windows
The only thing you may want to change is the default pager,
which can be done near the top of the script. If you don't have
less, then the pager set in the environment variable PAGER
(/etc/profile) will be used.
sfm checks the number of columns (single character) on the
current screen, and chooses how many columns (menu) to display.
There's one less for the submenu because file names tend to
be longer than directory names.
Starting sfm.sh brings up the main menu:
 EXIT  COMMAND  SAVE
 file -L  ls -Als  /
 /bin  /dev  /etc
 /home  /lib  /proc
 /root  /sbin  /usr
 /var  STARTDIR  LASTDIR
(that's what it would look like on a narrow screen)
There are no subdirectories in the above directory.
Make your choice by entering a number at the prompt. If it is a directory, you
will cd there and the menu will be rebuilt for that directory.
Ctrl-j (^J) or Ctrl-m (^M) can be used, in most circumstances,
instead of Enter/Return.
- are a part of the main menu regardless of which dir you are
in. Only the subdirs of the current directory are listed. Note
that subdirs in the current directory, if any, begin after ".."
(You can, of course, change the above directories in any way you
Hit "Enter/Return" to run ls -aFs on the current directory, then
again to return to the main menu.
" EXIT" Guess! :-)
" COMMAND" opens a submenu and its own prompt. Only non-directory
files are listed, plus the option to return to main menu:
 MAIN MENU  cz  de.sh
 jpegtopnm  links.sh  man2text1.sh
 mangrep.sh  musetup  mutt.gz
 pgpewrap  pgpring  poff
 ppmdither  ppmtobmp  ru
 sfm-orig  sfm.sh  splitscreen.sh
 tcpdump.sh  time.sh  top-mem.sh
(that's what it would look like on a narrow screen)
 takes you back to the main menu.
Here you enter a normal commandline, but you use numbers instead
(And/or the string "ZZ". See below.)
" SAVE" gives you a menu with just the non-directory files
in the current directory, because you are returned to the main
menu after running it once. And its own prompt.
 cz  de.sh  jpegtopnm
 links.sh  man2text1.sh  mangrep.sh
 musetup  mutt.gz  pgpewrap
 pgpring  poff  ppmdither
 ppmtobmp  ru  sfm-orig
 sfm.sh  splitscreen.sh  tcpdump.sh
 time.sh  top-mem.sh  trash.sh
If you enter a list of numbers at the prompt, the file names they
represent, with full path, will be saved to a tempfile and you'll
return to the main menu.
The contents of this tempfile can be included on the "Command: "
commandline by using the string "ZZ".
You can now navigate to another directory and, for example, copy
the files in the tempfile to that directory by entering:
Command: cp ZZ .
You can only use the tempfile once. If you don't use it at all,
it will be deleted when you exit sfm. If you call SAVE again,
the tempfile will be deleted before the new save begins. Just
going to the SAVE submenu and hitting Enter/Return will delete
But it's a good way to see just the non-dir files.
Note that "." causes " $PWD " to be printed on the sfm
commandline, which is _not_ as flexible as a regular commandline,
although you can do a lot.
Command: e 45
would open the file represented by the number 45 in your favorite
editor (if you have "e" aliased to your favorite editor).
SAVE and COMMAND do not display error messages. If you use
invalid command names, options, or args, or don't include any
numbers representing files in the current directory, you will
find yourself returned to the main menu with SAVE, and with a new
COMMAND menu and prompt with COMMAND. If you enter one or more
numbers that don't represent valid files, but otherwise the line
is sound, the mistakes will be ignored.
The screen doesn't clear after a command is executed at the
"Command: " prompt so that you can see the output of apps that
output to stdout.
If the output of such an app is more than a screenful, use
Shift-PageUp/PageDown to access the missing part. Hit Space
to return to the prompt.
(For dirs with a _lot_ of files, piping to a pager is mandatory.)
If you want to keep the screen neat when executing more than one
command, there are three ways:
1. Execute 'clear' at the "Command: " prompt.
2. Pipe the output to a pager.
3. Return to the main menu and start again.
If a command hangs, use Ctrl-c (^C) to get out of it. (This has
only happenned with 'cat' with no files on the commandline.)
" file -L" runs file -L (dereference symbolic links) on the current
directory and displays the results in your pager of choice.
" ls - Als" runs ls -Als on the current directory and displays the
results in your pager of choice. (Here is where you can see the
Quiting the pager in either case returns you to the main menu.
" STARTDIR" takes you back to the directory you started sfm
" LASTDIR" to the last directory you were in.
" .." to the parent directory of your current directory.
If you have basic typing skills (and anyone aspiring to master
the computer _must_ be a decent touch typist) using sfm is much
faster for navigating the directory tree, in most cases, than
typing all the cd's and paths and ls's.
Takes a little getting used to, but once you have the numbers memorized...
Most of the time you can get to a directory with a fraction of
the keystrokes doing it manually would take. The numbers are easy
If sfm is getting in the way, just kill it.
Typing hint: Put your left index finger on "f" and the right
index finger on "j" (standard basic typing position). Move your
entire hands diagonally to the upper left. Your index fingers are now on
"r" and "u", respectively. Do it again. They are now on "1" and
"7". Practice moving back and forth with your eyes closed and
typing abcdefgh...then 123456...Keep your thumbs touching the
Space bar and your shoulders relaxed.
You can run as many concurrent instances of sfm as you like. They
won't step on each other.
Please read through the script. It is well-commented.
Simplistic File Manager
Copywrong Lee Forrest lforrestster at gmail.com Wed Feb 7 2007
Thanks to Steven, creator of BasicLinux, for his help with formatting.
If anyone wants to try it and suggest changes, I'd be grateful.
I've been using it for a while, and it looks like I got the bugs
BasicLinux: Small is Beautiful
More information about the BasLinux