From 8c466f593d0db30a946ef6f6531fe1b66d7705c8 Mon Sep 17 00:00:00 2001 From: cyteen Date: Sun, 13 Dec 2020 16:15:44 +0000 Subject: [PATCH] Add variable for the zsh alias directory and set it to .zshrc.d. --- 020_free42.sh | 6 +- 020_free42_from_dsc.sh | 5 +- 020_grc.sh | 3 +- 020_mutt-wizard.sh | 6 +- 020_neovim-coc.sh | 212 +++++++++++++++++++++-------------------- 020_tldr-broken.sh | 6 +- 020_vifm.sh | 3 +- 020_zsh-system.sh | 3 +- 020_zsh.sh | 75 ++++++++------- 020_zsh_aliases.d.sh | 21 ++-- 020_zsh_quickstart.sh | 19 ++-- 11 files changed, 189 insertions(+), 170 deletions(-) diff --git a/020_free42.sh b/020_free42.sh index 3a408e9..281451b 100755 --- a/020_free42.sh +++ b/020_free42.sh @@ -324,8 +324,10 @@ if [ -f ~/.aliases ]; then fi EOF -mkdir -p ${DEST}/.zsh_aliases.d -echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/.zsh_aliases.d/003_free42.zsh +ALIAS_DIR=".zshrc.d" + +mkdir -p ${DEST}/${ALIAS_DIR} +echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/${ALIAS_DIR}/003_free42.zsh cd /usr/src diff --git a/020_free42_from_dsc.sh b/020_free42_from_dsc.sh index 9f90247..2e41b02 100755 --- a/020_free42_from_dsc.sh +++ b/020_free42_from_dsc.sh @@ -10,8 +10,9 @@ DSC_FILE="http://deb.debian.org/debian/pool/main/f/free42-nologo/free42-nologo_1 DEST=${1:-/etc/skel} # Set and alias -mkdir -p ${DEST}/zsh_aliases.d -echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/.zsh_aliases.d/003_free42.zsh +ALIAS_DIR=".zshrc.d" +mkdir -p ${DEST}/${ALIAS_DIR} +echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/${ALIAS_DIR}/003_free42.zsh mkdir -p ${DEST}/.free42/ diff --git a/020_grc.sh b/020_grc.sh index 9f17212..159fe51 100755 --- a/020_grc.sh +++ b/020_grc.sh @@ -2,7 +2,8 @@ apt install -y grc DEST=${1:-/etc/skel} -ALIAS_HOME=${DEST}/.zsh_aliases.d/ +ALIAS_DIR=".zshrc.d" +ALIAS_HOME=${DEST}/${ALIAS_DIR}/ ALIAS_FILE=${ALIAS_HOME}/003_grc.sh mkdir -p ${ALIAS_HOME} diff --git a/020_mutt-wizard.sh b/020_mutt-wizard.sh index 5303140..4db5c2a 100755 --- a/020_mutt-wizard.sh +++ b/020_mutt-wizard.sh @@ -81,7 +81,7 @@ RELEASE=git ## Create directories and configuration files # '$ mw add' and follow the prompts. - +ALIAS_DIR=".zshrc.d" BUILD_DIR=/var/tmp/build_mutt-wizard MUTTWIZARDCONF="/usr/local/share/mutt-wizard" #MUTTDIR="$HOME/.config/mutt" @@ -251,8 +251,8 @@ mkdir -p ${EXAMPLES}/accounts mkdir -p ${EXAMPLES}/fonts #--------------------------------------------------------------------------------- -mkdir -p ${BUILD_DIR}/skel/.zsh_aliases.d/ -echo 'alias mutt="neomutt "' >> ${BUILD_DIR}/skel/.zsh_aliases.d/002_neomutt.zsh +mkdir -p ${BUILD_DIR}/skel/${ALIAS_DIR}/ +echo 'alias mutt="neomutt "' >> ${BUILD_DIR}/skel/${ALIAS_DIR}/002_neomutt.zsh #--------------------------------------------------------------------------------- ## git clone https://github.com/sheoak/neomutt-powerline-nerdfonts.git diff --git a/020_neovim-coc.sh b/020_neovim-coc.sh index 665c17e..8ee24d4 100644 --- a/020_neovim-coc.sh +++ b/020_neovim-coc.sh @@ -15,117 +15,123 @@ DEST=/etc/skel NEOVIM_HOME=${DEST}/.config/neovim LANGSERVER_CONF=${NEOVIM_HOME}/coc-settings.json - +declare -A COC_OPT # FIXME: Convert the following heredocs to jq -cat > ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${LANGSERVER_CONF} < ${HOME}/.zsh_aliases.d/003_tldr.zsh < ${HOME}/${ALIAS_DIR}/003_tldr.zsh < ${HOME}/.tldrrc <<'EOF' diff --git a/020_vifm.sh b/020_vifm.sh index 38eb1ae..72ad70d 100755 --- a/020_vifm.sh +++ b/020_vifm.sh @@ -3,7 +3,8 @@ mkdir -p ~/.config/vifm/scripts # https://gitlab.com/dwt1/dotfiles/tree/master/.config/vifm/scripts -cat > ~/.zsh_aliases.d/005_vifm.zsh << 'EOF' +ALIAS_DIR=".zshrc.d" +cat > ~/${ALIAS_DIR}/005_vifm.zsh << 'EOF' alias vifm="~/.config/vifm/scripts/vifmrun" EOF diff --git a/020_zsh-system.sh b/020_zsh-system.sh index 17df83b..1650862 100755 --- a/020_zsh-system.sh +++ b/020_zsh-system.sh @@ -2,6 +2,7 @@ # Run 020_zsh.sh to populate the files needed for /etc/skel # assuming default user ZSH_USER=default +ALIAS_DIR=".zshrc.d" sed -i 's,^\(DSHELL=\).*,\1'/bin/zsh',' /etc/adduser.conf #sed -i 's,^\(SHELL=\).*,\1'/bin/zsh',' /etc/default/useradd @@ -13,7 +14,7 @@ cp -a /home/${ZSH_USER}/.zshrc /etc/skel cp -a /home/${ZSH_USER}/.zshrc.d /etc/skel cp -a /home/${ZSH_USER}/.zsh_functions /etc/skel cp -a /home/${ZSH_USER}/.zsh_aliases /etc/skel -cp -a /home/${ZSH_USER}/.zsh_aliases.d /etc/skel +cp -a /home/${ZSH_USER}/${ALIAS_DIR} /etc/skel #cp -a /home/${ZSH_USER}/.zsh-completitions /etc/skel cp -a /home/${ZSH_USER}/.zgen /etc/skel cp -a /home/${ZSH_USER}/.zgen-setup /etc/skel diff --git a/020_zsh.sh b/020_zsh.sh index e791852..95a7c0e 100755 --- a/020_zsh.sh +++ b/020_zsh.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash echo "Broken, incomplete or untested." exit 1 + +DEST=${1:-/etc/skel} +ALIAS_DIR=".zshrc.d" + ## Completions for Debian 9.0 - may be included in zgen # #sudo bash -c "cat > /etc/apt/sources.list.d/shells:zsh-users:zsh-completions.list" << 'EOF' @@ -22,31 +26,31 @@ set -x mkdir -p /usr/local/share/zsh/site-functions chmod g-w /usr/local/share/zsh/site-functions -cd ~ || exit +cd ${DEST} || exit chsh -s "$(which zsh)" "${USER}" apt install -y git # Install zgen plugin manager and zsh quicktart to get a default setup for zsh git clone http://github.com/tarjoilija/zgen # available with apt install zgen which installs to /usr/share/zgen #git clone http://github.com/unixorn/zsh-quickstart-kit # FIXME: needs to be packaged -mkdir -p ~/.zgen/robbyrussell/ -git clone http://github.com/ohmyzsh/ohmyzsh ~/.zgen/robbyrussell/ohmyzsh +mkdir -p ${DEST}/.zgen/robbyrussell/ +git clone http://github.com/ohmyzsh/ohmyzsh ${DEST}/.zgen/robbyrussell/ohmyzsh -#ln -sfr ~/zsh-quickstart-kit/zsh/.zshrc ~/.zshrc -#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_functions ~/.zsh_functions -#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_aliases ~/.zsh_aliases -#ln -sfr ~/zsh-quickstart-kit/zsh/.zgen-setup ~/.zgen-setup -#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_completions ~/.zsh-completions -mkdir -p ~/.zshrc.d -echo "setopt PROMPT_SUBST" >> ~/.zshrc +#ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zshrc ${DEST}/.zshrc +#ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_functions ${DEST}/.zsh_functions +#ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_aliases ${DEST}/.zsh_aliases +#ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zgen-setup ${DEST}/.zgen-setup +#ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_completions ${DEST}/.zsh-completions +mkdir -p ${DEST}/.zshrc.d +echo "setopt PROMPT_SUBST" >> ${DEST}/.zshrc -echo "NVIM_PYTHON_LOG_FILE=/var/tmp/nvim_python.log" >> ~/.zshrc.d/008_nvim.zsh -echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> ~/.zshrc.d/008_nvim.zsh +echo "NVIM_PYTHON_LOG_FILE=/var/tmp/nvim_python.log" >> ${DEST}/.zshrc.d/008_nvim.zsh +echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> ${DEST}/.zshrc.d/008_nvim.zsh touch /var/tmp/nvim_python.log # Fix for using urls on the commandline -cat >> ~/.zshrc.d/005_url-quote-magic.zsh <> ${DEST}/.zshrc.d/005_url-quote-magic.zsh < ~/.zshrc.d/005-locatedb.zsh +# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ${DEST}/.zshrc +echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" > ${DEST}/.zshrc.d/005-locatedb.zsh -# add plugins to the load-starter-plugin-list() function in ~/.zgen-setup ~/zsh-quickstart-kit/zsh/.zgen-setup +# add plugins to the load-starter-plugin-list() function in ${DEST}/.zgen-setup ${DEST}/zsh-quickstart-kit/zsh/.zgen-setup # FIXED: create a file named .zgen-local-plugins and add your zgen load commands there. # Don't forget to run `zgen save` at the end of your .zgen-local-plugins file. # Warning: .zgen-local-plugins REPLACES the starter list setup, it doesn't add to it. -#sed -i -e "s|zgen load srijanshetty/docker-zsh|# zgen load srijanshetty/docker-zsh|" ~/zsh-quickstart-kit/zsh/.zgen-setup -#sed -i '/\# zgen load srijanshetty\/docker-zsh/a\ \ zgen load oh-my-zsh plugins\/docker\n\ \ zgen load oh-my-zsh plugins\/docker-compose' ~/zsh-quickstart-kit/zsh/.zgen-setup +#sed -i -e "s|zgen load srijanshetty/docker-zsh|# zgen load srijanshetty/docker-zsh|" ${DEST}/zsh-quickstart-kit/zsh/.zgen-setup +#sed -i '/\# zgen load srijanshetty\/docker-zsh/a\ \ zgen load oh-my-zsh plugins\/docker\n\ \ zgen load oh-my-zsh plugins\/docker-compose' ${DEST}/zsh-quickstart-kit/zsh/.zgen-setup # The contents of the starter plugin function with changes above, pulling from upstream git with now not squash local changes. -cat > ~/.zgen-local-plugins << 'EOF' +cat > ${DEST}/.zgen-local-plugins << 'EOF' echo "creating a zgen save" ZGEN_LOADED=() ZGEN_COMPLETIONS=() @@ -210,43 +214,42 @@ cat > ~/.zgen-local-plugins << 'EOF' EOF # example .d file use unset to prevent update -#echo '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ~/.zshrc.d/001-quickstart_refresh.zsh -#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ~/.zshrc.d/001-quickstart_refresh.zsh -echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ~/.zshrc.d/001_zgen-refresh.zsh +#echo '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ${DEST}/.zshrc.d/001-quickstart_refresh.zsh +#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ${DEST}/.zshrc.d/001-quickstart_refresh.zsh +echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ${DEST}/.zshrc.d/001_zgen-refresh.zsh apt install -y fonts-powerline powerline -# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ~/.zshrc +# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ${DEST}/.zshrc # Use powerline-daemon to speedup the prompt. -echo 'powerline-daemon -q' > ~/.zshrc.d/006_powerline-daemon.zsh +echo 'powerline-daemon -q' > ${DEST}/.zshrc.d/006_powerline-daemon.zsh sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup # set theme for zsh -cat > ~/.zshrc.d/002_theme.zsh << 'EOF' +cat > ${DEST}/.zshrc.d/002_theme.zsh << 'EOF' # https://zshthem.es/browse-zsh-themes/ ZSH_THEME="agnoster" # powerline based theme #ZSH_THEME="3den" #ZSH_THEME="Pure" EOF -cat > ~/.zshrc.d/001_vi-mode.sh << 'EOF' +cat > ${DEST}/.zshrc.d/001_vi-mode.sh << 'EOF' # Set vi mode bindkey -v bindkey '^R' history-incremental-search-backward EOF - -#git clone https://github.com/bhilburn/powerlevel9k.git ~/.zgen/robbyrussell/oh-my-zsh-master/themes/powerlevel9k +#git clone https://github.com/bhilburn/powerlevel9k.git ${DEST}/.zgen/robbyrussell/oh-my-zsh-master/themes/powerlevel9k ## add a separate zsh aliases directory -#echo > ~/.zshrc << 'EOF' +#echo > ${DEST}/.zshrc << 'EOF' ## Make it easy to append your own aliases -## loading all files from .zsh_aliases.d directory -#mkdir -p ~/.zsh_aliases.d -#if [ -n "$(ls ~/.zsh_aliases.d)" ]; then -# for dotfile in ~/.zsh_aliases.d/* +## loading all files from ${ALIAS_DIR} directory +#mkdir -p ${DEST}/${ALIAS_DIR} +#if [ -n "$(ls ${DEST}/${ALIAS_DIR})" ]; then +# for dotfile in ${DEST}/${ALIAS_DIR}/* # do # if [ -r "${dotfile}" ]; then # source "${dotfile}" @@ -258,8 +261,8 @@ EOF # alias python version # tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value. -echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ~/.zsh_aliases.d/002_sudo.zsh -echo 'alias sudo="sudo "' >> ~/.zsh_aliases.d/002_sudo.zsh +echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ${DEST}/${ALIAS_DIR}/002_sudo.zsh +echo 'alias sudo="sudo "' >> ${DEST}/${ALIAS_DIR}/002_sudo.zsh diff --git a/020_zsh_aliases.d.sh b/020_zsh_aliases.d.sh index 8fda0fc..b63b20a 100755 --- a/020_zsh_aliases.d.sh +++ b/020_zsh_aliases.d.sh @@ -1,22 +1,23 @@ #!/usr/bin/env bash DEST=${1:-/etc/skel} -mkdir -p ${DEST}/.zsh_aliases.d +ALIAS_DIR=".zshrc.d" +mkdir -p ${DEST}/${ALIAS_DIR} ALIAS_FILE=${DEST}/.zsh_aliases cat >> ${ALIAS_FILE} <<'EOF' -# Enable .zsh_aliases.d to keep aliases separate from env variables -if [ -d ~/.zsh_aliases.d ]; then - for f (~/.zsh_aliases.d/**/*(N.)) . $f +# Enable ${ALIAS_DIR} to keep aliases separate from env variables +if [ -d ~/${ALIAS_DIR} ]; then + for f (~/${ALIAS_DIR}/**/*(N.)) . $f fi EOF # tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value. -echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ${DEST}/.zsh_aliases.d/002_sudo.zsh -echo 'alias sudo="sudo "' >> ${DEST}/.zsh_aliases.d/002_sudo.zsh +echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ${DEST}/${ALIAS_DIR}/002_sudo.zsh +echo 'alias sudo="sudo "' >> ${DEST}/${ALIAS_DIR}/002_sudo.zsh -cat > ${DEST}/.zsh_aliases.d/003_py-aliases.zsh << 'EOF' +cat > ${DEST}/${ALIAS_DIR}/003_py-aliases.zsh << 'EOF' _py_version() { PY_VERSIONS=(2 3) @@ -54,7 +55,7 @@ alias jupyter="_py_version" EOF -cat > ${DEST}/.zsh_aliases.d/003_transfer.zsh <<'EOF' +cat > ${DEST}/${ALIAS_DIR}/003_transfer.zsh <<'EOF' # # Defines transfer alias and provides easy command line file and folder sharing. # @@ -124,7 +125,7 @@ transfer() { EOF -ALIAS_FILE=${DEST}/.zsh_aliases.d/003_local.sh +ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_local.sh cat > ${ALIAS_FILE} <<'EOF' alias locate='locate --existing --follow --basename --ignore-case' alias wget="wget --content-disposition -c" @@ -140,7 +141,7 @@ alias tsleech='torsocks leech' alias tswget='torsocks wget' EOF -ALIAS_FILE=${DEST}/.zsh_aliases.d/003_lsd.sh +ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_lsd.sh cat > ${ALIAS_FILE} <<'EOF' if [ -x /usr/bin/lsd ]; then alias lsd="/usr/bin/lsd" diff --git a/020_zsh_quickstart.sh b/020_zsh_quickstart.sh index 16b7f4e..ba81828 100755 --- a/020_zsh_quickstart.sh +++ b/020_zsh_quickstart.sh @@ -26,6 +26,7 @@ chsh -s "$(which zsh)" "${USER}" #DEST=$HOME DEST=${1:-/etc/skel} HOME=${DEST} +ALIAS_DIR=".zshrc.d" apt install -y git # Install zgen plugin manager and zsh quicktart to get a default setup for zsh @@ -240,10 +241,10 @@ EOF ## add a separate zsh aliases directory #echo > ${DEST}/.zshrc << 'EOF' ## Make it easy to append your own aliases -## loading all files from .zsh_aliases.d directory -#mkdir -p ~/.zsh_aliases.d -#if [ -n "$(ls ~/.zsh_aliases.d)" ]; then -# for dotfile in ~/.zsh_aliases.d/* +## loading all files from ${ALIAS_DIR} directory +#mkdir -p ~/${ALIAS_DIR} +#if [ -n "$(ls ~/${ALIAS_DIR})" ]; then +# for dotfile in ~/${ALIAS_DIR}/* # do # if [ -r "${dotfile}" ]; then # source "${dotfile}" @@ -253,13 +254,13 @@ EOF #EOF # alias python version -mkdir -p ${DEST}/.zsh_aliases.d +mkdir -p ${DEST}/${ALIAS_DIR} # tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value. -echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ${DEST}/.zsh_aliases.d/002_sudo.zsh -echo 'alias sudo="sudo "' >> ${DEST}/.zsh_aliases.d/002_sudo.zsh +echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." > ${DEST}/${ALIAS_DIR}/002_sudo.zsh +echo 'alias sudo="sudo "' >> ${DEST}/${ALIAS_DIR}/002_sudo.zsh -cat > ${DEST}/.zsh_aliases.d/003-py_aliases.zsh << 'EOF' +cat > ${DEST}/${ALIAS_DIR}/003-py_aliases.zsh << 'EOF' _py_version() { PY_VERSIONS=(2 3) @@ -296,7 +297,7 @@ alias ipython="_py_version" alias jupyter="_py_version" EOF -cat > ${DEST}/.zsh_aliases.d/003_transfer.zsh <<'EOF' +cat > ${DEST}/${ALIAS_DIR}/003_transfer.zsh <<'EOF' # # Defines transfer alias and provides easy command line file and folder sharing. #