Improve autoinstall
This commit is contained in:
parent
b5764c0376
commit
57cd02890a
8 changed files with 92 additions and 187 deletions
15
.bashrc
15
.bashrc
|
@ -8,12 +8,13 @@ then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
autoinstall-packages
|
autoinstall all
|
||||||
|
|
||||||
# Set name of the theme to load. Optionally, if you set this to "random"
|
# 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.
|
# it'll load a random theme each time that oh-my-bash is loaded.
|
||||||
OSH_THEME="brainy"
|
OSH_THEME="brainy"
|
||||||
[ -x "$(command -v starship)" ] && ZSH_THEME=""
|
# shellcheck disable=SC2034
|
||||||
|
[ -x "$(command -v starship)" ] && OSH_THEME=""
|
||||||
|
|
||||||
# Uncomment the following line to use case-sensitive completion.
|
# Uncomment the following line to use case-sensitive completion.
|
||||||
# CASE_SENSITIVE="true"
|
# CASE_SENSITIVE="true"
|
||||||
|
@ -32,9 +33,11 @@ OSH_THEME="brainy"
|
||||||
# DISABLE_LS_COLORS="true"
|
# DISABLE_LS_COLORS="true"
|
||||||
|
|
||||||
# Uncomment the following line to disable auto-setting terminal title.
|
# Uncomment the following line to disable auto-setting terminal title.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
DISABLE_AUTO_TITLE="true"
|
DISABLE_AUTO_TITLE="true"
|
||||||
|
|
||||||
# Uncomment the following line to enable command auto-correction.
|
# Uncomment the following line to enable command auto-correction.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
ENABLE_CORRECTION="true"
|
ENABLE_CORRECTION="true"
|
||||||
|
|
||||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||||
|
@ -48,6 +51,7 @@ ENABLE_CORRECTION="true"
|
||||||
# Uncomment the following line if you want to change the command execution time
|
# Uncomment the following line if you want to change the command execution time
|
||||||
# stamp shown in the history command output.
|
# stamp shown in the history command output.
|
||||||
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
HIST_STAMPS="yyyy-mm-dd"
|
HIST_STAMPS="yyyy-mm-dd"
|
||||||
|
|
||||||
# Would you like to use another custom folder than $OSH/custom?
|
# Would you like to use another custom folder than $OSH/custom?
|
||||||
|
@ -57,6 +61,7 @@ HIST_STAMPS="yyyy-mm-dd"
|
||||||
# Custom completions may be added to ~/.oh-my-bash/custom/completions/
|
# Custom completions may be added to ~/.oh-my-bash/custom/completions/
|
||||||
# Example format: completions=(ssh git bundler gem pip pip3)
|
# Example format: completions=(ssh git bundler gem pip pip3)
|
||||||
# Add wisely, as too many completions slow down shell startup.
|
# Add wisely, as too many completions slow down shell startup.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
completions=(
|
completions=(
|
||||||
git
|
git
|
||||||
composer
|
composer
|
||||||
|
@ -67,6 +72,7 @@ completions=(
|
||||||
# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/
|
# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/
|
||||||
# Example format: aliases=(vagrant composer git-avh)
|
# Example format: aliases=(vagrant composer git-avh)
|
||||||
# Add wisely, as too many aliases slow down shell startup.
|
# Add wisely, as too many aliases slow down shell startup.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
aliases=(
|
aliases=(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,11 +80,12 @@ aliases=(
|
||||||
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
|
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
|
||||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||||
# Add wisely, as too many plugins slow down shell startup.
|
# Add wisely, as too many plugins slow down shell startup.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
plugins=(
|
plugins=(
|
||||||
git
|
git
|
||||||
)
|
)
|
||||||
|
|
||||||
source $OSH/oh-my-bash.sh
|
source "$OSH/oh-my-bash.sh"
|
||||||
|
|
||||||
HISTCONTROL=ignoreboth
|
HISTCONTROL=ignoreboth
|
||||||
export SAVEHIST=1000000
|
export SAVEHIST=1000000
|
||||||
|
@ -91,6 +98,6 @@ shopt -s checkwinsize
|
||||||
source "$HOME/.config/environment"
|
source "$HOME/.config/environment"
|
||||||
source "$HOME/.config/completionsrc"
|
source "$HOME/.config/completionsrc"
|
||||||
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
|
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
|
||||||
[ -x "$(command -v thefuck)" ] && eval $(thefuck --alias)
|
[ -x "$(command -v thefuck)" ] && eval "$(thefuck --alias)"
|
||||||
|
|
||||||
[ -x "$(command -v starship)" ] && eval "$(starship init bash)"
|
[ -x "$(command -v starship)" ] && eval "$(starship init bash)"
|
||||||
|
|
62
.bin/autoinstall
Executable file
62
.bin/autoinstall
Executable file
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
_autoinstall_all () {
|
||||||
|
plug_path="$HOME/.config/vim/autoload/plug.vim"
|
||||||
|
if [ ! -f "$plug_path" ]
|
||||||
|
then
|
||||||
|
_autoinstall_file "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" "$plug_path"
|
||||||
|
[ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvim_dir="$HOME/.config/nvim"
|
||||||
|
if [ ! -d "$nvim_dir" ]
|
||||||
|
then
|
||||||
|
_autoinstall_git "https://github.com/AstroNvim/AstroNvim" "$nvim_dir"
|
||||||
|
[ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$(command -v starship)" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$HOME/.local/bin"
|
||||||
|
curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "$(command -v envsubst)" ]
|
||||||
|
then
|
||||||
|
wakatime_cfg="$WAKATIME_HOME/.wakatime.cfg"
|
||||||
|
wakatime_tpl="$wakatime_cfg.tpl"
|
||||||
|
envsubst < "$wakatime_tpl" > "$wakatime_cfg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_autoinstall_file \
|
||||||
|
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
|
||||||
|
"$HOME/.local/bin/git-fire"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_autoinstall_git () {
|
||||||
|
if [ ! -d "$2" ]
|
||||||
|
then
|
||||||
|
echo "Installing repo $1 to $2"
|
||||||
|
mkdir -p "$2"
|
||||||
|
git clone "$1" "$2" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_autoinstall_file () {
|
||||||
|
if [ ! -f "$2" ]
|
||||||
|
then
|
||||||
|
echo "Installing file $1 to $2"
|
||||||
|
file_path=$(dirname "$2")
|
||||||
|
mkdir -p "$file_path"
|
||||||
|
cd "$file_path" || exit
|
||||||
|
curl -sSo "$2" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
all) _autoinstall_all ;;
|
||||||
|
git) _autoinstall_git "$2" "$3" ;;
|
||||||
|
file) _autoinstall_file "$2" "$3" ;;
|
||||||
|
*) echo "'$1' is not valid" ;;
|
||||||
|
esac
|
|
@ -1,30 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
vim_autoload_dir="$HOME/.config/vim/autoload"
|
|
||||||
if [ ! -f "$vim_autoload_dir/plug.vim" ]
|
|
||||||
then
|
|
||||||
mkdir -p "$vim_autoload_dir"
|
|
||||||
cd "$vim_autoload_dir" || exit
|
|
||||||
curl -o "plug.vim" "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
|
||||||
[ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term
|
|
||||||
fi
|
|
||||||
|
|
||||||
nvim_dir="$HOME/.config/nvim"
|
|
||||||
if [ ! -d "$nvim_dir" ]
|
|
||||||
then
|
|
||||||
git clone https://github.com/AstroNvim/AstroNvim "$nvim_dir"
|
|
||||||
[ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$(command -v starship)" ]
|
|
||||||
then
|
|
||||||
mkdir -p "$HOME/.local/bin"
|
|
||||||
curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "$(command -v envsubst)" ]
|
|
||||||
then
|
|
||||||
wakatime_cfg="$WAKATIME_HOME/.wakatime.cfg"
|
|
||||||
wakatime_tpl="$wakatime_cfg.tpl"
|
|
||||||
envsubst < "$wakatime_tpl" > "$wakatime_cfg"
|
|
||||||
fi
|
|
107
.bin/git-fire
107
.bin/git-fire
|
@ -1,107 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# The MIT License (MIT)
|
|
||||||
|
|
||||||
# Copyright (c) 2015 - 2019 Nimit Kalra <nimit@utexas.edu>
|
|
||||||
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# Of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# In the Software without restriction, including without limitation the rights
|
|
||||||
# To use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# Copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# Furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
|
||||||
# Copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
# SOFTWARE.
|
|
||||||
|
|
||||||
# Setup.
|
|
||||||
VERSION="0.2.3"
|
|
||||||
|
|
||||||
version() {
|
|
||||||
printf "git-fire version %s\n" "$VERSION"
|
|
||||||
|
|
||||||
git --version
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helpers.
|
|
||||||
current_branch() {
|
|
||||||
basename "$(git symbolic-ref HEAD)"
|
|
||||||
}
|
|
||||||
|
|
||||||
current_epoch() {
|
|
||||||
date +%s
|
|
||||||
}
|
|
||||||
|
|
||||||
user_email() {
|
|
||||||
git config user.email
|
|
||||||
}
|
|
||||||
|
|
||||||
new_branch() {
|
|
||||||
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
|
|
||||||
}
|
|
||||||
|
|
||||||
fire() {
|
|
||||||
initial_branch="$(current_branch)"
|
|
||||||
|
|
||||||
git checkout -b "$(new_branch)"
|
|
||||||
|
|
||||||
# cd to git root directory
|
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
git add -A
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
message="Fire! Branch $(current_branch)."
|
|
||||||
else
|
|
||||||
message="$*"
|
|
||||||
fi
|
|
||||||
|
|
||||||
git commit -m "$message" --no-verify
|
|
||||||
|
|
||||||
for remote in $(git remote); do
|
|
||||||
git push --no-verify --set-upstream "${remote}" "$(current_branch)" || true
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$(git stash list)" != '' ]; then
|
|
||||||
for sha in $(git rev-list -g stash); do
|
|
||||||
git push --no-verify origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n\nLeave building!\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
display_help() {
|
|
||||||
cat <<-EOF
|
|
||||||
|
|
||||||
usage:
|
|
||||||
git fire [options] [COMMAND] [args]
|
|
||||||
|
|
||||||
commands:
|
|
||||||
git fire Add, commit, and push to remote in case of a fire
|
|
||||||
git fire <message> Execute git fire with <message> for commit message
|
|
||||||
|
|
||||||
|
|
||||||
options:
|
|
||||||
-V, --version Output current version of git-fire
|
|
||||||
-h, --help Display this help information
|
|
||||||
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
-V|--version) version; exit 0 ;;
|
|
||||||
-h|--help) display_help; exit 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
fire "$@"
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
base_path="$HOME/.cache/remote-sources"
|
base_path="$HOME/.cache/remote-sources"
|
||||||
mkdir -p "$base_path"
|
mkdir -p "$base_path"
|
||||||
file_path="$base_path/$1"
|
file_path="$base_path/$2"
|
||||||
if [ ! -f "$file_path" ]
|
if [ ! -f "$file_path" ]
|
||||||
then
|
then
|
||||||
echo "Installing file $1"
|
echo "Installing file $2"
|
||||||
curl -Ls -o "$file_path" "$2"
|
curl -Ls -o "$file_path" "$1"
|
||||||
fi
|
fi
|
||||||
source $file_path
|
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "$file_path"
|
||||||
|
|
|
@ -55,6 +55,8 @@ alias sail='bash vendor/bin/sail'
|
||||||
alias sl='ls'
|
alias sl='ls'
|
||||||
alias sudo='sudo '
|
alias sudo='sudo '
|
||||||
|
|
||||||
|
alias tokei='tokei --hidden'
|
||||||
|
|
||||||
alias watch='watch -c'
|
alias watch='watch -c'
|
||||||
alias wget='wget -c'
|
alias wget='wget -c'
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ then
|
||||||
rm "$HOME/.zshrc"
|
rm "$HOME/.zshrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
autoinstall-packages
|
autoinstall all
|
||||||
|
|
||||||
# Set name of the theme to load --- if set to "random", it will
|
# Set name of the theme to load --- if set to "random", it will
|
||||||
# load a random theme each time oh-my-zsh is loaded, in which case,
|
# load a random theme each time oh-my-zsh is loaded, in which case,
|
||||||
|
@ -69,15 +69,13 @@ HIST_STAMPS="yyyy-mm-dd"
|
||||||
# Would you like to use another custom folder than $ZSH/custom?
|
# Would you like to use another custom folder than $ZSH/custom?
|
||||||
ZSH_CUSTOM=$ZDOTDIR/custom
|
ZSH_CUSTOM=$ZDOTDIR/custom
|
||||||
|
|
||||||
function omz_install_custom_plugin() {
|
plugin_path="$ZSH_CUSTOM/plugins"
|
||||||
plugin_path="$ZSH_CUSTOM/plugins/$1"
|
autoinstall git \
|
||||||
if [ ! -d "$plugin_path" ]
|
"https://github.com/zsh-users/zsh-syntax-highlighting.git" \
|
||||||
then
|
"$plugin_path/zsh-syntax-highlighting"
|
||||||
echo "Installing plugin $1"
|
autoinstall file \
|
||||||
git clone "$2" "$plugin_path" >/dev/null 2>&1
|
"https://gist.githubusercontent.com/oshybystyi/475ee7768efc03727f21/raw/4bfd57ef277f5166f3070f11800548b95a501a19/git-auto-status.plugin.zsh" \
|
||||||
fi
|
"$plugin_path/git-auto-status/git-auto-status.plugin.zsh"
|
||||||
}
|
|
||||||
omz_install_custom_plugin "zsh-syntax-highlighting" "https://github.com/zsh-users/zsh-syntax-highlighting.git"
|
|
||||||
|
|
||||||
|
|
||||||
# Which plugins would you like to load?
|
# Which plugins would you like to load?
|
||||||
|
@ -120,6 +118,8 @@ export SAVEHIST=1000000
|
||||||
export HISTSIZE=1000000
|
export HISTSIZE=1000000
|
||||||
export HISTFILE="$HOME/.cache/zsh_history"
|
export HISTFILE="$HOME/.cache/zsh_history"
|
||||||
|
|
||||||
source source-remote-file "dracula-syntax-highlighting" "https://raw.githubusercontent.com/dracula/zsh-syntax-highlighting/master/zsh-syntax-highlighting.sh"
|
source source-remote-file \
|
||||||
|
"https://raw.githubusercontent.com/dracula/zsh-syntax-highlighting/master/zsh-syntax-highlighting.sh" \
|
||||||
|
"dracula-syntax-highlighting"
|
||||||
|
|
||||||
[ -x "$(command -v starship)" ] && eval "$(starship init zsh)"
|
[ -x "$(command -v starship)" ] && eval "$(starship init zsh)"
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#
|
|
||||||
# Run git status after specified set of command
|
|
||||||
#
|
|
||||||
# @author Oleksandr Shybystyi oleksandr.shybystyi@gmail.com
|
|
||||||
#
|
|
||||||
|
|
||||||
# default list of git commands `git status` is running after
|
|
||||||
gitPreAutoStatusCommands=(
|
|
||||||
'add'
|
|
||||||
'rm'
|
|
||||||
'reset'
|
|
||||||
'commit'
|
|
||||||
'checkout'
|
|
||||||
'mv'
|
|
||||||
'init'
|
|
||||||
)
|
|
||||||
|
|
||||||
# taken from http://stackoverflow.com/a/8574392/4647743
|
|
||||||
function elementInArray() {
|
|
||||||
local e
|
|
||||||
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function git() {
|
|
||||||
command git $@
|
|
||||||
|
|
||||||
if (elementInArray $1 $gitPreAutoStatusCommands); then
|
|
||||||
command git status
|
|
||||||
fi
|
|
||||||
}
|
|
Loading…
Reference in a new issue