parallel/src/parset

139 lines
4.4 KiB
Plaintext
Raw Normal View History

2018-02-22 19:43:33 +00:00
#!/usr/bin/env bash
# Copyright (C) 2016-2022 Ole Tange, http://ole.tange.dk and Free
# Software Foundation, Inc.
2018-02-22 19:43:33 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin St,
# Fifth Floor, Boston, MA 02110-1301 USA
#
# SPDX-FileCopyrightText: 2021-2022 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
# SPDX-License-Identifier: GPL-3.0-or-later
2018-02-22 19:43:33 +00:00
grepq() {
# grep -q for systems without -q
grep >/dev/null 2>/dev/null "$@"
}
installer() {
source="$1"
script="$2"
into="$3"
if grepq $script $into; then
true already installed
else
echo $source \`which $script\` >> $into
fi
}
while test $# -gt 0; do
key="$1"
case $key in
-i|--install)
installer . env_parallel.bash $HOME/.bashrc
installer . env_parallel.sh $HOME/.shrc
installer . env_parallel.zsh $HOME/.zshenv
installer source env_parallel.ksh $HOME/.kshrc
2018-07-13 05:33:11 +00:00
installer source env_parallel.mksh $HOME/.kshrc
2018-02-22 19:43:33 +00:00
echo $SHELL | grepq /pdksh &&
installer . env_parallel.pdksh $HOME/.profile
echo $SHELL | grepq /ash &&
installer . env_parallel.ash $HOME/.profile
echo $SHELL | grepq /dash &&
installer . env_parallel.dash $HOME/.profile
installer source env_parallel.csh $HOME/.cshrc
installer source env_parallel.tcsh $HOME/.tcshrc
mkdir -p $HOME/.config/fish
grepq env_parallel.fish $HOME/.config/fish/config.fish ||
echo '. (which env_parallel.fish)' >> $HOME/.config/fish/config.fish
echo 'Installed env_parallel in:'
echo " " $HOME/.bashrc
echo " " $HOME/.shrc
echo " " $HOME/.zshenv
echo " " $HOME/.config/fish/config.fish
echo " " $HOME/.kshrc
2018-07-13 05:33:11 +00:00
echo " " $HOME/.mkshrc
2018-02-22 19:43:33 +00:00
echo " " $HOME/.profile
echo " " $HOME/.cshrc
echo " " $HOME/.tcshrc
exit
;;
*)
echo "Unknown option: $key"
;;
esac
shift # past argument or value
done
cat <<'_EOS'
2022-05-13 23:27:17 +00:00
2018-02-22 19:43:33 +00:00
parset only works if it is a function. The function is defined as part
of env_parallel.
Do the below and restart your shell.
bash: Put this in $HOME/.bashrc: . `which env_parallel.bash`
E.g. by doing: echo '. `which env_parallel.bash`' >> $HOME/.bashrc
2021-06-22 17:40:07 +00:00
Supports: variables, aliases, functions, arrays
2018-02-22 19:43:33 +00:00
ksh: Put this in $HOME/.kshrc: source `which env_parallel.ksh`
E.g. by doing: echo 'source `which env_parallel.ksh`' >> $HOME/.kshrc
2021-06-22 17:40:07 +00:00
Supports: variables, aliases, functions, arrays
2018-02-22 19:43:33 +00:00
2018-07-13 05:33:11 +00:00
mksh: Put this in $HOME/.mkshrc: source `which env_parallel.mksh`
E.g. by doing: echo 'source `which env_parallel.mksh`' >> $HOME/.mkshrc
2021-06-22 17:40:07 +00:00
Supports: variables, aliases, functions, arrays
2018-07-13 05:33:11 +00:00
2018-02-22 19:43:33 +00:00
pdksh: Put this in $HOME/.profile: source `which env_parallel.pdksh`
E.g. by doing: echo '. `which env_parallel.pdksh`' >> $HOME/.profile
2021-06-22 17:40:07 +00:00
Supports: variables, aliases, functions, arrays
zsh: Put this in $HOME/.zshrc: . `which env_parallel.zsh`
E.g. by doing: echo '. `which env_parallel.zsh`' >> $HOME/.zshenv
Supports: variables, functions, arrays
2018-02-22 19:43:33 +00:00
ash: Put this in $HOME/.profile: . `which env_parallel.ash`
E.g. by doing: echo '. `which env_parallel.ash`' >> $HOME/.profile
2021-06-22 17:40:07 +00:00
Supports: variables, aliases
2018-02-22 19:43:33 +00:00
dash: Put this in $HOME/.profile: . `which env_parallel.dash`
E.g. by doing: echo '. `which env_parallel.dash`' >> $HOME/.profile
2021-06-22 17:40:07 +00:00
Supports: variables, aliases
fish: Unsupported
2018-02-22 19:43:33 +00:00
csh: Unsupported
tcsh: Unsupported
To install in all shells run:
parset --install
2022-05-13 23:27:17 +00:00
In a script you need to run this before using parset:
bash: . `which env_parallel.bash`
ksh: source `which env_parallel.ksh`
mksh: source `which env_parallel.mksh`
pdksh: source `which env_parallel.pdksh`
zsh: . `which env_parallel.zsh`
ash: . `which env_parallel.ash`
dash: . `which env_parallel.dash`
2018-02-22 19:43:33 +00:00
For details: see man parset
_EOS