Add variable for the zsh alias directory and set it to .zshrc.d.

This commit is contained in:
cyteen 2020-12-13 16:15:44 +00:00
parent b0491d4f1c
commit 8c466f593d
11 changed files with 189 additions and 170 deletions

View File

@ -324,8 +324,10 @@ if [ -f ~/.aliases ]; then
fi fi
EOF EOF
mkdir -p ${DEST}/.zsh_aliases.d ALIAS_DIR=".zshrc.d"
echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/.zsh_aliases.d/003_free42.zsh
mkdir -p ${DEST}/${ALIAS_DIR}
echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/${ALIAS_DIR}/003_free42.zsh
cd /usr/src cd /usr/src

View File

@ -10,8 +10,9 @@ DSC_FILE="http://deb.debian.org/debian/pool/main/f/free42-nologo/free42-nologo_1
DEST=${1:-/etc/skel} DEST=${1:-/etc/skel}
# Set and alias # Set and alias
mkdir -p ${DEST}/zsh_aliases.d ALIAS_DIR=".zshrc.d"
echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/.zsh_aliases.d/003_free42.zsh mkdir -p ${DEST}/${ALIAS_DIR}
echo "alias xcalc=/usr/bin/free42bin" > ${DEST}/${ALIAS_DIR}/003_free42.zsh
mkdir -p ${DEST}/.free42/ mkdir -p ${DEST}/.free42/

View File

@ -2,7 +2,8 @@
apt install -y grc apt install -y grc
DEST=${1:-/etc/skel} 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 ALIAS_FILE=${ALIAS_HOME}/003_grc.sh
mkdir -p ${ALIAS_HOME} mkdir -p ${ALIAS_HOME}

View File

@ -81,7 +81,7 @@ RELEASE=git
## Create directories and configuration files ## Create directories and configuration files
# '$ mw add' and follow the prompts. # '$ mw add' and follow the prompts.
ALIAS_DIR=".zshrc.d"
BUILD_DIR=/var/tmp/build_mutt-wizard BUILD_DIR=/var/tmp/build_mutt-wizard
MUTTWIZARDCONF="/usr/local/share/mutt-wizard" MUTTWIZARDCONF="/usr/local/share/mutt-wizard"
#MUTTDIR="$HOME/.config/mutt" #MUTTDIR="$HOME/.config/mutt"
@ -251,8 +251,8 @@ mkdir -p ${EXAMPLES}/accounts
mkdir -p ${EXAMPLES}/fonts mkdir -p ${EXAMPLES}/fonts
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
mkdir -p ${BUILD_DIR}/skel/.zsh_aliases.d/ mkdir -p ${BUILD_DIR}/skel/${ALIAS_DIR}/
echo 'alias mutt="neomutt "' >> ${BUILD_DIR}/skel/.zsh_aliases.d/002_neomutt.zsh echo 'alias mutt="neomutt "' >> ${BUILD_DIR}/skel/${ALIAS_DIR}/002_neomutt.zsh
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
## git clone https://github.com/sheoak/neomutt-powerline-nerdfonts.git ## git clone https://github.com/sheoak/neomutt-powerline-nerdfonts.git

View File

