From fa4f8beae40578cda329f93434b45cbf0cf9e6be Mon Sep 17 00:00:00 2001 From: gittestuser Date: Fri, 4 Feb 2022 11:22:57 +0100 Subject: [PATCH] fixe bashrcd issue --- .../provs/desktop/infrastructure/Bash.kt | 14 ++++---------- .../desktop/infrastructure/bashrcd-enhancement.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/org/domaindrivenarchitecture/provs/desktop/infrastructure/bashrcd-enhancement.sh diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Bash.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Bash.kt index 60e6560..00e2dd4 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Bash.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Bash.kt @@ -2,12 +2,15 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.ProvResult +import org.domaindrivenarchitecture.provs.framework.core.endingWithFileSeparator +import org.domaindrivenarchitecture.provs.framework.core.getResourceAsText import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.addTextToFile import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDir import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.dirExists import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall import java.io.File +private val resourcePath = "org/domaindrivenarchitecture/provs/desktop/infrastructure/" fun Prov.configureBash() = def { configureBashForUser() @@ -20,16 +23,7 @@ fun Prov.configureBashForUser(): ProvResult = def { cmd("chmod 755 " + dirname) aptInstall("bash-completion screen") - val enhance = """ - # source .bashrc.d files - if [ -d ~/.bashrc.d ]; then - for i in ~/.bashrc.d/*.sh; do - if [ -r \$\{i} ]; then - . \\\$\{i} - fi - done - unset i - fi""".trimIndent() + "\n" + val enhance = getResourceAsText(resourcePath + "bashrcd-enhancement.sh").trimIndent() + "\n" addTextToFile(text = enhance, file = File("~/.bashrc")) } else { ProvResult(true) diff --git a/src/main/resources/org/domaindrivenarchitecture/provs/desktop/infrastructure/bashrcd-enhancement.sh b/src/main/resources/org/domaindrivenarchitecture/provs/desktop/infrastructure/bashrcd-enhancement.sh new file mode 100644 index 0000000..e6313ea --- /dev/null +++ b/src/main/resources/org/domaindrivenarchitecture/provs/desktop/infrastructure/bashrcd-enhancement.sh @@ -0,0 +1,9 @@ +# source .bashrc.d files +if [ -d ~/.bashrc.d ]; then + for i in ~/.bashrc.d/*.sh; do + if [ -r ${i} ]; then + . ${i} + fi + done + unset i +fi