Fixed history and cd without args
This commit is contained in:
@ -289,3 +289,4 @@ fn find_common_chars(mut strvec: Vec<String>) -> String {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ use std::io::{prelude::*, BufReader};
|
||||
|
||||
pub fn write_to_history(command: &str) -> Result<(), std::io::Error> {
|
||||
//Write a command to history
|
||||
let filepath = dirs::home_dir().unwrap().join("history.sqish");
|
||||
let filepath = dirs::home_dir().unwrap().join(".history.sqish");
|
||||
let mut file = OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
@ -26,7 +26,7 @@ pub fn write_to_history(command: &str) -> Result<(), std::io::Error> {
|
||||
|
||||
pub fn get_history_number() -> Result<i32, std::io::Error> {
|
||||
//Get the latest number found in history file
|
||||
let filepath = dirs::home_dir().unwrap().join("history.sqish");
|
||||
let filepath = dirs::home_dir().unwrap().join(".history.sqish");
|
||||
let file = File::open(filepath)?;
|
||||
let reader = BufReader::new(file).lines();
|
||||
let myline = String::from(reader.last().unwrap_or(Ok(String::from("1")))?);
|
||||
@ -59,7 +59,7 @@ pub fn get_history() -> Result<String, std::io::Error> {
|
||||
|
||||
pub fn get_hist_from_number(number: &i32) -> Option<String> {
|
||||
//Returns a command from its number in hist file
|
||||
let filepath = dirs::home_dir().unwrap().join("history.sqish");
|
||||
let filepath = dirs::home_dir().unwrap().join(".history.sqish");
|
||||
|
||||
if filepath.exists() == false {
|
||||
return None;
|
||||
|
Reference in New Issue
Block a user