@ -15,117 +15,123 @@ DEST=/etc/skel
NEOVIM_HOME=${DEST}/.config/neovim NEOVIM_HOME=${DEST}/.config/neovim
LANGSERVER_CONF=${NEOVIM_HOME}/coc-settings.json LANGSERVER_CONF=${NEOVIM_HOME}/coc-settings.json
declare -A COC_OPT
# FIXME: Convert the following heredocs to jq # FIXME: Convert the following heredocs to jq
cat > ${LANGSERVER_CONF} <<EOF #cat > ${LANGSERVER_CONF} <<EOF
"languageserver": { #"languageserver": {
"golang": { # "golang": {
"command": "gopls", # "command": "gopls",
"rootPatterns": ["go.mod"], # "rootPatterns": ["go.mod"],
"filetypes": ["go"] # "filetypes": ["go"]
} # }
} #}
EOF #EOF
COC_OPT[1]='.["languageserver"] = {"golang": {"command": "gopls", "rootPatterns" = ["go.mod"] , "filetypes" = ["go"] }'
## https://github.com/rcjsuen/dockerfile-language-server-nodejs
#cat > ${LANGSERVER_CONF} <<EOF
#"languageserver": {
# "dockerfile": {
# "command": "docker-langserver",
# "filetypes": ["dockerfile"],
# "args": ["--stdio"]
# }
#}
#EOF
COC_OPT[2]='.["languageserver"] = {"dockerfile": {"command": "docker-langserver", "filetypes" = ["dockerfile"], "args" = ["--stdio"] }'
# https://github.com/rcjsuen/dockerfile-language-server-nodejs ## h# https://github.com/palantir/python-language-serverttps://github.com/mads-hartmann/bash-language-server
cat > ${LANGSERVER_CONF} <<EOF #cat > ${LANGSERVER_CONF} <<EOF
"languageserver": { #"languageserver": {
"dockerfile": { # "bash": {
"command": "docker-langserver", # "command": "bash-language-server",
"filetypes": ["dockerfile"], # "args": ["start"],
"args": ["--stdio"] # "filetypes": ["sh"],
} # "ignoredRootPaths": ["~"]
} # }
EOF #}
COC_OPT[3]='.["languageserver"] = {"bash": {"command": "bash-language-server", "filetypes" = ["sh"], "args" = ["start"], "ignoredRootPaths" = ["~"] }'
# h# https://github.com/palantir/python-language-serverttps://github.com/mads-hartmann/bash-language-server
cat > ${LANGSERVER_CONF} <<EOF
"languageserver": {
"bash": {
"command": "bash-language-server",
"args": ["start"],
"filetypes": ["sh"],
"ignoredRootPaths": ["~"]
}
}
## Python ## Python
# https://github.com/palantir/python-language-server # https://github.com/palantir/python-language-server
cat > ${LANGSERVER_CONF} <<EOF #cat > ${LANGSERVER_CONF} <<EOF
"languageserver": { #"languageserver": {
"python": { # "python": {
"command": "python", # "command": "python",
"args": [ # "args": [
"-mpyls", # "-mpyls",
"-vv", # "-vv",
"--log-file", # "--log-file",
"/tmp/lsp_python.log" # "/tmp/lsp_python.log"
], # ],
"trace.server": "verbose", # "trace.server": "verbose",
"filetypes": [ # "filetypes": [
"python" # "python"
], # ],
"settings": { # "settings": {
"pyls": { # "pyls": {
"enable": true, # "enable": true,
"trace": { # "trace": {
"server": "verbose" # "server": "verbose"
}, # },
"commandPath": "", # "commandPath": "",
"configurationSources": [ # "configurationSources": [
"pycodestyle" # "pycodestyle"
], # ],
"plugins": { # "plugins": {
"jedi_completion": { # "jedi_completion": {
"enabled": true # "enabled": true
}, # },
"jedi_hover": { # "jedi_hover": {
"enabled": true # "enabled": true
}, # },
"jedi_references": { # "jedi_references": {
"enabled": true # "enabled": true
}, # },
"jedi_signature_help": { # "jedi_signature_help": {
"enabled": true # "enabled": true
}, # },
"jedi_symbols": { # "jedi_symbols": {
"enabled": true, # "enabled": true,
"all_scopes": true # "all_scopes": true
}, # },
"mccabe": { # "mccabe": {
"enabled": true, # "enabled": true,
"threshold": 15 # "threshold": 15
}, # },
"preload": { # "preload": {
"enabled": true # "enabled": true
}, # },
"pycodestyle": { # "pycodestyle": {
"enabled": true # "enabled": true
}, # },
"pydocstyle": { # "pydocstyle": {
"enabled": false, # "enabled": false,
"match": "(?!test_).*\\.py", # "match": "(?!test_).*\\.py",
"matchDir": "[^\\.].*" # "matchDir": "[^\\.].*"
}, # },
"pyflakes": { # "pyflakes": {
"enabled": true # "enabled": true
}, # },
"rope_completion": { # "rope_completion": {
"enabled": true # "enabled": true
}, # },
"yapf": { # "yapf": {
"enabled": true # "enabled": true
} # }
} # }
} # }
} # }
} # }
} #}
EOF #EOF
COC_OPT[4]='.["languageserver"] = {"python": {"command": "python", "filetypes" = ["py"], "args" = ["-mpyls", "-vv", "--log-file", "/tmp/lsp_python.log"], "ignoredRootPaths" = ["~"] }'
pip install -U setuptools pip install -U setuptools
pip install 'python-language-server[all]' pip install 'python-language-server[all]'

View File

