2024-12-22 21:10:53 +01:00
|
|
|
> This is a fork of [twilight-commander](https://github.com/golmman/twilight-commander)
|
|
|
|
|
|
|
|
# twilight-tree
|
|
|
|
|
|
|
|
A simple console tree file explorer for linux, similiar to NERDTree but independent of vim.
|
|
|
|
Developed and tested on Ubuntu 18.04 with xterm derivatives.
|
|
|
|
|
|
|
|
## Build and install
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git clone https://git.4rs.nl/awiteb/twilight-tree
|
|
|
|
cd twilight-tree
|
|
|
|
cargo install --path . # this will install the binary in $HOME/.cargo/bin
|
|
|
|
```
|
|
|
|
|
2024-12-25 21:46:55 +01:00
|
|
|
## `twilight-tree` vs `twilight-commander`
|
|
|
|
|
|
|
|
- With `twilight-tree` you can hide the header (Which is the current working
|
|
|
|
directory) with `--setup.with_cwd_header=false`
|
|
|
|
- You can rename a file/directory using the `r` keybinding. To move a
|
|
|
|
file/directory, specify the new path along with the new name. For example,
|
|
|
|
`../new_name.rs` will move the file to the parent directory and rename it to
|
|
|
|
`new_name.rs`.
|
2024-12-27 20:42:29 +01:00
|
|
|
- You can delete a file/directory with `ctrl+d` keybinding
|
2024-12-27 22:47:15 +01:00
|
|
|
- You can create a new file with `n+f` keybinding
|
|
|
|
- You can create a new directory with `n+d` keybinding
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
## Implemented features
|
|
|
|
|
|
|
|
### Configuration
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
The configuration is loaded as follows
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
1. load values from `$XDG_CONFIG_HOME/twilight-tree.toml`
|
|
|
|
2. else load values from `$HOME/.config/twilight-tree/twilight-tree.toml`
|
2024-12-25 21:46:55 +01:00
|
|
|
3. fill missing values with app defaults
|
|
|
|
4. overwrite values with defines from the command line options
|
2024-12-22 21:10:53 +01:00
|
|
|
|
|
|
|
For a config file with the default values, see [twilight-tree.toml](./twilight-tree.toml).
|
|
|
|
The command line options are derived from the values defined inside the twilight-tree.toml .
|
|
|
|
E.g.
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
```
|
|
|
|
[debug]
|
|
|
|
enabled = true
|
|
|
|
```
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
is set with the option `--debug.enabled=true`.
|
|
|
|
|
|
|
|
### Configurable key bindings
|
|
|
|
|
|
|
|
The key bindings are configurable. For the set of configurable keys and key combinations consult the [event.rs](./src/model/event.rs).
|
|
|
|
|
2024-12-25 21:46:55 +01:00
|
|
|
| default key | default configuration | action |
|
|
|
|
| ------------- | --------------------------------- | ---------------------------------------------------------------- |
|
|
|
|
| `up arrow` | `--keybinding.entry_up=up` | move an entry up |
|
|
|
|
| `down arrow` | `--keybinding.entry_down=down` | move an entry down |
|
|
|
|
| `left arrow` | `--keybinding.collapse_dir=left` | collapse an entry directory or jump to parent if not collapsable |
|
|
|
|
| `right arrow` | `--keybinding.expand_dir=left` | expand an entry directory |
|
|
|
|
| `r` | `--keybinding.rename_mode=r` | Enter rename mode (To exit rename mode press `quit` keybinding) |
|
2024-12-27 22:47:15 +01:00
|
|
|
| `n` | `--keybinding.new_entry=n` | Enter create mode (To exit rename mode press `quit` keybinding) |
|
2024-12-25 21:46:55 +01:00
|
|
|
| `ctrl+r` | `--keybinding.reload=r` | collapse all directories and reload root directory |
|
2024-12-27 20:42:29 +01:00
|
|
|
| `ctrl+d` | `--keybinding.remove=ctrl+d` | remove a file/directory |
|
2024-12-25 21:46:55 +01:00
|
|
|
| `return` | `--keybinding.file_action=return` | perform configured file action |
|
2024-12-27 20:42:13 +01:00
|
|
|
| `esc` | `--keybinding.quit=esc` | quit |
|
2024-12-22 21:10:53 +01:00
|
|
|
|
|
|
|
### Directory entry management
|
|
|
|
|
|
|
|
#### File Action
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
The command line option / config value `--behavior.file_action` defines the action taken when the return key is pressed
|
|
|
|
on a file. The action is interpreted by `bash` and any occurence of `%s` will be replaced by the selected filename.
|
|
|
|
E.g. when enter is pressed on the file `.bashrc` in a twilight-tree process created with
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
```
|
|
|
|
twilight-tree "--behavior.file_action=xterm -e 'cat %s; echo opened file: %s; bash'"
|
|
|
|
```
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
then
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
```
|
|
|
|
bash -c "xterm -e 'cat /home/user/.bashrc; echo opened file: /home/user/.bashrc; bash'"
|
|
|
|
```
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
is executed, i.e.:
|
|
|
|
|
2024-12-25 21:46:55 +01:00
|
|
|
- a new xterm window is opened
|
|
|
|
- where the selected file (`.bashrc`) is printed to stdout
|
|
|
|
- then `opened file: ~/.bashrc` is printed
|
|
|
|
- `bash` prevents the window from closing.
|
|
|
|
|
|
|
|
`--behavior.file_action` defaults to [true](<https://en.wikipedia.org/wiki/True_and_false_(commands)>), which does
|
2024-12-22 21:10:53 +01:00
|
|
|
(almost) nothing.
|
|
|
|
|
|
|
|
### Scrolling modes
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
Specified with the option `--behaviour.scrolling` (default = `center`)
|
|
|
|
|
2024-12-25 21:46:55 +01:00
|
|
|
- `center`: move the cursor until it is in the center, then move the text instead
|
|
|
|
- `editor`: move the cursor until it hits the top/bottom boundaries set by the `debug.paddin_top/bot` limits
|
2024-12-22 21:10:53 +01:00
|
|
|
|
|
|
|
### Utf-8 support
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
In case your terminal does not support utf-8 you can disable it with `--composition.use_utf8=false`.
|
|
|
|
|
|
|
|
### Logs
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
Logs are written to
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
1. `$XDG_CONFIG_HOME/tc.log` if XDG_CONFIG_HOME is defined
|
|
|
|
2. else they are placed in `$HOME/.config/twilight-tree/tc.log`
|
|
|
|
|
|
|
|
## License
|
2024-12-25 21:46:55 +01:00
|
|
|
|
2024-12-22 21:10:53 +01:00
|
|
|
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|