github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/assets/contents/shells/tcsh.sh (about)

     1  # We don't need to source the rcfile here (like the other shells do)  because
     2  # the mechanism we are using to spawn the subshell is already loading it.
     3  #
     4  # Also, it's ineffectual to attempt setting a prompt in this script since those
     5  # `set` variables are not inherited when we spawn the sub shell via exec.  Only
     6  # `setenv` values are inherited.
     7  
     8  if ( -f ~/.cshrc ) source ~/.cshrc
     9  
    10  # Other shells have the capability to pass an rc file flag when starting a shell.
    11  # However, tcsh does not have that capability and will always source ~/.tcshrc.
    12  # As a result, we have to do `tcsh -c source tcsh.sh ; exec tcsh`, the latter of which sources
    13  # ~/.tcshrc.
    14  # This will cause a redundant "State Tool is operating on project ..., located at ..." message
    15  # since the necessary trigger variables are defined in this tcsh.sh script, which is loaded first.
    16  # So, define a one-time variable that ~/.tcshrc file uses to prevent printing the redundant message.
    17  # Subsequent tcsh invocations will not have this variable defined and will print the message as
    18  # expected.
    19  setenv ACTIVESTATE_TCSH_FIRST_RUN 1
    20  
    21  cd "{{.WD}}"
    22  
    23  {{- range $K, $V := .Env}}
    24  {{- if eq $K "PATH"}}
    25  setenv {{$K}} "{{$V}}:$PATH"
    26  {{- else}}
    27  setenv {{$K}} "{{$V}}"
    28  {{- end}}
    29  {{- end}}
    30  
    31  {{ if .ExecAlias }}
    32  alias {{.ExecName}}='{{.ExecAlias}}'
    33  {{ end }}
    34  
    35  {{range $K, $CMD := .Scripts}}
    36  alias {{$K}} '{{$.ExecName}} run {{$CMD}}'
    37  {{end}}
    38  
    39  echo "{{.ActivatedMessage}}"
    40  
    41  {{.UserScripts}}