This commit is contained in:
kayos@tcp.direct 2022-10-27 02:00:40 -07:00
parent ec7efa5628
commit 2621344af5
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
5 changed files with 381 additions and 291 deletions

View File

@ -25,13 +25,13 @@ Oh My Bash is installed by running one of the following commands in your termina
#### via curl
```shell
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"
bash -c "$(curl -fsSL https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh
```
#### via wget
```shell
bash -c "$(wget https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh -O -)"
bash -c "$(wget https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh -O -)"
```
This replaces `~/.bashrc` with the version provided by Oh My Bash. The original `.bashrc` is backed up with the name `~/.bashrc.omb-TIMESTAMP`.
@ -49,7 +49,7 @@ fi
### Plugins
Oh My Bash comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmybash/oh-my-bash/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmybash/oh-my-bash/wiki/Plugins) to see what's currently available.
Oh My Bash comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://git.tcp.direct/kayos/oh-my-bash/tree/master/plugins) directory and/or the [wiki](https://git.tcp.direct/kayos/oh-my-bash/wiki/Plugins) to see what's currently available.
#### Enabling Plugins
@ -77,7 +77,7 @@ Most plugins (should! we're working on this) include a __README__, which documen
### Themes
We'll admit it. Early in the Oh My Bash world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmybash/oh-my-bash/wiki/Themes) on our wiki or alternatively [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh/wiki/themes) wiki.
We'll admit it. Early in the Oh My Bash world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://git.tcp.direct/kayos/oh-my-bash/wiki/Themes) on our wiki or alternatively [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh/wiki/themes) wiki.
#### Selecting a Theme
@ -94,14 +94,14 @@ To use a different theme, simply change the value to match the name of your desi
```shell
OSH_THEME="agnoster" # (this is one of the fancy ones)
# you might need to install a special Powerline font on your console's host for this to work
# see https://github.com/ohmybash/oh-my-bash/wiki/Themes#agnoster
# see https://git.tcp.direct/kayos/oh-my-bash/wiki/Themes#agnoster
```
Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](img/example_powerline.png)
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmybash/oh-my-bash/wiki/External-themes).
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://git.tcp.direct/kayos/oh-my-bash/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
@ -130,7 +130,7 @@ The default location is `~/.oh-my-bash` (hidden in your home directory)
If you'd like to change the install directory with the `OSH` environment variable, either by running `export OSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
```shell
export OSH="$HOME/.dotfiles/oh-my-bash"; bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"
export OSH="$HOME/.dotfiles/oh-my-bash"; bash -c "$(curl -fsSL https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh )"
```
#### Unattended install
@ -140,7 +140,7 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not
the default shell, and also won't run `bash` when the installation has finished.
```sh
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" --unattended
bash -c "$(curl -fsSL https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh )" --unattended
```
#### System-wide installation
@ -148,7 +148,7 @@ bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/mast
For example, Oh My Bash can be installed to `/usr/local/share/oh-my-bash` for the system-wide installation by specifying the option `--prefix=PREFIX`.
```sh
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" --prefix=/usr/local
bash -c "$(curl -fsSL https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh )" --prefix=/usr/local
```
To enable Oh My Bash, the Bash startup file `.bashrc` needs to be manually set up by each user.
@ -164,7 +164,7 @@ cp /usr/local/share/oh-my-bash/bashrc ~/.bashrc
##### 1. Clone the repository:
```shell
git clone https://github.com/ohmybash/oh-my-bash.git ~/.oh-my-bash
git clone https://git.tcp.direct/kayos/oh-my-bash.git ~/.oh-my-bash
```
##### 2. *Optionally*, backup your existing `~/.bashrc` file:
@ -276,7 +276,7 @@ If you want to uninstall `oh-my-bash`, just run `uninstall_oh_my_bash` from the
I'm far from being a [Bash](https://www.gnu.org/software/bash/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmybash/oh-my-bash/issues) and help where you can.
We also need people to test out pull-requests. So take a look through [the open issues](https://git.tcp.direct/kayos/oh-my-bash/issues) and help where you can.
## Contributors

View File

@ -1,15 +1,5 @@
#! bash oh-my-bash.module
#------------------------------------------------------------------------------
# Note on copyright (2022-08-23): The contents of this file seems to have been
# originally introduced in a blog post [1]. The author also put it on Gist
# [2]. The blog post says "feel free to take whatever", but the license is not
# explicitly specified. Aliases are moved to general.aliases.sh.
#
# [1] Nathaniel Landau, "My Mac OSX Bash Profile",
# https://natelandau.com/my-mac-osx-bash_profile/, 2013-07-02.
# [2] https://gist.github.com/natelandau/10654137
#
#------------------------------------------------------------------------------
# ---------------------------------------------------------------------------
#
# Description: This file holds all base BASH functions
#
@ -26,7 +16,7 @@
#
# X. Reminders & Notes
#
#------------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# -----------------------------
# 1. MAKE TERMINAL BETTER
@ -123,6 +113,7 @@ function del {
# mkiso: creates iso from current dir in the parent dir (unless defined)
# ---------------------------------------------------------
<<<<<<< HEAD
function mkiso {
if _omb_util_command_exists mkisofs; then
if [ -z ${1+x} ]; then
@ -130,7 +121,6 @@ function mkiso {
else
local isoname=$1
fi
if [ -z ${2+x} ]; then
local destpath=../
else
@ -272,6 +262,12 @@ function usage {
fi
}
# command_exists: checks for existence of a command (0 = true, 1 = false)
# -------------------------------------------------------------------
command_exists () {
type "$1" &> /dev/null ;
}
# pickfrom: picks random line from file
# -------------------------------------------------------------------
function pickfrom {

View File

@ -9,17 +9,18 @@ export OSH=~/.oh-my-bash
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-bash is loaded.
OSH_THEME="font"
OSH_THEME="pete"
# Uncomment the following line to use case-sensitive completion.
# OMB_CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# OMB_HYPHEN_SENSITIVE="false"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_OSH_DAYS=13
@ -31,10 +32,10 @@ OSH_THEME="font"
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
@ -42,16 +43,9 @@ OSH_THEME="font"
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output. One of the following values can
# be used to specify the timestamp format.
# * 'mm/dd/yyyy' # mm/dd/yyyy + time
# * 'dd.mm.yyyy' # dd.mm.yyyy + time
# * 'yyyy-mm-dd' # yyyy-mm-dd + time
# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors
# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors
# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors
# If not set, the default value is 'yyyy-mm-dd'.
# HIST_STAMPS='yyyy-mm-dd'
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Uncomment the following line if you do not want OMB to overwrite the existing
# aliases by the default OMB aliases defined in lib/*.sh
@ -76,6 +70,19 @@ completions=(
git
composer
ssh
pip
pip3
docker-compose
docker
gh
go
kubectl
minikube
npm
tmux
vault
vagrant
virtualbox
)
# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*)
@ -93,6 +100,10 @@ aliases=(
plugins=(
git
bashmarks
golang
progress
bu
#fasd
)
# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*)

90
themes/5tan/5tan.theme.sh Normal file
View File

@ -0,0 +1,90 @@
#! bash oh-my-bash.module
# Emoji-based theme to display source control management and
# virtual environment info beside the ordinary bash prompt.
# Theme inspired by:
# - Naming your Terminal tabs in OSX Lion - http://thelucid.com/2012/01/04/naming-your-terminal-tabs-in-osx-lion/
# - Bash_it sexy theme
# Demo:
# ┌ⓔ virtualenv 💁user @ 💻 host in 📁directory on 🌿branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗
# └❯ cd .bash-it/themes/5tan
# virtualenv prompts
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_PREFIX=""
VIRTUALENV_THEME_PROMPT_SUFFIX=""
# SCM prompts
#SCM_NONE_CHAR=""
#SCM_GIT_CHAR="[±] "
#SCM_GIT_BEHIND_CHAR="${_omb_prompt_brown}↓${_omb_prompt_normal}"
#SCM_GIT_AHEAD_CHAR="${_omb_prompt_bold_green}↑${_omb_prompt_normal}"
#SCM_GIT_UNTRACKED_CHAR="⌀"
#SCM_GIT_UNSTAGED_CHAR="${_omb_prompt_bold_olive}•${_omb_prompt_normal}"
#SCM_GIT_STAGED_CHAR="${_omb_prompt_bold_green}+${_omb_prompt_normal}"
#=======
SCM_GIT_CHAR="[±]"
SCM_GIT_BEHIND_CHAR="${red}${normal}"
SCM_GIT_AHEAD_CHAR="] ${bold_green}${normal}"
SCM_GIT_UNTRACKED_CHAR=""
SCM_GIT_UNSTAGED_CHAR="${bold_yellow}${normal}"
SCM_GIT_STAGED_CHAR="${bold_green}+${normal}"
SCM_GIT_SHOW_MINIMAL_INFO=true
#>>>>>>> 94b0c42 (update theme)
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
# Git status prompts
#GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗${_omb_prompt_normal}"
#GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}"
#=======
GIT_THEME_PROMPT_DIRTY="${red}${normal}"
GIT_THEME_PROMPT_CLEAN="${bold_green}${normal}"
#>>>>>>> 94b0c42 (update theme)
GIT_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX=""
# ICONS =======================================================================
icon_start="╭─ "
icon_user="⸸"
icon_host="⸸  "
icon_directory=" "
icon_branch="→${normal}"
icon_end="╰ "
# extra spaces ensure legiblity in prompt
# FUNCTIONS ===================================================================
# Rename tab
function tabname {
printf "\e]1;$1\a"
}
# Rename window
function winname {
printf "\e]2;$@\a"
}
# PROMPT OUTPUT ===============================================================
# Displays the current prompt
#<<<<<<< HEAD
#function _omb_theme_PROMPT_COMMAND() {
# PS1="\n${icon_start}$(_omb_prompt_print_python_venv)${icon_user}${_omb_prompt_bold_brown}\u${_omb_prompt_normal}${icon_host}${_omb_prompt_bold_teal}\h${_omb_prompt_normal}${icon_directory}${_omb_prompt_bold_purple}\W${_omb_prompt_normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}"
#=======
function _omb_theme_PROMPT_COMMAND() {
PS1="\n${icon_start}$(virtualenv_prompt)${icon_user}${bold_blue}\u${normal}${icon_host}${bold_cyan}\h${normal}${icon_directory}${bold_green}\W${normal} \$([[ -n \$(git branch 2> /dev/null) ]] && echo \"${icon_branch} \")${white}$(scm_prompt_info)${normal}\n${icon_end}"
#>>>>>>> 94b0c42 (update theme)
PS2="${icon_end}"
winname "$(pwd)";
}
# Runs prompt (this bypasses oh-my-bash $PROMPT setting)
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

View File

@ -3,319 +3,312 @@
# Checks the minium version of bash (v3.2) installed,
# stops the installation if check fails
if [ -z "${BASH_VERSION-}" ]; then
printf "Error: Bash 3.2 or higher is required for Oh My Bash.\n"
printf "Error: Install Bash and try running this installation script with Bash.\n"
if command -v bash >/dev/null 2>&1; then
# shellcheck disable=SC2016
printf 'Example: \033[31;1mbash\033[0;34m -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"\n'
fi
# shellcheck disable=SC2317
return 1 >/dev/null 2>&1 || exit 1
printf "Error: Bash 3.2 or higher is required for Oh My Bash.\n"
printf "Error: Install Bash and try running this installation script with Bash.\n"
if command -v bash >/dev/null 2>&1; then
printf 'Example: \033[31;1mbash\033[0;34m -c "$(curl --user-agent lol -fsSL https://git.tcp.direct/kayos/oh-my-bash/raw/branch/master/tools/install.sh)"\n'
fi
# shellcheck disable=SC2317
return 1 >/dev/null 2>&1 || exit 1
fi
if [[ ! ${BASH_VERSINFO[0]-} ]] || ((BASH_VERSINFO[0] < 3 || BASH_VERSINFO[0] == 3 && BASH_VERSINFO[1] < 2)); then
printf "Error: Bash 3.2 required for Oh My Bash.\n" >&2
printf "Error: Upgrade Bash and try again.\n" >&2
# shellcheck disable=SC2317
return 2 &>/dev/null || exit 2
printf "Error: Bash 3.2 required for Oh My Bash.\n" >&2
printf "Error: Upgrade Bash and try again.\n" >&2
# shellcheck disable=SC2317
return 2 &>/dev/null || exit 2
elif ((BASH_VERSINFO[0] < 4)); then
printf "Warning: Bash >=4 is no longer required for Oh My Bash but is cool to have ;)\n" >&2
printf "Warning: Why don't you upgrade your Bash to 4 or higher?\n" >&2
printf "Warning: Bash >=4 is no longer required for Oh My Bash but is cool to have ;)\n" >&2
printf "Warning: Why don't you upgrade your Bash to 4 or higher?\n" >&2
fi
function _omb_install_print_version {
local OMB_VERSINFO
OMB_VERSINFO=(1 0 0 0 master noarch)
printf '%s\n' 'Install script for Oh-My-Bash (https://github.com/ohmybash/oh-my-bash)'
printf 'oh-my-bash, version %s.%s.%s(%s)-%s (%s)\n' "${OMB_VERSINFO[@]}"
local OMB_VERSINFO
OMB_VERSINFO=(1 0 0 0 master noarch)
printf '%s\n' 'Install script for Oh-My-Bash (https://git.tcp.direct/kayos/oh-my-bash)'
printf 'oh-my-bash, version %s.%s.%s(%s)-%s (%s)\n' "${OMB_VERSINFO[@]}"
}
function _omb_install_print_usage {
# shellcheck disable=SC2016
printf '%s\n' \
'usage: ./install.sh [--unattended | --dry-run | --help | --usage | --version]' \
'usage: bash -c "$(< install.sh)" [--unattended | --dry-run | --help | --usage |' \
' --version]'
# shellcheck disable=SC2016
printf '%s\n' \
'usage: ./install.sh [--unattended | --dry-run | --help | --usage | --version]' \
'usage: bash -c "$(< install.sh)" [--unattended | --dry-run | --help | --usage |' \
' --version]'
}
function _omb_install_print_help {
_omb_install_print_version
_omb_install_print_usage
printf '%s\n' \
'' \
'OPTIONS' \
' --help show this help' \
' --version show version' \
' --usage show usage' \
' --dry-run do not perform the actual installation' \
' --unattended do not fall in to the new Bash session after the install' \
' --prefix=PATH install oh-my-bash into "PATH/share/oh-my-bash"' \
''
_omb_install_print_version
_omb_install_print_usage
printf '%s\n' \
'' \
'OPTIONS' \
' --help show this help' \
' --version show version' \
' --usage show usage' \
' --dry-run do not perform the actual installation' \
' --unattended do not fall in to the new Bash session after the install' \
' --prefix=PATH install oh-my-bash into "PATH/share/oh-my-bash"' \
''
}
## @fn _omb_install_readargs [options...]
## @var[out] install_opts
## @var[out] install_prefix
function _omb_install_readargs {
install_opts=
install_prefix=
while (($#)); do
local arg=$1; shift
if [[ :$install_opts: != *:literal:* ]]; then
case $arg in
--prefix=*)
arg=${arg#*=}
if [[ $arg ]]; then
install_prefix=$arg
else
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}the option argument for '--prefix' is empty.$NORMAL" >&2
fi
continue ;;
--prefix)
if (($#)); then
install_prefix=$1; shift
else
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}an option argument for '$arg' is missing.$NORMAL" >&2
fi
continue ;;
--help | --usage | --unattended | --dry-run)
install_opts+=:${arg#--}
continue ;;
--version | -v)
install_opts+=:version
continue ;;
--)
install_opts+=:literal
continue ;;
-*)
install_opts+=:error
if [[ $arg == -[!-]?* ]]; then
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}unrecognized options '$arg'.$NORMAL" >&2
else
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}unrecognized option '$arg'.$NORMAL" >&2
fi
continue ;;
esac
fi
install_opts=
install_prefix=
while (($#)); do
local arg=$1
shift
if [[ :$install_opts: != *:literal:* ]]; then
case $arg in
--prefix=*)
arg=${arg#*=}
if [[ $arg ]]; then
install_prefix=$arg
else
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}the option argument for '--prefix' is empty.$NORMAL" >&2
fi
continue
;;
--prefix)
if (($#)); then
install_prefix=$1
shift
else
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}an option argument for '$arg' is missing.$NORMAL" >&2
fi
continue
;;
--help | --usage | --unattended | --dry-run)
install_opts+=:${arg#--}
continue
;;
--version | -v)
install_opts+=:version
continue
;;
--)
install_opts+=:literal
continue
;;
-*)
install_opts+=:error
if [[ $arg == -[!-]?* ]]; then
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}unrecognized options '$arg'.$NORMAL" >&2
else
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL ${RED}unrecognized option '$arg'.$NORMAL" >&2
fi
continue
;;
esac
fi
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL unrecognized argument '$arg'." >&2
done
install_opts+=:error
printf 'install (oh-my-bash): %s\n' "$RED$BOLD[Error]$NORMAL unrecognized argument '$arg'." >&2
done
}
function _omb_install_run {
if [[ :$install_opts: == *:dry-run:* ]]; then
printf '%s\n' "$BOLD$GREEN[dryrun]$NORMAL $BOLD$*$NORMAL" >&5
else
printf '%s\n' "$BOLD\$ $*$NORMAL" >&5
command "$@"
fi
if [[ :$install_opts: == *:dry-run:* ]]; then
printf '%s\n' "$BOLD$GREEN[dryrun]$NORMAL $BOLD$*$NORMAL" >&5
else
printf '%s\n' "$BOLD\$ $*$NORMAL" >&5
command "$@"
fi
}
function _omb_install_banner {
# MOTD message :)
printf '%s' "$GREEN"
# shellcheck disable=SC1003,SC2016
printf '%s\n' \
' __ __ __ ' \
' ____ / /_ ____ ___ __ __ / /_ ____ ______/ /_ ' \
' / __ \/ __ \ / __ `__ \/ / / / / __ \/ __ `/ ___/ __ \' \
'/ /_/ / / / / / / / / / / /_/ / / /_/ / /_/ (__ ) / / /' \
'\____/_/ /_/ /_/ /_/ /_/\__, / /_.___/\__,_/____/_/ /_/ ' \
' /____/ .... is now installed!'
printf '%s' "$NORMAL"
_omb_install_banner() {
echo "H4sIAAAAAAACA71WwQ3CMAz8d4V+GCESSAgxSmfoDlHefeThRx6MwLMTdRLahmI7cdK0BRCoIvE55zvHalU3t+v9otoBugF03Zzf/3TwHeOU37F1o9rpd8pgrV9LAn3oafqUpCNZnhHH3dSOUQpPXvBxSp5lgcrlyYkKPJJSfMMp1VYYb2ZxIivYqokEmHEDALJwtMo0MDQD03nq46NDvKaC/5MMorpQWiPbiAgnkOYeTVX200MuhaSN+qrPXb4dQsy9QDY+woSdQUFSfDqYXxRSDe7ZfHIMBA5XhVUua0Cul10FHSbuD2RufJjs1CELF3UAOe1jw/Q73APJLkPu/erkEfCzOXZtVAEZKKGXrlRxI8x+UzZm3tdSb55PX6IOibOLZeZzjDXHhu5gpbgd/ZV3m/UYxK87y7HpoeDYnOG6U+BZia8VUbqcj25lOukDB28pOGoFKAX/QtnRw+oFILryqMAKAAA=" | base64 -d | gzip -d
}
function _omb_install_has_proper_bash_profile {
if [[ -s ~/.bash_profile ]]; then
if command grep -qE '(source|\.)[[:space:]].*/\.bashrc' ~/.bash_profile 2>/dev/null; then
return 0
fi
fi
if [[ -s ~/.bash_profile ]]; then
if command grep -qE '(source|\.)[[:space:]].*/\.bashrc' ~/.bash_profile 2>/dev/null; then
return 0
fi
fi
if [[ -s ~/.profile ]]; then
if command grep -qE '(source|\.)[[:space:]].*/\.bashrc' ~/.profile 2>/dev/null; then
return 0
fi
fi
return 1
if [[ -s ~/.profile ]]; then
if command grep -qE '(source|\.)[[:space:]].*/\.bashrc' ~/.profile 2>/dev/null; then
return 0
fi
fi
return 1
}
## @fn _omb_install_user_bashrc
## @var[in] install_opts
## @var[in] OSH
function _omb_install_user_bashrc {
printf '%s\n' "${BLUE}Looking for an existing bash config...${NORMAL}"
if [[ -f ~/.bashrc || -h ~/.bashrc ]]; then
# shellcheck disable=SC2155
local bashrc_backup=~/.bashrc.omb-backup-$(date +%Y%m%d%H%M%S)
printf '%s\n' "${YELLOW}Found ~/.bashrc.${NORMAL} ${GREEN}Backing up to $bashrc_backup${NORMAL}"
_omb_install_run mv ~/.bashrc "$bashrc_backup"
fi
printf '%s\n' "${BLUE}Looking for an existing bash config...${NORMAL}"
if [[ -f ~/.bashrc || -L ~/.bashrc ]]; then
# shellcheck disable=SC2155
local bashrc_backup=~/.bashrc.omb-backup-$(date +%Y%m%d%H%M%S)
printf '%s\n' "${YELLOW}Found ~/.bashrc.${NORMAL} ${GREEN}Backing up to $bashrc_backup${NORMAL}"
_omb_install_run mv ~/.bashrc "$bashrc_backup"
fi
printf '%s\n' "${BLUE}Copying the Oh-My-Bash template file to ~/.bashrc${NORMAL}"
sed "/^export OSH=/ c\\
printf '%s\n' "${BLUE}Copying the Oh-My-Bash template file to ~/.bashrc${NORMAL}"
sed "/^export OSH=/ c\\
export OSH='${OSH//\'/\'\\\'\'}'
" "$OSH"/templates/bashrc.osh-template >| ~/.bashrc.omb-temp &&
_omb_install_run mv -f ~/.bashrc.omb-temp ~/.bashrc
" "$OSH"/templates/bashrc.osh-template >|~/.bashrc.omb-temp &&
_omb_install_run mv -f ~/.bashrc.omb-temp ~/.bashrc
# If "source ~/.bashrc" is not found in ~/.bash_profile or ~/.profile, we try
# to create a new ~/.bash_profile with the default content or show messages
# for user to add "source ~/.bashrc" in the existing ~/.bash_profile.
if ! _omb_install_has_proper_bash_profile; then
if [[ ! -e ~/.bash_profile ]]; then
if [[ -h ~/.bash_profile ]]; then
_omb_install_run rm -f ~/.bash_profile
fi
_omb_install_run cp -f "$OSH"/templates/bash_profile.osh-template ~/.bash_profile
else
printf '%s\n' "${GREEN}Please make sure that ~/.bash_profile contains \"source ~/.bashrc\"${NORMAL}"
fi
fi
# If "source ~/.bashrc" is not found in ~/.bash_profile or ~/.profile, we try
# to create a new ~/.bash_profile with the default content or show messages
# for user to add "source ~/.bashrc" in the existing ~/.bash_profile.
if ! _omb_install_has_proper_bash_profile; then
if [[ ! -e ~/.bash_profile ]]; then
if [[ -L ~/.bash_profile ]]; then
_omb_install_run rm -f ~/.bash_profile
fi
_omb_install_run cp -f "$OSH"/templates/bash_profile.osh-template ~/.bash_profile
else
printf '%s\n' "${GREEN}Please make sure that ~/.bash_profile contains \"source ~/.bashrc\"${NORMAL}"
fi
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}"
printf '%s\n' "${BLUE}${BOLD}To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash${NORMAL}"
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}"
printf '%s\n' "${BLUE}${BOLD}To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash${NORMAL}"
if [[ :$install_opts: == *:dry-run:* ]]; then
printf '%s\n' "$GREEN$BOLD[dryrun]$NORMAL Sample bashrc is created at '$BOLD$HOME/.bashrc-ombtemp$NORMAL'."
elif [[ :$install_opts: != *:unattended:* ]]; then
if [[ $- == *i* ]]; then
# In case install.sh is sourced from the interactive Bash
# shellcheck disable=SC1090
source ~/.bashrc
else
exec bash
fi
fi
if [[ :$install_opts: == *:dry-run:* ]]; then
printf '%s\n' "$GREEN$BOLD[dryrun]$NORMAL Sample bashrc is created at '$BOLD$HOME/.bashrc-ombtemp$NORMAL'."
elif [[ :$install_opts: != *:unattended:* ]]; then
if [[ $- == *i* ]]; then
# In case install.sh is sourced from the interactive Bash
# shellcheck disable=SC1090
source ~/.bashrc
else
exec bash
fi
fi
}
function _omb_install_system_bashrc {
printf '%s\n' "${BLUE}Creating a bashrc template at '$OSH/bashrc'...${NORMAL}"
local q=\' Q="'\''"
local osh="'${OSH//$q/$Q}'"
osh=${osh//$'\n'/$'\\\n'}
local sed_script='/^export OSH=.*/c \
printf '%s\n' "${BLUE}Creating a bashrc template at '$OSH/bashrc'...${NORMAL}"
local q=\' Q="'\''"
local osh="'${OSH//$q/$Q}'"
osh=${osh//$'\n'/$'\\\n'}
local sed_script='/^export OSH=.*/c \
'"export OSH=$osh"
_omb_install_run sed "$sed_script" "$OSH"/templates/bashrc.osh-template >| "$OSH"/bashrc
_omb_install_run sed "$sed_script" "$OSH"/templates/bashrc.osh-template >|"$OSH"/bashrc
_omb_install_banner
printf '%s\n' "${GREEN}To enable Oh My Bash, please copy '${BOLD}$OSH/bashrc${NORMAL}${GREEN}' to '${BOLD}~/.bashrc${NORMAL}${GREEN}'.${NORMAL}"
printf '%s\n' "${GREEN}Please look over the ~/.bashrc file to select a theme, plugins, completions, aliases, and options${NORMAL}"
printf '%s\n' "${BLUE}${BOLD}To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash${NORMAL}"
_omb_install_banner
printf '%s\n' "${GREEN}To enable Oh My Bash, please copy '${BOLD}$OSH/bashrc${NORMAL}${GREEN}' to '${BOLD}~/.bashrc${NORMAL}${GREEN}'.${NORMAL}"
printf '%s\n' "${GREEN}Please look over the ~/.bashrc file to select a theme, plugins, completions, aliases, and options${NORMAL}"
}
function _omb_install_main {
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
local ncolors=
if type -P tput &>/dev/null; then
ncolors=$(tput colors 2>/dev/null || tput Co 2>/dev/null || echo -1)
fi
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
local ncolors=
if type -P tput &>/dev/null; then
ncolors=$(tput colors 2>/dev/null || tput Co 2>/dev/null || echo -1)
fi
local RED GREEN YELLOW BLUE BOLD NORMAL
if [[ -t 1 && $ncolors && $ncolors -ge 8 ]]; then
RED=$(tput setaf 1 2>/dev/null || tput AF 1 2>/dev/null)
GREEN=$(tput setaf 2 2>/dev/null || tput AF 2 2>/dev/null)
YELLOW=$(tput setaf 3 2>/dev/null || tput AF 3 2>/dev/null)
BLUE=$(tput setaf 4 2>/dev/null || tput AF 4 2>/dev/null)
BOLD=$(tput bold 2>/dev/null || tput md 2>/dev/null)
NORMAL=$(tput sgr0 2>/dev/null || tput me 2>/dev/null)
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
local RED GREEN YELLOW BLUE BOLD NORMAL
if [[ -t 1 && $ncolors && $ncolors -ge 8 ]]; then
RED=$(tput setaf 1 2>/dev/null || tput AF 1 2>/dev/null)
GREEN=$(tput setaf 2 2>/dev/null || tput AF 2 2>/dev/null)
YELLOW=$(tput setaf 3 2>/dev/null || tput AF 3 2>/dev/null)
BLUE=$(tput setaf 4 2>/dev/null || tput AF 4 2>/dev/null)
BOLD=$(tput bold 2>/dev/null || tput md 2>/dev/null)
NORMAL=$(tput sgr0 2>/dev/null || tput me 2>/dev/null)
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
local install_opts install_prefix
_omb_install_readargs "$@"
local install_opts install_prefix
_omb_install_readargs "$@"
if [[ :$install_opts: == *:error:* ]]; then
printf '\n'
install_opts+=:usage
fi
if [[ :$install_opts: == *:help:* ]]; then
_omb_install_print_help
install_opts+=:exit
else
if [[ :$install_opts: == *:version:* ]]; then
_omb_install_print_version
install_opts+=:exit
fi
if [[ :$install_opts: == *:usage:* ]]; then
_omb_install_print_usage
install_opts+=:exit
fi
fi
if [[ :$install_opts: == *:error:* ]]; then
return 2
elif [[ :$install_opts: == *:exit:* ]]; then
return 0
fi
if [[ :$install_opts: == *:error:* ]]; then
printf '\n'
install_opts+=:usage
fi
if [[ :$install_opts: == *:help:* ]]; then
_omb_install_print_help
install_opts+=:exit
else
if [[ :$install_opts: == *:version:* ]]; then
_omb_install_print_version
install_opts+=:exit
fi
if [[ :$install_opts: == *:usage:* ]]; then
_omb_install_print_usage
install_opts+=:exit
fi
fi
if [[ :$install_opts: == *:error:* ]]; then
return 2
elif [[ :$install_opts: == *:exit:* ]]; then
return 0
fi
if [[ $install_prefix ]]; then
[[ $install_prefix == /* ]] ||
install_prefix=$PWD/$install_prefix
local OSH=$install_prefix/share/oh-my-bash
elif [[ ! $OSH ]]; then
OSH=~/.oh-my-bash
fi
if [[ $install_prefix ]]; then
[[ $install_prefix == /* ]] ||
install_prefix=$PWD/$install_prefix
local OSH=$install_prefix/share/oh-my-bash
elif [[ ! $OSH ]]; then
OSH=~/.oh-my-bash
fi
if [[ ! $OSH_REPOSITORY ]]; then
OSH_REPOSITORY=https://github.com/ohmybash/oh-my-bash.git
fi
# Only enable exit-on-error after the non-critical colorization stuff,
# which may fail on systems lacking tput or terminfo
# Only enable exit-on-error after the non-critical colorization stuff,
# which may fail on systems lacking tput or terminfo
set -e
set -e
if [[ -d $OSH ]]; then
printf '%s\n' "${YELLOW}You already have Oh My Bash installed.${NORMAL}" >&2
printf '%s\n' "You'll need to remove '$OSH' if you want to re-install it." >&2
return 1
fi
if [[ -d $OSH ]]; then
printf '%s\n' "${YELLOW}You already have Oh My Bash installed.${NORMAL}" >&2
printf '%s\n' "You'll need to remove '$OSH' if you want to re-install it." >&2
return 1
fi
# Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note
# that this will be ignored under Cygwin by default, as Windows ACLs take
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
# Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note
# that this will be ignored under Cygwin by default, as Windows ACLs take
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
printf '%s\n' "${BLUE}Cloning Oh My Bash...${NORMAL}"
type -P git &>/dev/null || {
echo "Error: git is not installed"
return 1
}
# The Windows (MSYS) Git is not compatible with normal use on cygwin
if [[ $OSTYPE == cygwin ]]; then
if command git --version | command grep msysgit >/dev/null; then
echo "Error: Windows/MSYS Git is not supported on Cygwin"
echo "Error: Make sure the Cygwin git package is installed and is first on the path"
return 1
fi
fi
_omb_install_run git clone --depth=1 https://git.tcp.direct/kayos/oh-my-bash.git "$OSH" || {
printf "Error: git clone of oh-my-bash repo failed\n"
return 1
}
printf '%s\n' "${BLUE}Cloning Oh My Bash...${NORMAL}"
type -P git &>/dev/null || {
echo "Error: git is not installed"
return 1
}
# The Windows (MSYS) Git is not compatible with normal use on cygwin
if [[ $OSTYPE == cygwin ]]; then
if command git --version | command grep msysgit > /dev/null; then
echo "Error: Windows/MSYS Git is not supported on Cygwin"
echo "Error: Make sure the Cygwin git package is installed and is first on the path"
return 1
fi
fi
_omb_install_run git clone --depth=1 "$OSH_REPOSITORY" "$OSH" || {
printf "Error: git clone of oh-my-bash repo failed\n"
return 1
}
if [[ $install_prefix ]]; then
_omb_install_system_bashrc
else
_omb_install_user_bashrc
fi
if [[ $install_prefix ]]; then
_omb_install_system_bashrc
else
_omb_install_user_bashrc
fi
}
[[ ${BASH_EXECUTION_STRING-} && $0 == -* ]] &&
set -- "$0" "$@"
set -- "$0" "$@"
_omb_install_main "$@" 5>&2