diff --git a/CHANGELOG.md b/CHANGELOG.md index d45c7d4..46b6306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Header view: new view to inspect ELF and PE executables. - Added a command to change the view (same as pressing `Tab`). Example: `:set view hex` (possible values are `text`, `hex`, and `header`). It can be used in `~/.dz6init` to set the default view when dz6 is loaded. +- Added support for comments / lines starting with `#` in `~/.dz6init`. ## Breaking changes: - `Tab` cycles through available views now (`Enter` no longer does that). diff --git a/README.md b/README.md index 18102d6..05954b9 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ Once you load a file in **dz6**, you can use the commands below. | `wq` or `x` | Write changes to file and quit | | | | `q` | Quit without saving changes | | In replace mode, `T` (truncate) is an exception because it modifies the file immediately. | -If you need permanent settings, create a `$HOME/.dz6init` file containing any of the commands above, one per line. dz6 will load that at startup. +> If you need permanent settings, create a `$HOME/.dz6init` file containing any of the commands above, one per line. dz6 will load that at startup. Lines starting with `#` are ignored. ### Hex view diff --git a/src/initfile.rs b/src/initfile.rs index bfe59a8..94673d5 100644 --- a/src/initfile.rs +++ b/src/initfile.rs @@ -13,7 +13,11 @@ impl App { let path = home.join(".dz6init"); let data = fs::read_to_string(path)?; - for cmdline in data.lines() { + for cmdline in data + .lines() + .map(str::trim) + .filter(|line| !line.starts_with('#')) + { parse_command(self, cmdline); } }