@ -2,15 +2,17 @@
sudo apt -y install tldr-py fzf sudo apt -y install tldr-py fzf
TLDR_CONFIG_DIR=${HOME}/.tldr TLDR_CONFIG_DIR=${HOME}/.tldr
#mkdir -p ${TLDR_CONFIG_DIR} ALIAS_DIR=".zshrc.d"
mkdir -p ${TLDR_CONFIG_DIR}
cd ${HOME} cd ${HOME}
git clone https://github.com/tldr-pages/tldr.git .tldr git clone https://github.com/tldr-pages/tldr.git .tldr
cat > ${HOME}/.zsh_aliases.d/003_tldr.zsh <<EOF cat > ${HOME}/${ALIAS_DIR}/003_tldr.zsh <<EOF
if [ -x /usr/bin/tldr ]; then if [ -x /usr/bin/tldr ]; then
alias howto="tldr find" alias howto="tldr find"
alias fhowto="tldr list | fzf | xargs -I{} tldr find {}" alias fhowto="tldr list | fzf | xargs -I{} tldr find {}"
fi
EOF EOF
cat > ${HOME}/.tldrrc <<'EOF' cat > ${HOME}/.tldrrc <<'EOF'

View File

@ -3,7 +3,8 @@ mkdir -p ~/.config/vifm/scripts
# https://gitlab.com/dwt1/dotfiles/tree/master/.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" alias vifm="~/.config/vifm/scripts/vifmrun"
EOF EOF

View File

@ -2,6 +2,7 @@
# Run 020_zsh.sh to populate the files needed for /etc/skel # Run 020_zsh.sh to populate the files needed for /etc/skel
# assuming default user # assuming default user
ZSH_USER=default ZSH_USER=default
ALIAS_DIR=".zshrc.d"
sed -i 's,^\(DSHELL=\).*,\1'/bin/zsh',' /etc/adduser.conf sed -i 's,^\(DSHELL=\).*,\1'/bin/zsh',' /etc/adduser.conf
#sed -i 's,^\(SHELL=\).*,\1'/bin/zsh',' /etc/default/useradd #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}/.zshrc.d /etc/skel
cp -a /home/${ZSH_USER}/.zsh_functions /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 /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}/.zsh-completitions /etc/skel
cp -a /home/${ZSH_USER}/.zgen /etc/skel cp -a /home/${ZSH_USER}/.zgen /etc/skel
cp -a /home/${ZSH_USER}/.zgen-setup /etc/skel cp -a /home/${ZSH_USER}/.zgen-setup /etc/skel

View File

