Skip to content

Commit

Permalink
Fix bug on missing line feed on last line (#283)
Browse files Browse the repository at this point in the history
If you have a shell config without line feed at the end of the file,
the appended line would follow the last line. Fix this by adding an
empty line before adding actual content.
  • Loading branch information
endremm authored Oct 29, 2024
1 parent 94fbac2 commit ac09ad6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/aws/admin-session.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func startWorkingShell(awsProfile string) error {
func startZshWorkingShell(awsProfile string) error {
setup := "mkdir -p /tmp/zsh-sso-admin-session;" +
"find $HOME -type f -maxdepth 1 -name \".zsh*\" | xargs -I {} cp {} /tmp/zsh-sso-admin-session;" +
"echo >> /tmp/zsh-sso-admin-session/.zshrc;" +
"echo 'export AWS_PROFILE=" + awsProfile + "' >> /tmp/zsh-sso-admin-session/.zshrc;" +
"echo 'export PROMPT=\"%F{red}SSO-Admin-Session%f (${AWS_PROFILE}) %~ $ \"' >> /tmp/zsh-sso-admin-session/.zshrc"
cmd := exec.Command(os.Getenv("SHELL"), "-c", setup)
Expand All @@ -230,6 +231,7 @@ func startZshWorkingShell(awsProfile string) error {
func startBashWorkingShell(awsProfile string) error {
setup := "mkdir -p /tmp/bash-sso-admin-session;" +
"find $HOME -type f -maxdepth 1 -name \".bashrc\" | xargs -I {} cp {} /tmp/bash-sso-admin-session;" +
"echo >> /tmp/bash-sso-admin-session/.bashrc;" +
"echo 'export AWS_PROFILE=" + awsProfile + "' >> /tmp/bash-sso-admin-session/.bashrc;" +
"echo 'export PS1=\"\\e[31m\\]SSO-Admin-Session\\e[0m\\] (${AWS_PROFILE}) \\w $ \"' >> /tmp/bash-sso-admin-session/.bashrc"
cmd := exec.Command(os.Getenv("SHELL"), "-c", setup)
Expand Down

0 comments on commit ac09ad6

Please sign in to comment.