README.md

June 9, 2020 · View on GitHub

cfiles

Latest release Arch Linux Homebrew

License

cfiles is a terminal file manager with vim like keybindings, written in C using the ncurses library. It aims to provide an interface like ranger while being lightweight, fast and minimal.

screenshot

Dependencies

  • ncursesw
  • cpand mv for copying and moving
  • fzf for searching
  • w3mimgdisplay or Überzug for image previews
  • mediainfo for viewing media info and file sizes
  • atool for archive previews
  • poppler(specifically pdftoppm) for pdf previews

Compiling and Installation

Arch Linux

Arch Linux users can use the AUR package.

macOS

macOS users can use brew or macports

Others

To compile, run

make

and then run,

sudo make install

to install.

Keybindings

KeyFunction
h j k lNavigation keys
GGo to end
gGo to top
HGo to top of current view
MGo to middle of current view
LGo to bottom of current view
pgupScroll Up One Page
pgdnScroll Down One Page
fSearch using fzf
FSearch using fzf in the present directory
SOpen Shell in present directory
spaceAdd/Remove to/from selection list
tabView selection list
eEdit selection list
uEmpty selection list
yCopy files from selection list
vMove files from selection list
aRename Files in selection list
ddMove files from selection list to trash
dDRemove selected files
iView mediainfo and general info
IView preview
.Toggle hidden files
bToggle borders
'View/Goto bookmarks
mAdd bookmark
EEdit bookmarks
pRun external script
rReload
qQuit

Directories Used

cfiles uses $XDG_CONFIG_HOME/cfiles directory to store the clipboard file. This is used so that the clipboard can be shared between multiple instances of cfiles. That's why I won't be adding tabs in cfiles because multiple instances can be openend and managed by any terminal multiplexer or your window manager. Note that this also means the selection list will persist even if all instances are closed.

cfiles also uses $HOME/.local/share/Trash/files as the Trash Directory, so make sure this directory exists before you try to delete a file.

For storing bookmarks, cfiles uses $XDG_CONFIG_HOME/cfiles/bookmarks file. Bookmarks are stored in the form <key>:<path>. You can either edit this file directly or press m in cfiles to add new bookmarks.

cfiles looks for external scripts in the $XDG_CONFIG_HOME/cfiles/scripts directory. Make sure the scripts are executable before moving them to the scripts directory.

If $XDG_CONFIG_HOME is not set, then $HOME/.config is used.

Opening Files

You can set FILE_OPENER in config.h to specify your file opening program. It is set to use xdg-open by default but you can change it to anything like thunar. macOS users need to set it to open.

Image Previews

You can either go with w3mimgdisplay or Überzug (link) for image previews. Each method has it's own pros and cons.

  1. Überzug

To use Überzug for image previews, set DISPLAYIMG and CLEARIMG in config.h to the paths of displayimg_uberzug and clearimg_uberzug scripts respectively.

  • Pros
    1. Better previews when compared to w3mimgdisplay
  • Cons
    1. Can't generate previews for mp3 album arts
    2. Non functional scrolling with arrow keys

I recommend Überzug because the previews scale well with change in terminal size and don't disappear on changing workspaces.

  1. w3mimgdisplay

To use w3mimgdisplay for image previews, set DISPLAYIMG and CLEARIMG in config.h to the paths of displayimg and clearimg scripts respectively.

  • Pros
    1. Faster scrolling
    2. Can generate previews of album arts for mp3 files
  • Cons
    1. Previews are very inconsistent and may disappear on resizing the terminal or changing workspaces
    2. You may have to redraw the UI while scrolling by pressing KEY_RELOAD (defaults to R)

You may have to modify the scripts a little, about which you can read here.

Why C?

I wanted to improve my C and learn ncurses so I decided this would be an ideal project.

Apart from this, I have always wanted an alternative to ranger that is faster while still having a similar UI.