9 Commits
dev ... v1.0.1

Author SHA1 Message Date
cf6a9961d1 autocomplete fix ? 2023-11-16 16:46:28 +01:00
165f4a3a08 Autocomplete fix attempt 2023-11-16 15:32:42 +01:00
a56dc578de Update README.md
All checks were successful
continuous-integration/drone/push Build is passing
Added build badge
2023-07-14 12:25:54 +02:00
48322b25e5 drone error correction
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 12:21:16 +02:00
fbf6be2779 drone
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 12:15:36 +02:00
0aabd711a3 Merge pull request 'dev' (#4) from dev into main
Reviewed-on: #4
2023-05-01 13:44:36 +02:00
1eefd44a89 Merge pull request 'dev' (#3) from dev into main
Reviewed-on: #3
2023-03-04 20:26:00 +01:00
1e052f1a79 Merge pull request 'dev' (#2) from dev into main
Reviewed-on: #2
2023-03-04 14:31:17 +01:00
7b0f4b1922 Merge pull request 'dev' (#1) from dev into main
Reviewed-on: #1
2023-03-01 17:41:20 +01:00
4 changed files with 51 additions and 16 deletions

View File

@ -3,8 +3,38 @@ type: docker
name: default name: default
steps: steps:
- name: build
- name: test image: rust:latest
image: rust:1.66.0-alpine3.17
commands: commands:
- cargo build --verbose - cargo build --release
---
kind: pipeline
type: docker
name: release
steps:
- name: build
image: rust:latest
commands:
- cargo build --release
when:
event:
include:
- tag
- name: create-release
image: plugins/gitea-release:latest
custom_dns: [ 9.9.9.9 ]
settings:
api_key:
from_secret: gitea_api
base_url: https://gitea.squi.fr
note: This is an automated release of sqish.
files:
- ./target/release/sqish
when:
event:
include:
- tag

View File

@ -1,4 +1,5 @@
# Sqish # Sqish
[![Build Status](http://drone.sq.lan/api/badges/Rust/sqish/status.svg)](http://drone.sq.lan/Rust/sqish)
## Sqish's goal ## Sqish's goal
Squi's Shell, aka Sqish. This is an attempt to create a simple but usable shell in Rust, because why not. The goal (for me) is also to get more familiar with Rust since I read the Rust book and want to try things out. And, at last, building and using your own tools is pretty cool. Squi's Shell, aka Sqish. This is an attempt to create a simple but usable shell in Rust, because why not. The goal (for me) is also to get more familiar with Rust since I read the Rust book and want to try things out. And, at last, building and using your own tools is pretty cool.

View File

@ -408,23 +408,23 @@ pub mod shell {
}; };
} }
fn find_next_space(current_pos: &usize, max_pos: &usize, command: &String) -> usize { fn find_next_space(current_pos: &usize, max_pos: &usize, command: &String) -> usize {
let markers = vec![' ', '!', ',', ';', ':'];
let mut steps: usize = 0; let mut steps: usize = 0;
if *current_pos == *max_pos { return steps; } if *current_pos == *max_pos { return steps; }
for letter in command.chars().skip(*current_pos) { for letter in command.chars().skip(*current_pos+1) {
//println!("L : {:?}, S : {:?} C: {:?} M {:?}", letter, steps, current_pos, max_pos); if markers.contains(&letter) {
//Skip if we start on a space if *current_pos + steps < *max_pos { steps += 1; }
if steps == 0 && (letter == ' ' || letter == ',' || letter == ';') {
continue;
} else if letter != ' ' && *current_pos + steps < *max_pos {
steps += 1;
} else {
return steps; return steps;
} else {
steps += 1;
} }
} }
let max: usize = (0 + max_pos) - current_pos; let max: usize = (0 + max_pos) - current_pos;
return max; return max;
} }
fn handle_conf(stdout: &mut Stdout) -> SqishConf { fn handle_conf(stdout: &mut Stdout) -> SqishConf {
let conf = match SqishConf::from_sqishrc() { let conf = match SqishConf::from_sqishrc() {
@ -614,7 +614,7 @@ pub mod shell {
fn jmp_prev_word(elems: &mut TermElements) { fn jmp_prev_word(elems: &mut TermElements) {
let command_rev = elems.command.chars().rev().collect::<String>(); let command_rev = elems.command.chars().rev().collect::<String>();
let curr_rev = elems.max_pos - elems.cur_pos + 1; let curr_rev = elems.max_pos - elems.cur_pos;
let steps = find_next_space(&curr_rev, &elems.max_pos, &command_rev); let steps = find_next_space(&curr_rev, &elems.max_pos, &command_rev);
if steps > 0 { if steps > 0 {
print!("{}", cursor::Left(steps as u16)); print!("{}", cursor::Left(steps as u16));

View File

@ -97,14 +97,13 @@ impl Search {
SearchType::CmdSearch => autocomplete_cmd(&self.searchee, &self), SearchType::CmdSearch => autocomplete_cmd(&self.searchee, &self),
SearchType::FileSearch => match autocomplete_file(&self) { SearchType::FileSearch => match autocomplete_file(&self) {
Ok(t) => t, Ok(t) => t,
Err(_) => (format!("{}{}", &self.command, &self.searchee), String::new()), Err(_) => (String::new(), String::new()),
} }
}; };
if res.len() < 1 { if res.len() < 1 {
*&mut res = format!("{}{}", &self.command, &self.searchee); *&mut res = format!("{}{}", &self.command, &self.searchee);
} }
return (res, res_lines); return (res, res_lines);
} }
@ -205,7 +204,12 @@ fn autocomplete_file(search: &Search) -> std::io::Result<(String, String)> {
//Remote search... is annoying //Remote search... is annoying
if !search.local_search { if !search.local_search {
last_found = last_found.replace("./", ""); last_found = last_found.replace("./", "");
return Ok((format!("{}{}{}", search.command, search.search_path.display(), last_found), String::new())); //println!("{:?}", format!("{}{}", search.command, last_found));
if nbr_found < 2 {
return Ok((format!("{}{}{}", search.command, search.search_path.display(), last_found), String::new()));
} else {
return Ok((format!("{}{}", search.command, last_found), all_res));
}
} }
last_found = last_found.replace("./", ""); last_found = last_found.replace("./", "");