@ -1,6 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Broken, incomplete or untested." echo "Broken, incomplete or untested."
exit 1 exit 1
DEST=${1:-/etc/skel}
ALIAS_DIR=".zshrc.d"
## Completions for Debian 9.0 - may be included in zgen ## 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' #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 mkdir -p /usr/local/share/zsh/site-functions
chmod g-w /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}" chsh -s "$(which zsh)" "${USER}"
apt install -y git apt install -y git
# Install zgen plugin manager and zsh quicktart to get a default setup for zsh # 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/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 #git clone http://github.com/unixorn/zsh-quickstart-kit # FIXME: needs to be packaged
mkdir -p ~/.zgen/robbyrussell/ mkdir -p ${DEST}/.zgen/robbyrussell/
git clone http://github.com/ohmyzsh/ohmyzsh ~/.zgen/robbyrussell/ohmyzsh git clone http://github.com/ohmyzsh/ohmyzsh ${DEST}/.zgen/robbyrussell/ohmyzsh
#ln -sfr ~/zsh-quickstart-kit/zsh/.zshrc ~/.zshrc #ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zshrc ${DEST}/.zshrc
#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_functions ~/.zsh_functions #ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_functions ${DEST}/.zsh_functions
#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_aliases ~/.zsh_aliases #ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_aliases ${DEST}/.zsh_aliases
#ln -sfr ~/zsh-quickstart-kit/zsh/.zgen-setup ~/.zgen-setup #ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zgen-setup ${DEST}/.zgen-setup
#ln -sfr ~/zsh-quickstart-kit/zsh/.zsh_completions ~/.zsh-completions #ln -sfr ${DEST}/zsh-quickstart-kit/zsh/.zsh_completions ${DEST}/.zsh-completions
mkdir -p ~/.zshrc.d mkdir -p ${DEST}/.zshrc.d
echo "setopt PROMPT_SUBST" >> ~/.zshrc 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_FILE=/var/tmp/nvim_python.log" >> ${DEST}/.zshrc.d/008_nvim.zsh
echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> ~/.zshrc.d/008_nvim.zsh echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >> ${DEST}/.zshrc.d/008_nvim.zsh
touch /var/tmp/nvim_python.log touch /var/tmp/nvim_python.log
# Fix for using urls on the commandline # Fix for using urls on the commandline
cat >> ~/.zshrc.d/005_url-quote-magic.zsh <<EOF cat >> ${DEST}/.zshrc.d/005_url-quote-magic.zsh <<EOF
autoload -U url-quote-magic autoload -U url-quote-magic
zle -N self-insert url-quote-magic zle -N self-insert url-quote-magic
@ -60,21 +64,21 @@ zstyle -e :urlglobber url-other-schema \
EOF EOF
# fix path error in .zshrc # fix path error in .zshrc
#sed -i 's|pushd $(dirname "${HOME}/$(readlink ~/.zshrc)")|pushd $(dirname "$(readlink ~/.zshrc)")|' ~/zsh-quickstart-kit/zsh/.zshrc #sed -i 's|pushd $(dirname "${HOME}/$(readlink ${DEST}/.zshrc)")|pushd $(dirname "$(readlink ${DEST}/.zshrc)")|' ${DEST}/zsh-quickstart-kit/zsh/.zshrc
# debians locate db locate # debians locate db locate
# 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
echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" > ~/.zshrc.d/005-locatedb.zsh 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. # 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. # 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. # 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 -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' ~/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. # 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" echo "creating a zgen save"
ZGEN_LOADED=() ZGEN_LOADED=()
ZGEN_COMPLETIONS=() ZGEN_COMPLETIONS=()
@ -210,43 +214,42 @@ cat > ~/.zgen-local-plugins << 'EOF'
EOF EOF
# example .d file use unset to prevent update # 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 '# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.' > ${DEST}/.zshrc.d/001-quickstart_refresh.zsh
#echo 'QUICKSTART_KIT_REFRESH_IN_DAYS=30' >> ~/.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' > ~/.zshrc.d/001_zgen-refresh.zsh echo 'ZGEN_PLUGIN_UPDATE_DAYS=30' > ${DEST}/.zshrc.d/001_zgen-refresh.zsh
apt install -y fonts-powerline powerline 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. # 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 sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup
# set theme for zsh # 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/ # https://zshthem.es/browse-zsh-themes/
ZSH_THEME="agnoster" # powerline based theme ZSH_THEME="agnoster" # powerline based theme
#ZSH_THEME="3den" #ZSH_THEME="3den"
#ZSH_THEME="Pure" #ZSH_THEME="Pure"
EOF EOF
cat > ~/.zshrc.d/001_vi-mode.sh << 'EOF' cat > ${DEST}/.zshrc.d/001_vi-mode.sh << 'EOF'
# Set vi mode # Set vi mode
bindkey -v bindkey -v
bindkey '^R' history-incremental-search-backward bindkey '^R' history-incremental-search-backward
EOF EOF
#git clone https://github.com/bhilburn/powerlevel9k.git ${DEST}/.zgen/robbyrussell/oh-my-zsh-master/themes/powerlevel9k
#git clone https://github.com/bhilburn/powerlevel9k.git ~/.zgen/robbyrussell/oh-my-zsh-master/themes/powerlevel9k
## add a separate zsh aliases directory ## add a separate zsh aliases directory
#echo > ~/.zshrc << 'EOF' #echo > ${DEST}/.zshrc << 'EOF'
## Make it easy to append your own aliases ## Make it easy to append your own aliases
## loading all files from .zsh_aliases.d directory ## loading all files from ${ALIAS_DIR} directory
#mkdir -p ~/.zsh_aliases.d #mkdir -p ${DEST}/${ALIAS_DIR}
#if [ -n "$(ls ~/.zsh_aliases.d)" ]; then #if [ -n "$(ls ${DEST}/${ALIAS_DIR})" ]; then
# for dotfile in ~/.zsh_aliases.d/* # for dotfile in ${DEST}/${ALIAS_DIR}/*
# do # do
# if [ -r "${dotfile}" ]; then # if [ -r "${dotfile}" ]; then
# source "${dotfile}" # source "${dotfile}"
@ -258,8 +261,8 @@ EOF
# alias python version # 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. # 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 "# 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 "' >> ~/.zsh_aliases.d/002_sudo.zsh echo 'alias sudo="sudo "' >> ${DEST}/${ALIAS_DIR}/002_sudo.zsh

