-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
510 additions
and
241 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::io::Write; | ||
use std::process::Command; | ||
|
||
use anyhow::Result; | ||
|
||
use super::ShellSpawnInfo; | ||
|
||
pub fn spawn_shell(info: &ShellSpawnInfo) -> Result<()> { | ||
let mut temp_rc_file = tempfile::Builder::new() | ||
.prefix("kubie-bashrc") | ||
.suffix(".bash") | ||
.tempfile()?; | ||
|
||
write!( | ||
temp_rc_file, | ||
r#" | ||
if [ -f "$HOME/.bashrc" ] ; then | ||
source "$HOME/.bashrc" | ||
elif [ -f "/etc/skel/.bashrc" ] ; then | ||
source /etc/skel/.bashrc | ||
fi | ||
function __kubie_cmd_pre_exec__() {{ | ||
export KUBECONFIG="$KUBIE_KUBECONFIG" | ||
}} | ||
trap '__kubie_cmd_pre_exec__' DEBUG | ||
KUBIE_PROMPT='{}' | ||
PS1="$KUBIE_PROMPT $PS1" | ||
unset KUBIE_PROMPT | ||
"#, | ||
info.prompt, | ||
)?; | ||
temp_rc_file.flush()?; | ||
|
||
let mut cmd = Command::new("bash"); | ||
cmd.arg("--rcfile"); | ||
cmd.arg(temp_rc_file.path()); | ||
info.env_vars.apply(&mut cmd); | ||
|
||
let mut child = cmd.spawn()?; | ||
child.wait()?; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.