File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22_src_dir=" ${PWD} /src/venv-cli"
33_install_dir=" /usr/local/share/venv"
4+ _source_comment=" # Source function script for 'venv' command"
45
56set -e
67
@@ -18,9 +19,13 @@ install_common() {
1819 sudo cp " ${completion_file} " " ${completion_target} "
1920 fi
2021
21- # Append line to the shell config file to source the script
22- echo -e " \n# Source function script for 'venv' command" >> " ${rcfile} "
23- echo " . ${_install_dir} /venv" >> " ${rcfile} "
22+ # If line does not already exist in the rc file,
23+ # append line to the shell config file to source the venv-cli script
24+ if ! command grep -q " ${_source_comment} " " ${rcfile} " ; then
25+ echo " ${_source_comment} " >> " ${rcfile} "
26+ echo " source ${_install_dir} /venv" >> " ${rcfile} "
27+ fi
28+
2429 { set +x; } 2> /dev/null
2530}
2631
@@ -40,8 +45,10 @@ install_zsh() {
4045 echo " Command completions currently not supported for zsh"
4146
4247 install_common " ${rcfile} "
43- echo " fpath+=( ${_install_dir} )" >> " ${rcfile} "
44- echo " autoload -Uz venv" >> " ${rcfile} "
48+ if ! command grep -q " ${_source_comment} " " ${rcfile} " ; then
49+ echo " fpath+=( ${_install_dir} )" >> " ${rcfile} "
50+ echo " autoload -Uz venv" >> " ${rcfile} "
51+ fi
4552}
4653
4754main () {
You can’t perform that action at this time.
0 commit comments