-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve setup script (avoid redundancies for bash/zsh) (#718)
- Loading branch information
Showing
1 changed file
with
32 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,39 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "${BASH_SOURCE:-$0}")" || exit 255 | ||
echo "Setting up your IDEasy in ${PWD}" | ||
|
||
AUTOCOMPLETION="source ${PWD}/completion" | ||
|
||
if ! grep -q "${AUTOCOMPLETION}" ~/.bashrc; then | ||
echo -e "${AUTOCOMPLETION}" >> ~/.bashrc | ||
fi | ||
if ! grep -q "alias ide=" ~/.bashrc; then | ||
echo -e "alias ide=\"source ${PWD}/bin/ide\"" >> ~/.bashrc | ||
echo -e "ide" >> ~/.bashrc | ||
fi | ||
|
||
if [ "${OSTYPE}" != "cygwin" ] && [ "${OSTYPE}" != "msys" ]; then | ||
if ! grep -q "IDE_ROOT" ~/.bashrc | ||
then | ||
echo -e 'export IDE_ROOT="$(pwd)"' >> ~/.bashrc | ||
fi | ||
|
||
if ! grep -q "IDE_ROOT" ~/.zshrc | ||
then | ||
echo -e 'export IDE_ROOT="$(pwd)"' >> ~/.zshrc | ||
function doSetupInConfigFile() { | ||
local cfg=$1 | ||
if [ ! -f "${cfg}" ]; then | ||
echo "${cfg} not found - skipping." | ||
return | ||
fi | ||
fi | ||
|
||
|
||
if [ -f ~/.zshrc ]; then | ||
if ! grep -q "compinit" ~/.zshrc | ||
then | ||
echo -e 'autoload -Uz compinit\ncompinit' >> ~/.zshrc | ||
if [ "${cfg}" = "~/.zshrc" ]; then | ||
if ! grep -q "compinit" "${cfg}"; then | ||
echo -e 'autoload -Uz compinit\ncompinit' >> "${cfg}" | ||
fi | ||
if ! grep -q "bashcompinit" "${cfg}"; then | ||
echo -e 'autoload bashcompinit\nbashcompinit' >> "${cfg}" | ||
fi | ||
fi | ||
if ! grep -q "bashcompinit" ~/.zshrc | ||
then | ||
echo -e 'autoload bashcompinit\nbashcompinit' >> ~/.zshrc | ||
echo "Configuring IDEasy in ${cfg}." | ||
if ! grep -q "${AUTOCOMPLETION}" "${cfg}"; then | ||
echo -e "${AUTOCOMPLETION}" >> "${cfg}" | ||
fi | ||
if ! grep -q "${AUTOCOMPLETION}" ~/.zshrc | ||
then | ||
echo -e "${AUTOCOMPLETION}" >> ~/.zshrc | ||
if ! grep -q "alias ide=" "${cfg}"; then | ||
echo -e "alias ide=\"source ${PWD}/bin/ide\"" >> "${cfg}" | ||
echo -e "ide" >> "${cfg}" | ||
fi | ||
if ! grep -q "alias ide=" ~/.zshrc; then | ||
echo -e "alias ide=\"source ${PWD}/bin/ide\"" >> ~/.zshrc | ||
echo -e "ide" >> ~/.zshrc | ||
if [ "${OSTYPE}" != "cygwin" ] && [ "${OSTYPE}" != "msys" ]; then | ||
if ! grep -q "IDE_ROOT" "${cfg}" | ||
then | ||
echo -e 'export IDE_ROOT="${PWD}"' >> "${cfg}" | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
cd "$(dirname "${BASH_SOURCE:-$0}")" || exit 255 | ||
echo "Setting up your IDEasy in ${PWD}" | ||
|
||
AUTOCOMPLETION="source ${PWD}/completion" | ||
|
||
doSetupInConfigFile ~/.bashrc | ||
doSetupInConfigFile ~/.zshrc |