Skip to content

Commit

Permalink
[guide] add guide for DirSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
anjakefala committed Dec 4, 2023
1 parent 1618aed commit 4cc7c97
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion visidata/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
pass # pwd,grp modules not available on Windows

from visidata import Column, Sheet, LazyComputeRow, asynccache, BaseSheet, vd
from visidata import Column, Sheet, LazyComputeRow, asynccache, BaseSheet, vd, GuideSheet
from visidata import Path, ENTER, asyncthread, VisiData
from visidata import modtime, filesize, vstat, Progress, TextSheet
from visidata.type_date import date
Expand Down Expand Up @@ -245,6 +245,41 @@ def inputShell(vd):
vd.warning('no $column in command')
return cmd

class DirGuide(GuideSheet):
guide = '''# Directory Sheet
The **DirSheet** is a display of files and folders in the *source* directory.
To load a **DirSheet** via the CLI, provide VisiData a directory as input (e.g. `vd sample_data/`). Within VisiData, use the command `open-dir-current` (equivalent to `vd .`).
Passing the flag `-r` (`--recursive`) will additionally display all of the files in all subfolders (`vd -r .`).
Basic usage of the **DirSheet** is to find and load files within VisiData:
- `Enter` (`open-row`) to open a file as a separate **Sheet**
- `g Enter` (`open-selected`) to open all selected files, each in a separate **Sheet**
- [:keystrokes]`[/] (`open-dir-parent`) to push the parent folder
- `Ctrl+O` (`sysopen-row`) to open the current file in your system editor
Advanced usage of **DirSheet** is as a file systems manager.
Via the **DirSheet** files can copied to a different directory, deleted, and renamed. All of the file metadata, except for *filetype*, is modifiable.
Modifications on the **DirSheet** are deferred - they do not take effect on the filesystem itself until they are confirmed with `z Ctrl+S` (`commit-sheet`).
- `y` (`copy-row`) to copy file to given directory
- `gy` (`copy-selected`) to copy selected files to given directory
- `d` (`delete-row`) to delete file from filesystem
- `e` (`edit-cell`) to change file metadata
- `z Ctrl+S` (`commit-sheet`) to then commit all changes to the filesystem (not undoable!)
## Options of Interest (must reload to take effect)
- [:onclick options-sheet dir_depth]`dir_depth`[/] to recurse into folders
- [:onclick options-sheet dir_hidden]`dir_hidden`[/] to include hidden dotfiles
'''


DirSheet.addCommand('`', 'open-dir-parent', 'vd.push(openSource(source.parent if source.resolve()!=Path(".").resolve() else os.path.dirname(source.resolve())))', 'open parent directory') #1801
BaseSheet.addCommand('', 'open-dir-current', 'vd.push(vd.currentDirSheet)', 'open Directory Sheet: browse properties of files in current directory')

Expand Down Expand Up @@ -283,3 +318,5 @@ def copy_files(sheet, paths, dest):
vd.addMenuItems('''
Column > Add column > shell > addcol-shell
''')

vd.addGuide('DirSheet', DirGuide)

0 comments on commit 4cc7c97

Please sign in to comment.