Skip to content

Commit 9b527e2

Browse files
committed
fix: Don't load ~/.inputrc for bash
User could set vi mode in .inputrc, which makes the completions fail.
1 parent 32b5da3 commit 9b527e2

File tree

1 file changed

+8
-0
lines changed
  • crates/completest-pty/src

1 file changed

+8
-0
lines changed

crates/completest-pty/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,18 @@ impl BashRuntime {
170170
std::fs::create_dir_all(&home)?;
171171

172172
let config_path = home.join(".bashrc");
173+
let inputrc_path = home.join(".inputrc");
173174
let config = "\
174175
PS1='% '
175176
. /etc/bash_completion
176177
"
177178
.to_owned();
178179
std::fs::write(config_path, config)?;
180+
// Ignore ~/.inputrc which may set vi edit mode.
181+
std::fs::write(
182+
inputrc_path,
183+
"# expected empty file to disable loading ~/.inputrc\n",
184+
)?;
179185

180186
Self::with_home(bin_root, home)
181187
}
@@ -211,8 +217,10 @@ PS1='% '
211217
/// Get the output from typing `input` into the shell
212218
pub fn complete(&mut self, input: &str, term: &Term) -> std::io::Result<String> {
213219
let mut command = Command::new("bash");
220+
let inputrc_path = self.home.join(".inputrc");
214221
command
215222
.env("PATH", &self.path)
223+
.env("INPUTRC", &inputrc_path)
216224
.args([OsStr::new("--rcfile"), self.config.as_os_str()]);
217225
let echo = !input.contains("\t\t");
218226
comptest(command, echo, input, term, self.timeout)

0 commit comments

Comments
 (0)