Update 'kfg'

This commit is contained in:
2023-05-06 15:03:05 +02:00
parent 41f8cf5699
commit c4fc41e103

136
kfg
View File

@@ -1,22 +1,43 @@
#!/bin/bash
NAME="kfg"
VERSION="0.2"
VERSION="0.3"
HOME_PATH="$HOME"
TMP_PATH="$HOME_PATH/tmp/kamu_install"
CONFIG_PATH="$HOME_PATH/.config"
BINARY_PATH="/usr/bin"
RC_FILE=".zshrc"
ASK="\e[38;5;9m"
INFO="\e[38;5;39m"
ADD="\e[32m\e[1m"
ERROR="\033[0;31m"
ENDCOLOR="\e[0m"
function show_help {
declare -A TOOLS || typeset -A TOOLS
TOOLS[all]="Install everything"
TOOLS[zsh]="Powerful Shell"
TOOLS[tmux]="Terminal Multiplexer - https://github.com/tmux/tmux"
TOOLS[unp]="Perl script to make file archive extraction easier"
TOOLS[bat]="cat replacement with syntax highlighting and git integration - https://github.com/sharkdp/bat"
TOOLS[lsd]="ls replacement with colors, icons, tree-view and more - https://github.com/lsd-rs/lsd"
TOOLS[omp]="Customisable shell prompt renderer - https://github.com/jandedobbeleer/oh-my-pos"
function show_help_name {
echo "$NAME v$VERSION"
echo -e "Usage: $NAME cmd [ opt ]\n"
echo -en "cmd := {
}
function show_help_cmd {
echo -e "cmd := {
${INFO}update${ENDCOLOR} \t\t Update $NAME,
${INFO}install${ENDCOLOR}\t\t Install configs :),
${INFO}version${ENDCOLOR}\t\t Print the version number
}\n"
}
function show_help_opt {
echo -en "opt := {
${INFO}-h${ENDCOLOR} | ${INFO}--help${ENDCOLOR} \t\t Show this help,
${INFO}-y${ENDCOLOR} | ${INFO}--yes${ENDCOLOR} \t\t Skip confirmation questions,
@@ -28,7 +49,13 @@ function show_help {
${INFO}-z${ENDCOLOR} \t\t\t Set shell to zsh,
${INFO}-a${ENDCOLOR} \t\t\t Just install everything
}\n"
}
function show_help {
show_help_name
echo -e "Usage: $NAME <cmd> [ opt ]\n"
show_help_cmd
show_help_opt
exit 2
}
@@ -303,26 +330,42 @@ function update {
exit 0
}
function show_help_install {
show_help_name
echo -e "Usage: $NAME install <program> [ opt ]\n"
echo -e "program := {"
for key in ${!TOOLS[@]}; do
echo -e " ${INFO}${key}${ENDCOLOR}\t\t\t ${TOOLS[$key]}"
done
echo -e "}\n"
show_help_opt
exit 2
}
function install {
init
function p_all {
p_zsh
p_tmux
p_unp
p_bat
p_lsd
p_omp
}
function p_zsh {
# -----------------
# zsh
# -----------------
apt_install zsh
set_shell zsh
# --- TODO --- : Keyboard navigation, Suggestions, ...
#wget -O .zshrc https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
#git clone https://github.com/zsh-users/zsh-autosuggestions "$HOME/.config/zsh/zsh-autosuggestions"
# source ~/.config/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
}
# -----------------
# General Config
# -----------------
init_install_rc "export KHOME=$HOME_PATH"
init_install_rc "export XDG_CONFIG_HOME=$CONFIG_PATH"
install_rc "shell" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.general.rc"
function p_tmux {
# -----------------
# tmux
# -----------------
@@ -333,19 +376,25 @@ function install {
sudo chmod +x ${CONFIG_PATH}/tmux/myip.sh
install_rc tmux https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.tmux.rc
git_clone "https://github.com/tmux-plugins/tpm" "${CONFIG_PATH}/tmux/plugins/tpm"
}
function p_unp {
# -----------------
# unp
# -----------------
apt_install unp
# --- TODO --- : rc file
}
function p_bat {
# -----------------
# bat
# -----------------
install_deb_github bat "sharkdp/bat" "bat_VERSION_ARCH.deb"
install_rc bat https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.bat.rc
}
function p_lsd {
# -----------------
# Install lsd https://github.com/Peltoche/lsd
# -----------------
@@ -353,26 +402,56 @@ function install {
install_rc lsd https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.lsd.rc
download_config lsd "config.yaml" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.lsd.conf"
download_config lsd "themes/kamu.yaml" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.lsd.theme"
}
#wget -O .zshrc https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
function p_omp {
# -----------------
# Install OhMyPosh
# -----------------
download_config "omp" "omp.json" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.omp.json"
install_rc "omp" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.omp.rc"
install_binary_github "oh-my-posh" "JanDeDobbeleer/oh-my-posh" "posh-linux-ARCH"
}
function install {
if [ -z $1 ]; then
show_help_install
fi
#git clone https://github.com/zsh-users/zsh-autosuggestions "$HOME/.config/zsh/zsh-autosuggestions"
# source ~/.config/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
init
P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1; P_ZSH=1
# -----------------
# General Config
# -----------------
init_install_rc "export KHOME=$HOME_PATH"
init_install_rc "export XDG_CONFIG_HOME=$CONFIG_PATH"
install_rc "shell" "https://git.cbeck.tech/kamu/dotfiles/raw/branch/main/.general.rc"
while :
do
case "$1" in
"") break ;;
all) p_all; shift ;;
zsh) p_zsh; shift ;;
bat) p_bat; shift ;;
tmux) p_tmux; shift ;;
unp) p_unp; shift ;;
lsd) p_lsd; shift ;;
omp) p_omp; shift ;;
# If invalid options were passed, then getopt should have reported an error,
# which we checked as VALID_ARGUMENTS when getopt was called...
*) log_error "Unrecognised program: $1"; shift ;;
esac
done
cleanup
exit 0
}
if [ -z $@ ]; then
if [ -z $1 ]; then
show_help
fi
@@ -392,12 +471,11 @@ do
-h | --help) show_help ;;
-v) P_Verbose=1 ; shift ;;
-d | --debug) P_Debug=1 ; shift ;;
-y) P_Yes=1 ; shift ;;
-y | --yes) P_Yes=1 ; shift ;;
-p) P_APT=1; P_DEB=1 ; shift ;;
-c) P_CONFIG=1 ; shift ;;
-r) P_RC=1 ; shift ;;
-b) P_BINARY=1 ; shift ;;
-i) P_Install="$2"; shift 2 ;;
-m | --arch) ARCH="$2" ; shift 2 ;;
-z) P_ZSH=1 ; shift ;;
-a) P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1; P_ZSH=1; shift ;;
@@ -405,28 +483,20 @@ do
--) shift; break ;;
# If invalid options were passed, then getopt should have reported an error,
# which we checked as VALID_ARGUMENTS when getopt was called...
*) echo "Unexpected option: $1"
*) log_error "Unexpected option: $1"
show_help ;;
esac
done
#echo "Parameters remaining are: $@"
HOME_PATH="$HOME"
TMP_PATH="$HOME_PATH/tmp/kamu_install"
CONFIG_PATH="$HOME_PATH/.config"
BINARY_PATH="/usr/bin"
RC_FILE=".zshrc"
case "$1" in
update) update ;;
version) version ;;
install) install; shift ;;
install) shift; install $@;;
# -- means the end of the arguments; drop this, and break out of the while loop
--) shift; break ;;
# If invalid options were passed, then getopt should have reported an error,
# which we checked as VALID_ARGUMENTS when getopt was called...
*) echo "Unexpected option: $1"
*) log_error "Unexpected command: $1"
show_help ;;
esac