@@ -31,7 +31,7 @@ function main() {
3131 rm -rf $cortex_sh_tmp_dir && mkdir -p $cortex_sh_tmp_dir
3232
3333 if command -v curl > /dev/null; then
34- curl -s -o $cortex_sh_tmp_dir /cortex https://s3-us-west-2.amazonaws.com/get-cortex/$CORTEX_VERSION_BRANCH_STABLE /cli/$parsed_os /cortex
34+ curl -s -w " " - o $cortex_sh_tmp_dir /cortex https://s3-us-west-2.amazonaws.com/get-cortex/$CORTEX_VERSION_BRANCH_STABLE /cli/$parsed_os /cortex
3535 elif command -v wget > /dev/null; then
3636 wget -q -O $cortex_sh_tmp_dir /cortex https://s3-us-west-2.amazonaws.com/get-cortex/$CORTEX_VERSION_BRANCH_STABLE /cli/$parsed_os /cortex
3737 else
@@ -82,6 +82,15 @@ function get_bash_profile_path() {
8282 echo " "
8383}
8484
85+ function get_zsh_profile_path() {
86+ if [ -f $HOME /.zshrc ]; then
87+ echo $HOME /.zshrc
88+ return
89+ fi
90+
91+ echo " "
92+ }
93+
8594function guess_if_bash_completion_installed() {
8695 if [ -f $HOME /.bash_profile ]; then
8796 if grep -q -e " ^[^#]*bash-completion" -e " ^[^#]*bash_completion" " $HOME /.bash_profile" ; then
@@ -102,12 +111,15 @@ function guess_if_bash_completion_installed() {
102111
103112function update_bash_profile() {
104113 bash_profile_path=$( get_bash_profile_path)
114+ zsh_profile_path=$( get_zsh_profile_path)
105115 maybe_bash_completion_installed=$( guess_if_bash_completion_installed)
116+ did_locate_shell_profile=" false"
106117
107118 if [ " $bash_profile_path " != " " ]; then
119+ did_locate_shell_profile=" true"
108120 if ! grep -Fxq " source <(cortex completion bash)" " $bash_profile_path " ; then
109121 echo
110- read -p " Would you like to modify your bash profile ($bash_profile_path ) to enable cortex command completion and the cx alias? [y/n] " -r
122+ read -p " Would you like to modify your bash profile ($bash_profile_path ) to enable cortex command completion and the cx alias in bash ? [y/n] " -r
111123 echo
112124 if [ " $REPLY " = " y" ] || [ " $REPLY " = " Y" ] || [ " $REPLY " = " yes" ] || [ " $REPLY " = " Yes" ] || [ " $REPLY " = " YES" ]; then
113125 echo -e " \nsource <(cortex completion bash)" >> $bash_profile_path
@@ -118,20 +130,30 @@ function update_bash_profile() {
118130 echo -e " Note: \` bash-completion\` must be installed on your system for cortex command completion to function properly"
119131 fi
120132 else
121- echo -e " Your bash profile has not been modified. If you would like to modify it manually, add this line to your bash profile:"
122- echo " source <(cortex completion bash)"
123- if [ ! " $maybe_bash_completion_installed " = " true" ]; then
124- echo " Note: \` bash-completion\` must be installed on your system for cortex command completion to function properly"
125- fi
133+ echo -e " Your bash profile has not been modified (run \` cortex completion --help\` to show how to enable bash completion manually)"
126134 fi
127135 fi
128- else
129- echo -e " \nIf your would like to enable cortex command completion and the cx alias, add this line to your bash profile:"
130- echo " source <(cortex completion bash)"
131- if [ ! " $maybe_bash_completion_installed " = " true" ]; then
132- echo " Note: \` bash-completion\` must be installed on your system for cortex command completion to function properly"
136+ fi
137+
138+ if [ " $zsh_profile_path " != " " ]; then
139+ did_locate_shell_profile=" true"
140+ if ! grep -Fxq " source <(cortex completion zsh)" " $zsh_profile_path " ; then
141+ echo
142+ read -p " Would you like to modify your zsh profile ($zsh_profile_path ) to enable cortex command completion and the cx alias in zsh? [y/n] " -r
143+ echo
144+ if [ " $REPLY " = " y" ] || [ " $REPLY " = " Y" ] || [ " $REPLY " = " yes" ] || [ " $REPLY " = " Yes" ] || [ " $REPLY " = " YES" ]; then
145+ echo -e " \nsource <(cortex completion zsh)" >> $zsh_profile_path
146+ echo -e " ✓ Your zsh profile has been updated"
147+ echo -e " \nStart a new zsh shell for completion to take effect. If completion still doesn't work, you can try adding this line to the top of $zsh_profile_path : autoload -Uz compinit && compinit"
148+ else
149+ echo -e " Your zsh profile has not been modified (run \` cortex completion --help\` to show how to enable zsh completion manually)"
150+ fi
133151 fi
134152 fi
153+
154+ if [ " $did_locate_shell_profile " = " false" ]; then
155+ echo -e " \nIf you would like to enable cortex bash completion and the cx alias, run \` cortex completion --help\` for instructions"
156+ fi
135157}
136158
137159main
0 commit comments