mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
Fix few issues & improve framework functionality
- Fixed LSCOLORS from theme-and-appearance.sh - Fixed ii() command in core plugin - Stop using .bashrc as Oh-My-Bash profile, use .bash_profile instead - Automate backport new version for old version users - Added .editorconfig for future contribution
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
# Matches multiple files with brace expansion notation
|
||||
[*.{sh,py,yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,5 +13,6 @@
|
||||
!/log/.gitkeep
|
||||
|
||||
# disabled files
|
||||
*.swp
|
||||
*.disabled
|
||||
.idea/
|
||||
|
@@ -2,36 +2,3 @@
|
||||
|
||||
# colored ls
|
||||
export LSCOLORS='Gxfxcxdxdxegedabagacad'
|
||||
|
||||
if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
|
||||
# Find the option for using colors in ls, depending on the version
|
||||
if [[ "$OSTYPE" == netbsd* ]]; then
|
||||
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
elif [[ "$OSTYPE" == openbsd* ]]; then
|
||||
# On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
|
||||
# with color and multibyte support) are available from ports. "colorls"
|
||||
# will be installed on purpose and can't be pulled in by installing
|
||||
# coreutils, so prefer it to "gls".
|
||||
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
colorls -G -d . &>/dev/null && alias ls='colorls -G'
|
||||
elif [[ "$OSTYPE" == darwin* ]]; then
|
||||
# this is a good alias, it works by default just using $LSCOLORS
|
||||
ls -G . &>/dev/null && alias ls='ls -G'
|
||||
|
||||
# only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
|
||||
# otherwise, gls will use the default color scheme which is ugly af
|
||||
[[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
else
|
||||
# For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
|
||||
if [[ -z "$LS_COLORS" ]]; then
|
||||
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
|
||||
fi
|
||||
|
||||
#ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
|
||||
|
||||
# Take advantage of $LS_COLORS for completion as well.
|
||||
#zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
fi
|
||||
fi
|
||||
|
@@ -179,14 +179,14 @@ ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name end
|
||||
# ii: display useful host related informaton
|
||||
# -------------------------------------------------------------------
|
||||
ii() {
|
||||
echo -e "\nYou are logged on ${red}$HOST"
|
||||
echo -e "\nAdditionnal information:$NC " ; uname -a
|
||||
echo -e "\n${red}Users logged on:$NC " ; w -h
|
||||
echo -e "\n${red}Current date :$NC " ; date
|
||||
echo -e "\n${red}Machine stats :$NC " ; uptime
|
||||
#echo -e "\n${red}Current network location :$NC " ; scselect
|
||||
echo -e "\n${red}Public facing IP Address :$NC " ;myip
|
||||
#echo -e "\n${red}DNS Configuration:$NC " ; scutil --dns
|
||||
echo -e "\\nYou are logged on ${red}$HOST"
|
||||
echo -e "\\nAdditionnal information:$NC " ; uname -a
|
||||
echo -e "\\n${red}Users logged on:$NC " ; w -h
|
||||
echo -e "\\n${red}Current date :$NC " ; date
|
||||
echo -e "\\n${red}Machine stats :$NC " ; uptime
|
||||
[[ "$OSTYPE" == darwin* ]] && echo -e "\\n${red}Current network location :$NC " ; scselect
|
||||
echo -e "\\n${red}Public facing IP Address :$NC " ;myip
|
||||
[[ "$OSTYPE" == darwin* ]] && echo -e "\\n${red}DNS Configuration:$NC " ; scutil --dns
|
||||
echo
|
||||
}
|
||||
|
||||
@@ -216,7 +216,6 @@ ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name end
|
||||
else
|
||||
du -hd 1
|
||||
fi
|
||||
|
||||
elif [ $(uname) = "Linux" ]; then
|
||||
if [ -n "$1" ]; then
|
||||
du -h --max-depth=1 "$1"
|
||||
|
@@ -1,6 +1,3 @@
|
||||
# If you come from bash you might have to change your $PATH.
|
||||
# export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||
|
||||
# Path to your oh-my-bash installation.
|
||||
export OSH=$HOME/.oh-my-bash
|
||||
|
||||
@@ -48,7 +45,7 @@ OSH_THEME="font"
|
||||
|
||||
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*)
|
||||
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Example format: plugins=(core rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
plugins=(core git bashmarks progress)
|
||||
|
117
templates/bashrc.default-template
Normal file
117
templates/bashrc.default-template
Normal file
@@ -0,0 +1,117 @@
|
||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return;;
|
||||
esac
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# If set, the pattern "**" used in a pathname expansion context will
|
||||
# match all files and zero or more directories and subdirectories.
|
||||
#shopt -s globstar
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||
case "$TERM" in
|
||||
xterm-color|*-256color) color_prompt=yes;;
|
||||
esac
|
||||
|
||||
# uncomment for a colored prompt, if the terminal has the capability; turned
|
||||
# off by default to not distract the user: the focus in a terminal window
|
||||
# should be on the output of commands, not on the prompt
|
||||
#force_color_prompt=yes
|
||||
|
||||
if [ -n "$force_color_prompt" ]; then
|
||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
# We have color support; assume it's compliant with Ecma-48
|
||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||
# a case would tend to support setf rather than setaf.)
|
||||
color_prompt=yes
|
||||
else
|
||||
color_prompt=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
fi
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto'
|
||||
#alias dir='dir --color=auto'
|
||||
#alias vdir='vdir --color=auto'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
fi
|
||||
|
||||
# colored GCC warnings and errors
|
||||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# Add an "alert" alias for long running commands. Use like so:
|
||||
# sleep 10; alert
|
||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||
|
||||
# Alias definitions.
|
||||
# You may want to put all your additions into a separate file like
|
||||
# ~/.bash_aliases, instead of adding them here directly.
|
||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
# enable programmable completion features (you don't need to enable
|
||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||
# sources /etc/bash.bashrc).
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
6
tools/backward_compatible.sh
Normal file
6
tools/backward_compatible.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -f $HOME/.bashrc.pre-oh-my-bash ] || [ -h $HOME/.bashrc.pre-oh-my-bash ]; then
|
||||
mv $HOME/.bashrc.pre-oh-my-bash HOME/.bash_profile.pre-oh-my-bash
|
||||
cp $OSH/templates/bashrc.default-template $HOME/.bashrc
|
||||
fi
|
@@ -11,7 +11,7 @@ function _update_osh_update() {
|
||||
}
|
||||
|
||||
function _upgrade_osh() {
|
||||
env OSH=$OSH sh $OSH/tools/upgrade.sh
|
||||
env BASH=$OSH sh $OSH/tools/upgrade.sh
|
||||
# update the osh file
|
||||
_update_osh_update
|
||||
}
|
||||
|
@@ -62,17 +62,17 @@ main() {
|
||||
}
|
||||
|
||||
printf "${BLUE}Looking for an existing bash config...${NORMAL}\n"
|
||||
if [ -f ~/.bashrc ] || [ -h ~/.bashrc ]; then
|
||||
printf "${YELLOW}Found ~/.bashrc.${NORMAL} ${GREEN}Backing up to ~/.bashrc.pre-oh-my-bash${NORMAL}\n";
|
||||
mv ~/.bashrc ~/.bashrc.pre-oh-my-bash;
|
||||
if [ -f $HOME/.bash_profile ] || [ -h $HOME/.bash_profile ]; then
|
||||
printf "${YELLOW}Found ~/.bash_profile.${NORMAL} ${GREEN}Backing up to ~/.bash_profile.pre-oh-my-bash${NORMAL}\n";
|
||||
mv $HOME/.bash_profile $HOME/.bash_profile.pre-oh-my-bash;
|
||||
fi
|
||||
|
||||
printf "${BLUE}Using the Oh My Bash template file and adding it to ~/.bashrc${NORMAL}\n"
|
||||
cp $OSH/templates/bashrc.osh-template ~/.bashrc
|
||||
cp $OSH/templates/bash_profile.osh-template $HOME/.bash_profile
|
||||
sed "/^export OSH=/ c\\
|
||||
export OSH=$OSH
|
||||
" ~/.bashrc > ~/.bashrc-ombtemp
|
||||
mv -f ~/.bashrc-ombtemp ~/.bashrc
|
||||
export OSH=$OSH
|
||||
" $HOME/.bash_profile > $HOME/.bash_profile-ombtemp
|
||||
mv -f $HOME/.bash_profile-ombtemp $HOME/.bash_profile
|
||||
|
||||
# MOTD message :)
|
||||
printf '%s' "$GREEN"
|
||||
@@ -84,7 +84,7 @@ main() {
|
||||
printf '%s\n' ' /____/ .... is now installed!'
|
||||
printf "%s\n" "Please look over the ~/.bashrc file to select plugins, themes, and options"
|
||||
printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash"
|
||||
source $HOME/.bashrc
|
||||
. $HOME/.bash_profile
|
||||
}
|
||||
|
||||
|
||||
|
20
tools/uninstall.sh
Normal file → Executable file
20
tools/uninstall.sh
Normal file → Executable file
@@ -7,21 +7,21 @@ if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
|
||||
fi
|
||||
|
||||
echo "Removing ~/.oh-my-bash"
|
||||
if [ -d ~/.oh-my-bash ]; then
|
||||
rm -rf ~/.oh-my-bash
|
||||
if [ -d $HOME/.oh-my-bash ]; then
|
||||
rm -rf $HOME/.oh-my-bash
|
||||
fi
|
||||
|
||||
echo "Looking for original bash config..."
|
||||
if [ -f ~/.bashrc.pre-oh-my-bash ] || [ -h ~/.bashrc.pre-oh-my-bash ]; then
|
||||
echo "Found ~/.bashrc.pre-oh-my-bash -- Restoring to ~/.bashrc";
|
||||
if [ -f $HOME/.bash_profile.pre-oh-my-bash ] || [ -h $HOME/.bash_profile.pre-oh-my-bash ]; then
|
||||
echo "Found ~/.bash_profile.pre-oh-my-bash -- Restoring to ~/.bash_profile";
|
||||
|
||||
if [ -f ~/.bashrc ] || [ -h ~/.bashrc ]; then
|
||||
BASHRC_SAVE=".bashrc.omb-uninstalled-$(date +%Y%m%d%H%M%S)";
|
||||
echo "Found ~/.bashrc -- Renaming to ~/${BASHRC_SAVE}";
|
||||
mv ~/.bashrc ~/"${BASHRC_SAVE}";
|
||||
if [ -f $HOME/.bash_profile ] || [ -h $HOME/.bash_profile ]; then
|
||||
BASH_PROFILE_SAVE=".bash_profile.omb-uninstalled-$(date +%Y%m%d%H%M%S)";
|
||||
echo "Found ~/.bash_profile -- Renaming to ~/${BASH_PROFILE_SAVE}";
|
||||
mv $HOME/.bash_profile $HOME/"${BASH_PROFILE_SAVE}";
|
||||
fi
|
||||
|
||||
mv ~/.bashrc.pre-oh-my-bash ~/.bashrc;
|
||||
mv $HOME/.bash_profile.pre-oh-my-bash $HOME/.bash_profile;
|
||||
|
||||
echo "Your original bash config was restored. Please restart your session."
|
||||
else
|
||||
@@ -33,4 +33,4 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Thanks for trying out Oh My Bash. It's been uninstalled."
|
||||
echo "Thanks for trying out Oh My Bash. It has been uninstalled."
|
||||
|
@@ -34,7 +34,8 @@ then
|
||||
printf '%s\n' ' /____/ '
|
||||
printf "${BLUE}%s\n" "Hooray! Oh My Bash has been updated and/or is at the current version."
|
||||
printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash"
|
||||
source $HOME/.bashrc
|
||||
sh $OSH/tools/backward_compatible.sh
|
||||
. $HOME/.bash_profile
|
||||
else
|
||||
printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
|
||||
fi
|
||||
|
Reference in New Issue
Block a user