Released as 20240522 ('Tbilisi')
[parallel.git] / src / parset
blobba865d621187e833cf590a727c97bd8330ee97a9
1 #!/usr/bin/env bash
3 # Copyright (C) 2016-2024 Ole Tange, http://ole.tange.dk and Free
4 # Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>
18 # or write to the Free Software Foundation, Inc., 51 Franklin St,
19 # Fifth Floor, Boston, MA 02110-1301 USA
21 # SPDX-FileCopyrightText: 2021-2024 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
22 # SPDX-License-Identifier: GPL-3.0-or-later
24 grepq() {
25 # grep -q for systems without -q
26 grep >/dev/null 2>/dev/null "$@"
29 installer() {
30 source="$1"
31 script="$2"
32 into="$3"
33 if grepq $script $into; then
34 true already installed
35 else
36 echo $source \`which $script\` >> $into
40 while test $# -gt 0; do
41 key="$1"
43 case $key in
44 -i|--install)
45 installer . env_parallel.bash $HOME/.bashrc
46 installer . env_parallel.sh $HOME/.shrc
47 installer . env_parallel.zsh $HOME/.zshenv
48 installer source env_parallel.ksh $HOME/.kshrc
49 installer source env_parallel.mksh $HOME/.kshrc
50 echo $SHELL | grepq /pdksh &&
51 installer . env_parallel.pdksh $HOME/.profile
52 echo $SHELL | grepq /ash &&
53 installer . env_parallel.ash $HOME/.profile
54 echo $SHELL | grepq /dash &&
55 installer . env_parallel.dash $HOME/.profile
56 installer source env_parallel.csh $HOME/.cshrc
57 installer source env_parallel.tcsh $HOME/.tcshrc
58 mkdir -p $HOME/.config/fish
59 grepq env_parallel.fish $HOME/.config/fish/config.fish ||
60 echo '. (which env_parallel.fish)' >> $HOME/.config/fish/config.fish
61 echo 'Installed env_parallel in:'
62 echo " " $HOME/.bashrc
63 echo " " $HOME/.shrc
64 echo " " $HOME/.zshenv
65 echo " " $HOME/.config/fish/config.fish
66 echo " " $HOME/.kshrc
67 echo " " $HOME/.mkshrc
68 echo " " $HOME/.profile
69 echo " " $HOME/.cshrc
70 echo " " $HOME/.tcshrc
71 exit
74 echo "Unknown option: $key"
76 esac
77 shift # past argument or value
78 done
81 cat <<'_EOS'
83 parset only works if it is a function. The function is defined as part
84 of env_parallel.
86 Do the below and restart your shell.
88 bash: Put this in $HOME/.bashrc: . `which env_parallel.bash`
89 E.g. by doing: echo '. `which env_parallel.bash`' >> $HOME/.bashrc
90 Supports: variables, aliases, functions, arrays
92 ksh: Put this in $HOME/.kshrc: source `which env_parallel.ksh`
93 E.g. by doing: echo 'source `which env_parallel.ksh`' >> $HOME/.kshrc
94 Supports: variables, aliases, functions, arrays
96 mksh: Put this in $HOME/.mkshrc: source `which env_parallel.mksh`
97 E.g. by doing: echo 'source `which env_parallel.mksh`' >> $HOME/.mkshrc
98 Supports: variables, aliases, functions, arrays
100 pdksh: Put this in $HOME/.profile: source `which env_parallel.pdksh`
101 E.g. by doing: echo '. `which env_parallel.pdksh`' >> $HOME/.profile
102 Supports: variables, aliases, functions, arrays
104 zsh: Put this in $HOME/.zshrc: . `which env_parallel.zsh`
105 E.g. by doing: echo '. `which env_parallel.zsh`' >> $HOME/.zshenv
106 Supports: variables, functions, arrays
108 ash: Put this in $HOME/.profile: . `which env_parallel.ash`
109 E.g. by doing: echo '. `which env_parallel.ash`' >> $HOME/.profile
110 Supports: variables, aliases
112 dash: Put this in $HOME/.profile: . `which env_parallel.dash`
113 E.g. by doing: echo '. `which env_parallel.dash`' >> $HOME/.profile
114 Supports: variables, aliases
116 fish: Unsupported
118 csh: Unsupported
120 tcsh: Unsupported
122 To install in all shells run:
124 parset --install
126 In a script you need to run this before using parset:
128 bash: . `which env_parallel.bash`
129 ksh: source `which env_parallel.ksh`
130 mksh: source `which env_parallel.mksh`
131 pdksh: source `which env_parallel.pdksh`
132 zsh: . `which env_parallel.zsh`
133 ash: . `which env_parallel.ash`
134 dash: . `which env_parallel.dash`
136 For details: see man parset
138 _EOS