[ DISCLAIMER ] This program was written to try out pygtk and to fullfill my own needs for a Vim treeview. I.e., dont' be shocked if you find some design flaws on the gtk part, and feel free to flame me for it :-)
This is an attempt at making a generic treeview in the sense that it can open files in any editor/program. Using an IDE can probably be a good idea at times, but they often feel a bit supersized, with tons of functionality which clogs up your system, and which is never used. And their biggest weakness in my opinion is that they often lack a good editor, which is really what I'm looking for.
Vim and Emacs are superior to just about any IDE when it comes to text editing (even with all of their Vim/Emacs plugins installed). Emacs and Vim are not without flaws either naturally, maybe the biggest one is their (common) steep learning curve to configure things. Both of them more or less expect you to learn a new programming language for this.
Still I found the treeview (that most IDE's have) extremely handy, especially for Java projects with their directory/package structure. Well thats more or less the whole story, wanting to take what was good from them and combine it with what works for editing.
It is implemented in Python using gtk, and its default behaviour is to open files with Vim inside an Xterm. This is how I like to edit source code, but switching to Emacs, Gedit, GVim, Jed, Nano or some other program is easy. Thanks to L. Storjord other terminals are now supported as well, tested with aterm, wterm, rxvt. . Thanks to Matt a 7 year old bug was squashed today [Jan.2015]; allowing white space in path names..
If you download and run it without any options, you should see something like this.
If you press space, return, or double-click on a directory it will open recursively. Then if you press space or return or double-click on one of the files it will open with Vim inside an Xterm like this.
I've set the size of the treeview and Xterm according to my screen resolution to fill out the space, this can be done with command line arguments or placed into the file $HOME/.btvrc Once you quit Vim, the Xterm will die as well.
Vim is the default editor, so nothing has to be done in order to use Vim for editing, but if you prefer one running instance and to open files in tabs, use this setup:
> vim --servername VIM # in some shell > btv --exe vim --args --remote-tab -no-xterm > gvim --servername GVIM & > btv --exe gvim --args --remote-tab -no-xterm
If you want to use it with Emacs, then probably the most desirable way to use it is with the Emacs-Server. This will open all files in the one running instance of Emacs, instead of starting new instances for each new file. This is a matter of starting up your Emacs as a server M-x server-start, or place (server-start) in your configuration file. Then once you have your Emacs-Server up and running, this is how you start up the treeview
> btv -exe emacsclient -no-xterm
If you want to use Gedit you would most likely want to start it up like this
> btv -exe gedit -no-xterm
The nice thing about Gedit is that it activates a new instance if no instance is running, and adds a tab to the running instance if it finds a running instance. NOTE the last version of Gedit has a bug/feature in which it does not open files in the running instance, but starts new instances for each file.
Directories can be given on the command line, if no directory is listed, all files below PWD will be loaded into the treeview (recursively), use the option -n or --non-recursive , if you have huge filetrees that you do not want to load into the treeview. In non-recursive mode files are loaded as directories are investigated.
Minimum size of the treeview is controlled by these options
-y --min-height -x --min-width
The size of the Xterm's which are opened are controlled by
This follows the same format as the Xterm geometry option, see the example:
> btv --geometry 100x40
A list of all options and all key bindings are given below.
-h --help print this menu and exit -v --version print version and exit -k --key-bindings print key-bindings and exit -n --non-recursive do not add files recursively -y --min-height minimum heigth (default: 721) -x --min-width minimum width (default: 210) -g --geometry xterm geometry (default: 100x47) -f --filter ignore files/directories matching filter (wildcard) -e --editor --exe editor/executable to open files with (default:vim) -s --stand-alone editor/executable runs on it's own not in xterm -a --args editor args (emacs -nw == -e emacs --args -nw) -t --top-dir include parent (if only one) in treeview -c --alt-term use different console / terminal emulator --termargs pass arguments to terminal emulator --hidden show backup (*~) and hidden (.*) files --no-xterm alias for --stand-alone --logo legal values: bruce | ninja | cheese --no-splash do not show splash sceen at startup --title set alternative title (default: btv) --howto show examples of how to open your files in a running instance of: VIM/GVIM/EMACS/GEDIT
Control+L ____________ Open/Collapse TreeView Return / Space _______ Open/Collapse marked directory Return / Space _______ Open file if file is marked Left/Right/Up/Down ___ Scroll Left/Right/Up/Down Control+Q/W/C ________ Kill Control+S ____________ Stick/Unstick (visible on all desktops) Control+I ____________ Iconify Control+O ____________ Open file with different program Control+0 ____________ Set TreeView in position (0,0) Control [+] __________ Make TreeView bigger Control [-] __________ Make TreeView smaller Control+Down _________ Toggle Open/Collapse (one level) Control+UP ___________ Toggle Open/Collapse (one level) + ____________________ Open one level in TreeView - ____________________ Close one level in TreeView F5 ___________________ Refresh TreeView Control+M ____________ Maximize/Unmaximize TreeView Control+D ____________ Delete marked file Control+R ____________ Rename marked file Control+A ____________ Add new file in marked directory Control+G ____________ Grep for pattern
Configuring it is more or less the same as writing command line arguments into the file $HOME/.btvrc The options given in the configuration file are overwritten by command line options.