diff --git a/Cargo.lock b/Cargo.lock
index ced6c17..07212b6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -114,7 +114,7 @@ dependencies = [
[[package]]
name = "dialoguer"
version = "0.10.1"
-source = "git+https://github.com/araxeus/dialoguer#0c17c421d8d745c88c39e1b7652e35c848fae6a3"
+source = "git+https://github.com/araxeus/dialoguer#5982f7fd4c94c714c1ba7d61abdda6f8d039cbba"
dependencies = [
"console",
"crossterm",
diff --git a/README.md b/README.md
index 88d65b7..81facc5 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@
π Browse folders using Enter
-π Open folder in terminal (cd to folder) using Shift + Enter
+π Open folder in terminal (cd to folder) using [Shift + Enter] or [Alt + Enter]
π Open folder in file manager using Ctrl + Enter
@@ -33,12 +33,19 @@
π Type anything to filter current folder content using fuzzy search
+> on Linux/Mac Shift + Enter or Ctrl + Enter might not work
+>
+> see https://github.com/crossterm-rs/crossterm/issues/669
+
## π Installation
1. Download zip package from [releases page](https://github.com/Araxeus/ls-interactive/releases)
2. extract its content into a folder in PATH ([guide](https://gist.github.com/nex3/c395b2f8fd4b02068be37c961301caa7))
-Installation from package managers is Coming Soonβ’
+#### Linux/Mac
+Copy the function in [lsi.sh](https://github.com/Araxeus/ls-interactive/blob/master/scripts/lsi.sh) into to `/home/user/.bashrc`
+
+(You need only the ls-interactive file in your PATH, since lsi is defined in your bash startup file)
## π» How to run it
diff --git a/scripts/lsi.sh b/scripts/lsi.sh
index 825e619..891435f 100644
--- a/scripts/lsi.sh
+++ b/scripts/lsi.sh
@@ -1,4 +1,8 @@
-#!/bin/bash
+#add the following function to /home/user/.bashrc
-output=$("$(dirname "$0")/ls-interactive")
-[ -n "$output" ] && cd "$(output)"
+lsi() {
+ local output
+ if output=$(ls-interactive "$@") && [[ $output ]] ; then
+ cd "$output"
+ fi
+}
diff --git a/src/main.rs b/src/main.rs
index 482ac6e..71c1cfb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,7 @@ mod utils;
use std::{env, fs, path::Path};
use structs::{Entry, Filetype, Icons};
-use utils::{display_choices, err, resolve_lnk, KeyModifiers};
+use utils::{display_choices, err, pretty_path, resolve_lnk, KeyModifiers};
fn main() {
human_panic::setup_panic!();
@@ -35,7 +35,10 @@ fn main_loop(initial_path: String) {
// quit if file was opened
Ok(_) => break,
// else display error and open as directory
- Err(_) => err(format!("Failed to open file \"{}\"", &entry.path[4..])),
+ Err(_) => err(format!(
+ "Failed to open file \"{}\"",
+ pretty_path(&entry.path)
+ )),
}
}
// browse directory by continuing loop with new path
@@ -45,8 +48,8 @@ fn main_loop(initial_path: String) {
entry.path.to_string()
};
- if modifier == KeyModifiers::SHIFT {
- print!("{}", &path[4..]);
+ if modifier == KeyModifiers::SHIFT || modifier == KeyModifiers::ALT {
+ print!("{}", pretty_path(&path));
break;
}
}
diff --git a/src/utils.rs b/src/utils.rs
index 73003cf..cab075c 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -21,7 +21,7 @@ pub fn resolve_lnk(path: &String) -> String {
mem::drop(panic::take_hook());
if link.is_err() {
- err(format!("Failed to read shortcut \"{}\"", &path[4..]));
+ err(format!("Failed to read shortcut \"{}\"", pretty_path(path)));
return path.to_string();
}
@@ -40,7 +40,7 @@ pub fn resolve_lnk(path: &String) -> String {
// returns the index of the selected choice
pub fn display_choices(items: &[Entry], path: &str) -> (usize, KeyModifiers) {
match FuzzySelect::with_theme(&ColorfulTheme::default())
- .with_prompt(&path[4..])
+ .with_prompt(pretty_path(path))
.report(false)
.items(items)
.default(0)
@@ -52,3 +52,11 @@ pub fn display_choices(items: &[Entry], path: &str) -> (usize, KeyModifiers) {
None => process::exit(0),
}
}
+
+pub fn pretty_path(path: &str) -> &str {
+ if cfg!(windows) {
+ &path[4..]
+ } else {
+ path
+ }
+}