File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: path:: Path ;
12use std:: path:: PathBuf ;
23
34use anyhow:: Context ;
@@ -42,6 +43,13 @@ async fn interactive() -> anyhow::Result<()> {
4243 let mut state = init_state ( ) ;
4344
4445 let home = dirs:: home_dir ( ) . context ( "Couldn't get home directory" ) ?;
46+ let history_file: PathBuf = [ home. as_path ( ) , Path :: new ( ".shell_history" ) ]
47+ . iter ( )
48+ . collect ( ) ;
49+ if Path :: new ( history_file. as_path ( ) ) . exists ( ) {
50+ rl. load_history ( history_file. as_path ( ) )
51+ . context ( "Failed to read the command history" ) ?;
52+ }
4553
4654 let mut _prev_exit_code = 0 ;
4755 loop {
@@ -117,6 +125,8 @@ async fn interactive() -> anyhow::Result<()> {
117125 }
118126 }
119127 }
128+ rl. save_history ( history_file. as_path ( ) )
129+ . context ( "Failed to write the command history" ) ?;
120130
121131 Ok ( ( ) )
122132}
You can’t perform that action at this time.
0 commit comments