h-m-m/readme.md

318 lines
12 KiB
Markdown
Raw Normal View History

2022-08-30 17:54:49 +02:00
# h-m-m (hackers mind map)
2022-09-06 14:59:48 +02:00
**h-m-m** (pronounced like the interjection "hmm") is a simple, fast, keyboard-centric terminal-based tool for working with mind maps.
2022-08-30 17:54:49 +02:00
2022-09-04 09:46:24 +02:00
![screenshot](screenshot.png)
2022-08-30 17:54:49 +02:00
2023-07-23 10:45:10 +02:00
# Default key bindings
2022-08-30 17:54:49 +02:00
Adding, removing, and editing nodes:
2022-09-16 21:41:53 +02:00
* `o` or `Enter` - create a new sibling to the active node
* `O` or `Tab` - create a new child for the active node
2022-08-30 17:54:49 +02:00
* `y` - yanks (copies) the active node and its descendants
* `Y` - yanks (copies) the descendants of the active node
* `d` - deletes (cuts) the active node and its descendants
* `D` - deletes (cuts) the descendants of the active node
2022-09-16 21:41:53 +02:00
* `Delete` - deletes the active node and its descendants without putting them in the clipboard
2022-08-30 17:54:49 +02:00
* `p` - pastes as descendants of the active node
* `P` - pastes as siblings of the active node
2022-09-16 21:41:53 +02:00
* `Ctrl+p` - appends the clipboard text at the end of the active node's title
2022-09-15 20:07:35 +02:00
* `e`, `i`, or `a` - edits the active node
* `E`, `I`, or `A` - edits the active node, ignoring the existing text
2022-09-16 02:50:35 +02:00
* `u` - undo
2022-08-30 17:54:49 +02:00
2022-12-22 17:07:30 +01:00
Marks:
2023-03-15 09:24:48 +01:00
* `t` - toggles '✓ ', '✗ ', and '' (or your custom symbols) at the beginning of the title
2022-12-22 17:07:30 +01:00
* `#` - adds or removes sequential numbers at the beginning of the titles of a node and its siblings
2023-01-01 11:14:54 +01:00
* `=` - increases the positive ranking
* `+` - decreases the positive ranking
* `-` - increases the negative ranking
* `_` - decreases the negative ranking
2023-03-17 20:04:49 +01:00
* `H` - toggles the hidden flag
2022-12-22 17:07:30 +01:00
2022-08-30 17:54:49 +02:00
Relative navigating and moving:
2023-01-01 11:14:54 +01:00
* `h` or `←` - activates the parent of the previously active node
* `l` or `→` - activates the middle child of the previously active node
* `j` or `↓` - activates the lower sibling (or the nearest lower node if there's no lower sibling)
* `k` or `↑` - activates the higher sibling (or the nearest higher node if there's no higher sibling)
2022-08-30 17:54:49 +02:00
* `J` - moves the current node down among its siblings
* `K` - moves the current node up among its siblings
2023-01-01 11:14:54 +01:00
* `T` - sorts the siblings of the active node
2022-08-30 17:54:49 +02:00
Adjusting the view:
* `c` - centers the active node on the screen
2023-03-17 20:04:49 +01:00
* `C` - locks/unlocks active nodes on the center
2022-09-14 20:59:23 +02:00
* `~` or `m` - activate the root element
2022-08-30 17:54:49 +02:00
* `g` - goes to the highest element
* `G` - goes to the lowest element
* `w` - increases the maximum node width
* `W` - decreases the maximum node width
* `z` - decreases line spacing
* `Z` - increases line spacing
2023-03-17 20:04:49 +01:00
* `|` - enables/disables aligned levels
* `ctrl+h` - hides/views hidden nodes
2022-08-30 17:54:49 +02:00
Collapsing and expanding:
2022-09-16 21:41:53 +02:00
* `Space` - toggles the active node
2022-08-30 17:54:49 +02:00
* `v` - collapses everything other than the first-level nodes
2022-12-31 22:48:16 +01:00
* `V` - collapses all the children of the active node
2022-08-30 17:54:49 +02:00
* `b` - expands all nodes
* `1` to `9` - collapse the nth level and expand those before
* `f` - focuses by collapsing all, but the ancestors and descendants of the active node
* `F` - locks focus as the active node changes (try it with the center lock)
2022-09-15 20:07:35 +02:00
* `r` - collapses all the first level items except for the one that contains the active node
* `R` - collapses the children of the active node
2022-08-30 17:54:49 +02:00
Search:
2023-07-23 11:09:17 +02:00
* `/` or `Ctrl+f` - searches for a phrase
2022-08-30 17:54:49 +02:00
* `n` - goes to the next search result
* `N` - goes to the previous search result
Save, export, quit, etc.:
2022-08-30 17:54:49 +02:00
* `s` - saves with the previous file name (or asks for one if there's none)
* `S` - saves with a new file name
2023-03-18 14:38:26 +01:00
* `x` - export as an HTML file
* `X` - export as a text map into clipboard
2022-08-30 17:54:49 +02:00
* `q` - quits (if the changes were already saved)
* `Q` - quits, ignoring the changes
2023-04-19 18:00:59 +02:00
* `Ctrl+o` - open the active node as a file or URL using xdg-open
2022-08-30 17:54:49 +02:00
2023-07-23 11:09:17 +02:00
Misc:
* `?` - show the key bindings
2022-09-16 21:41:53 +02:00
In the text editor:
2023-01-01 11:14:54 +01:00
* `↓` - moves the cursor to the end of the line
* `↑` - moves the cursor to the beginning of the line
* `←` or `Home` - moves the cursor to the left
* `→` or `End` - moves the cursor to the right
* `Ctrl+Left` or `Shift+Left` - moves cursor to the previous word
* `Ctrl+Right` or `Shift+right` - moves cursor to the next word
* `Delete` - deletes character
* `Ctrl+Delete` - deletes word
* `Backspace` - deletes previous character
* `ctrl+Backspace` - deletes previous word
2022-09-16 21:41:53 +02:00
* `Ctrl+v` or `Ctrl+Shift+v` - paste
2023-01-01 11:14:54 +01:00
* `Esc` - cancels editing
2022-09-16 21:41:53 +02:00
* `Enter` - wanna guess? ;)
2022-08-30 17:54:49 +02:00
2023-07-23 10:45:10 +02:00
Other than the text editor key bindings, you can change all in your config file.
2022-08-30 17:54:49 +02:00
# Configuration
2022-09-19 20:53:38 +02:00
The following are the settings in h-m-m:
2022-08-30 17:54:49 +02:00
max_parent_node_width = 25
max_leaf_node_width = 55
2022-08-30 17:54:49 +02:00
line_spacing = 1
2023-03-15 09:09:17 +01:00
align_levels = 0
2022-08-30 17:54:49 +02:00
initial_depth = 1
2022-09-19 20:53:38 +02:00
center_lock = false
focus_lock = false
max_undo_steps = 24
2023-03-27 07:36:02 +02:00
active_node_color = \033[38;5;0m\033[48;5;172m\033[1m
message_color = \033[38;5;0m\033[48;5;141m\033[1m
clipboard = os
clipboard_file = /tmp/h-m-m
clipboard_in_command = ""
clipboard_out_command = ""
2022-09-29 10:14:11 +02:00
post_export_command = ""
2023-03-15 09:24:48 +01:00
symbol1 = ✓
symbol2 = ✗
2023-07-23 11:22:48 +02:00
auto_save = false
2022-08-30 17:54:49 +02:00
The colors are ASCII escape codes.
2023-07-23 10:45:10 +02:00
You can also change key bindings with a `bind x = command` syntax. The following are the commands:
append
center_active_node
collapse_all
collapse_children
collapse_inner
collapse_level_1
collapse_level_2
collapse_level_3
collapse_level_4
collapse_level_5
collapse_level_6
collapse_level_7
collapse_level_8
collapse_level_9
collapse_other_branches
decrease_line_spacing
decrease_negative_rank
decrease_positive_rank
decrease_text_width
delete_children
delete_node
delete_node_without_clipboard
edit_node_append
edit_node_replace
expand_all
export_html
export_text
focus
go_down
go_left
go_right
go_to_bottom
go_to_root
go_to_top
go_up
increase_line_spacing
increase_negative_rank
increase_positive_rank
increase_text_width
insert_new_child
insert_new_sibling
move_node_down
move_node_up
next_search_result
open_link
paste_as_children
paste_as_siblings
previous_search_result
quit
save
save_as
search
shutdown
sort_siblings
toggle_align
toggle_center_lock
toggle_focus_lock
toggle_hide
toggle_node
toggle_numbers
toggle_show_hidden
toggle_symbol
undo
yank_children
yank_node
Keys can be `x`, `X` (shift+x), `ctrl_x`, `alt_x`, or special keys: `arr_down`, `arr_left`, `arr_right`, `arr_up`, `back_space`, `ctrl_arr_left`, `ctrl_arr_right`, `ctrl_back_space`, `ctrl_del`, `del`, `end`, `enter`, `equal`, `esc`, `home`, `shift_arr_left`, `shift_arr_right`, `space`, `tab`
Note: Not every possible key is defined because I'm going to replace this whole system with one that supports key sequences.
Key bindings can only be set in a config file. There are 3 ways of changing settings:
2022-09-19 20:53:38 +02:00
1. Pass them as arguments when running the program; e.g., `h-m-m --focus-lock=true --line-spacing=0 filename`
1. Set them as environment variables with `hmm_` as prefix; e.g., `hmm_line_spacing=0`
1. Store them in a config file. You can pass the location of the config file when running the application like `h-m-m --config=/path/file`, or use the default location:
* Linux: ~/.config/h-m-m/h-m-m.conf
* Mac: ~/Library/Preferences/h-m-m/h-m-m.conf
* Windows: an h-m-m.conf file in the same directory as the script
Both underscores and dashes are accepted for the setting keys.
2023-07-01 12:55:19 +02:00
When multiple values exist, the highest priority goes to the command line arguments and the lowest to the config file.
2022-09-19 20:53:38 +02:00
2022-08-30 17:54:49 +02:00
# Clipboard
The normal `os` clipboard works fine for most users, but some users may need other options:
* `--clipboard=os` uses the global clipboard via xclip and similar tools.
* `--clipboard=internal` uses an internal variable as the clipboard (won't exchange text with external applications).
2022-09-29 10:14:11 +02:00
* `--clipboard=file` uses `/tmp/h-m-m` by default, or another file set by the `--clipboard_file=/path/filename` setting as the clipboard.
* `--clipboard=command` uses `--clipboard_in_command="command %text%"` to send content to a shell command and `--clipboard_out_command="command"` to read content.
2022-09-29 10:14:11 +02:00
# Exporting
You can export an HTML version of the map using the `x` key binding. This is useful for sending the file to someone who may not have h-m-m or a similar mind mapping application. To make the process easier, you can set a sell command to run after exporting the map; e.g., upload it to a server and copy the link to clipboard: `--post-export-command="upload.sh %filename% &>/dev/null"`.
2022-08-30 17:54:49 +02:00
# Data format
Mind maps are stored in plain text files (with `hmm` file extension by default) without metadata. The tree structure is represented by tab indentations; e.g.,
root (level 0)
item A (level 1)
item B (level 1)
item Ba (level 2)
item Bb (level 2)
item Bc (level 2)
item BaX (level 3)
item BaY (level 3)
item Bd (level 2)
item C (level 1)
When you yank (copy) or delete (cut) a subtree, the data will be put into your clipboard with a similar structure, and when pasting, the data will be interpreted as such.
Most mind mapping applications use a similar format for copying and pasting. As a result, if you want to import a map from another application, you can probably select everything in that application, copy it, come to **h-m-m**, and paste it. The same usually works well when copying from HTML/PDF/Doc lists, spreadsheets (e.g., Calc and Excel), etc.
2022-09-18 13:23:36 +02:00
# Installing
2022-08-30 17:54:49 +02:00
2023-07-01 12:55:19 +02:00
Note: A few issues should be solved before **h-m-m** can be run in Windows. Until then, Windows users can probably use *Windows Subsystem for Linux* to run it. There's an [open issue](https://github.com/nadrad/h-m-m/issues/29) for Windows, waiting for contributors!
2022-09-16 09:09:58 +02:00
2022-09-18 13:23:36 +02:00
## 1. Manual installation
2022-09-16 09:09:58 +02:00
**h-m-m** is a single php file. You can download it from here, or clone it on your computer using git and add a scheduled job to update it once a day or week.
You also need to have the following installed for h-m-m to work:
* php
* either php 8, or
* older versions of php along with the `mbstring` package (e.g., `php7.2-mbstring`)
2023-12-05 08:12:58 +01:00
* `xclip`, `xsel`, `wl-clipboard`, or `klipper` in Linux. (Windows and Mac don't need it)
2022-08-30 17:54:49 +02:00
After downloading or cloning, you can run `php h-m-m` in your terminal to run the program with a blank map or `php h-m-m filename` to open an existing file. If you don't already have a php interpreter installed, you would need to install it as well. Note: You don't need to set up a "web server" to run it because it's not a web application, but rather a terminal application that works like those written in Python, Bash, etc.
Optionally, you can make the file executable by running the `chmod +x h-m-m` in your terminal, and afterward, you can run it as `h-m-m filename` (assuming that **h-m-m** is in your path).
2022-09-16 09:28:54 +02:00
## 2. Installation for Arch Linux
2022-09-16 09:09:58 +02:00
In Arch Linux, you can use the `h-m-m-git` AUR package to install it.
2022-08-30 17:54:49 +02:00
2022-09-19 20:53:38 +02:00
## 3. Installation script for Linux (and Mac?)
2022-09-14 21:43:58 +02:00
2022-09-16 09:28:54 +02:00
You can run the following command to install h-m-m:
2022-09-14 21:43:58 +02:00
2022-09-17 12:06:09 +02:00
```sh
wget -q -O - 'https://raw.githubusercontent.com/nadrad/h-m-m/main/install.sh' | sh
2022-09-17 12:06:09 +02:00
```
2022-09-16 09:28:54 +02:00
This command downloads and runs the install.sh script, which it turn downloads h-m-m, copies it to `/usr/local/bin`, checks the dependencies, and makes it executable.
After installing, you can run `h-m-m` from anywhere in your terminal to run the application with an empty map, or `h-m-m filename` to open an existing file.
2022-09-14 21:47:46 +02:00
2022-09-19 20:53:38 +02:00
Note: It probably works in a Mac, but I'm not completely sure; so, [let me know](https://github.com/nadrad/h-m-m/issues/27).
2022-09-14 21:43:58 +02:00
2022-09-17 11:49:14 +02:00
## 4. Installation with Docker
It's also possible to execute `h-m-m` through docker (or podman):
```sh
# Build the image
docker build -t hmm .
# Run it
docker run --rm -it -v $(pwd):/app/ hmm
```
2022-08-30 17:54:49 +02:00
# Feedback
2023-07-01 12:55:19 +02:00
Programming is not my career, but rather a hobby, and I developed **h-m-m** because I wanted to have something like this application and couldn't find one. Therefore, what I've done here may have a lot of room for improvement. If you see an embarrassing problem in the program or have an idea for improvement, feel free to contact me; I'd be happy to receive your feedback.
2022-08-30 17:54:49 +02:00
2023-07-01 12:55:19 +02:00
Why php? It's simple: I only have a rusty knowledge of Pascal and a little familiarity with php. I thought about learning another language for this project (Nim is my top choice at this moment), but I didn't have time to do it. I'll probably do it later and convert it into a language I can compile :)
2022-08-30 17:54:49 +02:00