This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ssh and user env vars from control panel


I made this block for my .zshrc and .bashrc :

if [ -z "$APPDATA" ]; then
  # ssh session, set env vars
  
  # this from Corinna at http://cygwin.com/ml/cygwin/2010-08/msg00246.html
  _sid=$(grep "^$USER:" /etc/passwd | sed -e 's/[^:]*:[^:]*:[^:]*:[^:]*:[^:]*,\(S-1-5-[^:]*\):.*/\1/')
  _prof=$(cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows\ NT/CurrentVersion/ProfileList/${_sid}/ProfileImagePath)
  export APPDATA="${_prof}\\AppData\\Roaming"
  export LOCALAPPDATA="${_prof}\\AppData\\Local"
  unset _sid
  unset _prof

  echo | powershell -noprofile -command '$env = [environment]::GetEnvironmentVariables("User"); foreach ($key in $env.Keys) { $line = "export " + $key + "=" + "'\''" + $env.$key + "'\''"; write-host $line }' | while read -r env_var; do
    if    echo $env_var | grep -q '^export HOME=' \
       || echo $env_var | grep -q '^export PATH='; then
      continue
    fi
    eval $env_var
  done
  unset env_var
fi

maybe someone else will find it useful.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]