1use super::Shell;
2use std::path::Path;
3
4#[derive(Debug)]
5pub struct Bash;
6
7impl Shell for Bash {
8 fn path(&self, path: &Path, append: bool) -> String {
9 if append {
10 return format!("export PATH=$PATH:{:?};", path.display());
11 }
12
13 format!("export PATH={:?}:$PATH", path.display())
14 }
15
16 fn env_var(&self, name: &str, value: &str) -> String {
17 format!("export {}={:?}", name, value)
18 }
19
20 fn use_on_cd(&self) -> &'static str {
21 indoc::indoc!(
22 r#"
23 __snm_use_if_file_found() {
24 if [[ -f .node-version || -f .nvmrc || -f package.json ]]; then
25 snm use
26 fi
27 }
28 __snmcd() {
29 \cd "$@" || return $?
30 __snm_use_if_file_found
31 }
32 alias cd=__snmcd
33 __snm_use_if_file_found
34 "#
35 )
36 }
37}