mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-09-21 10:27:09 +00:00
tools/install: create "~/.bash_profile" if it doesn't exist
This commit is contained in:
parent
60332ed8fb
commit
f6597af711
@ -35,6 +35,15 @@ bash -c "$(wget https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/too
|
||||
```
|
||||
|
||||
This replaces `~/.bashrc` with the version provided by Oh My Bash. The original `.bashrc` is backed up with the name `~/.bashrc.omb-TIMESTAMP`.
|
||||
If `~/.bash_profile` does not exist, this also creates a new file `~/.bash_profile` with the default contents.
|
||||
|
||||
⚠️ If `~/.bash_profile` already existed before Oh My Bash is installed, please make sure that`~/.bash_profile` contains the line `source ~/.bashrc` or `. ~/.bashrc`.
|
||||
If not, please add the following three lines in `~/.bash_profile`:
|
||||
```bash
|
||||
if [[ -f ~/.bashrc ]]; then
|
||||
source ~/.bashrc
|
||||
fi
|
||||
```
|
||||
|
||||
## Using Oh My Bash
|
||||
|
||||
|
11
templates/bash_profile.osh-template
Normal file
11
templates/bash_profile.osh-template
Normal file
@ -0,0 +1,11 @@
|
||||
# .bash_profile -*- mode: sh -*-
|
||||
|
||||
# Load login settings and environment variables
|
||||
if [[ -f ~/.profile ]]; then
|
||||
source ~/.profile
|
||||
fi
|
||||
|
||||
# Load interactive settings
|
||||
if [[ -f ~/.bashrc ]]; then
|
||||
source ~/.bashrc
|
||||
fi
|
@ -134,13 +134,24 @@ _omb_install_user_bashrc() {
|
||||
_omb_install_run mv ~/.bashrc "$bashrc_backup"
|
||||
fi
|
||||
|
||||
printf "${BLUE}Using the Oh My Bash template file and adding it to ~/.bashrc${NORMAL}\n"
|
||||
_omb_install_run cp "$OSH"/templates/bashrc.osh-template ~/.bashrc
|
||||
printf "${BLUE}Copying the Oh-My-Bash template file to ~/.bashrc${NORMAL}\n"
|
||||
sed "/^export OSH=/ c\\
|
||||
export OSH='${OSH//\'/\'\\\'\'}'
|
||||
" ~/.bashrc >| ~/.bashrc.omb-temp
|
||||
" "$OSH"/templates/bashrc.osh-template >| ~/.bashrc.omb-temp &&
|
||||
_omb_install_run mv -f ~/.bashrc.omb-temp ~/.bashrc
|
||||
|
||||
# If no file is found at ~/.bash_profile, we create it with the default
|
||||
# content.
|
||||
if [[ ! -e ~/.bash_profile ]]; then
|
||||
if [[ -h ~/.bash_profile ]]; then
|
||||
_omb_install_run rm -f ~/.bash_profile
|
||||
fi
|
||||
_omb_install_run mv -f "$OSH"/templates/bash_profile.osh-template ~/.bash_profile
|
||||
else
|
||||
command grep -qE '(source|\.)[[:space:]].*/\.bashrc' ~/.bash_profile 2>/dev/null ||
|
||||
printf '%s\n' "${GREEN}Please make sure that ~/.bash_profile contains \"source ~/.bashrc\"${NORMAL}"
|
||||
fi
|
||||
|
||||
set +e
|
||||
_omb_install_banner
|
||||
printf '%s\n' "${GREEN}Please look over the ~/.bashrc file to select a theme, plugins, completions, aliases, and options${NORMAL}"
|
||||
|
Loading…
Reference in New Issue
Block a user