View File

@ -1,22 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DEST=${1:-/etc/skel} DEST=${1:-/etc/skel}
mkdir -p ${DEST}/.zsh_aliases.d ALIAS_DIR=".zshrc.d"
mkdir -p ${DEST}/${ALIAS_DIR}
ALIAS_FILE=${DEST}/.zsh_aliases ALIAS_FILE=${DEST}/.zsh_aliases
cat >> ${ALIAS_FILE} <<'EOF' cat >> ${ALIAS_FILE} <<'EOF'
# Enable .zsh_aliases.d to keep aliases separate from env variables # Enable ${ALIAS_DIR} to keep aliases separate from env variables
if [ -d ~/.zsh_aliases.d ]; then if [ -d ~/${ALIAS_DIR} ]; then
for f (~/.zsh_aliases.d/**/*(N.)) . $f for f (~/${ALIAS_DIR}/**/*(N.)) . $f
fi fi
EOF 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. # 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 "# 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}/.zsh_aliases.d/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_version() {
PY_VERSIONS=(2 3) PY_VERSIONS=(2 3)
@ -54,7 +55,7 @@ alias jupyter="_py_version"
EOF 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. # Defines transfer alias and provides easy command line file and folder sharing.
# #
@ -124,7 +125,7 @@ transfer() {
EOF EOF
ALIAS_FILE=${DEST}/.zsh_aliases.d/003_local.sh ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_local.sh
cat > ${ALIAS_FILE} <<'EOF' cat > ${ALIAS_FILE} <<'EOF'
alias locate='locate --existing --follow --basename --ignore-case' alias locate='locate --existing --follow --basename --ignore-case'
alias wget="wget --content-disposition -c" alias wget="wget --content-disposition -c"
@ -140,7 +141,7 @@ alias tsleech='torsocks leech'
alias tswget='torsocks wget' alias tswget='torsocks wget'
EOF EOF
ALIAS_FILE=${DEST}/.zsh_aliases.d/003_lsd.sh ALIAS_FILE=${DEST}/${ALIAS_DIR}/003_lsd.sh
cat > ${ALIAS_FILE} <<'EOF' cat > ${ALIAS_FILE} <<'EOF'
if [ -x /usr/bin/lsd ]; then if [ -x /usr/bin/lsd ]; then
alias lsd="/usr/bin/lsd" alias lsd="/usr/bin/lsd"

View File

@ -26,6 +26,7 @@ chsh -s "$(which zsh)" "${USER}"
#DEST=$HOME #DEST=$HOME
DEST=${1:-/etc/skel} DEST=${1:-/etc/skel}
HOME=${DEST} HOME=${DEST}
ALIAS_DIR=".zshrc.d"
apt install -y git apt install -y git
# Install zgen plugin manager and zsh quicktart to get a default setup for zsh # 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 ## add a separate zsh aliases directory
#echo > ${DEST}/.zshrc << 'EOF' #echo > ${DEST}/.zshrc << 'EOF'
## Make it easy to append your own aliases ## Make it easy to append your own aliases
## loading all files from .zsh_aliases.d directory ## loading all files from ${ALIAS_DIR} directory
#mkdir -p ~/.zsh_aliases.d #mkdir -p ~/${ALIAS_DIR}
#if [ -n "$(ls ~/.zsh_aliases.d)" ]; then #if [ -n "$(ls ~/${ALIAS_DIR})" ]; then
# for dotfile in ~/.zsh_aliases.d/* # for dotfile in ~/${ALIAS_DIR}/*
# do # do
# if [ -r "${dotfile}" ]; then # if [ -r "${dotfile}" ]; then
# source "${dotfile}" # source "${dotfile}"
@ -253,13 +254,13 @@ EOF
#EOF #EOF
# alias python version # 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. # 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 "# 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}/.zsh_aliases.d/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_version() {
PY_VERSIONS=(2 3) PY_VERSIONS=(2 3)
@ -296,7 +297,7 @@ alias ipython="_py_version"
alias jupyter="_py_version" alias jupyter="_py_version"
EOF 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. # Defines transfer alias and provides easy command line file and folder sharing.
# #