diff --git a/README.md b/README.md index 3bf9caf..0b1cb80 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ cargo install xplr ```bash mkdir -p ~/.config/xplr -echo "?" | xplr | yq ".config" -y | tee ~/.config/xplr/config.yml +echo "#" | xplr | yq ".config" -y | tee ~/.config/xplr/config.yml ``` 3. Check the key bindings in the config file. diff --git a/src/config.rs b/src/config.rs index 5e3e3cb..863d257 100644 --- a/src/config.rs +++ b/src/config.rs @@ -227,7 +227,7 @@ impl Default for KeyBindings { help: quit actions: - Quit - question-mark: + pound: help: print debug info actions: - PrintAppState diff --git a/src/input.rs b/src/input.rs index 8983d61..e70c48b 100644 --- a/src/input.rs +++ b/src/input.rs @@ -242,6 +242,7 @@ pub enum Key { Dot, Comma, QuestionMark, + Pound, NotSupported, } @@ -482,6 +483,7 @@ impl Key { TermionKey::Char('.') => Key::Dot, TermionKey::Char(',') => Key::Comma, TermionKey::Char('?') => Key::QuestionMark, + TermionKey::Char('#') => Key::Pound, _ => Key::NotSupported, } diff --git a/src/main.rs b/src/main.rs index e094ba6..15af872 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use crossterm::terminal as term; use handlebars::{handlebars_helper, Handlebars}; use shellwords; +use std::fs; use std::io; use termion::get_tty; use termion::{input::TermRead, screen::AlternateScreen}; @@ -12,10 +13,9 @@ use xplr::app::Task; use xplr::error::Error; use xplr::input::Key; use xplr::ui; -use std::fs; handlebars_helper!(shellescape: |v: str| format!("{}", shellwords::escape(v))); -handlebars_helper!(readfile: |v: str| fs::read_to_string(v).unwrap()); +handlebars_helper!(readfile: |v: str| fs::read_to_string(v).unwrap_or_default()); fn main() -> Result<(), Error> { let mut app = app::create()?; @@ -111,6 +111,8 @@ fn main() -> Result<(), Error> { a } Err(e) => { + term::disable_raw_mode().unwrap(); + std::mem::drop(terminal); result = Err(e); break 'outer; }