window下安装cygwin

2020-12-16 10:03:43 阅读:2 编辑

https://www.cygwin.com/ 选择"setup-x86_64.exe"

选择Install from Internet, 在”User URL”处输入以下地址:

https://mirrors.tuna.tsinghua.edu.cn/cygwin/
要安装wget
通过cyg-get安装软件包
vi /usr/local/bin/cyg-get
#!/usr/bin/env bash

# import proxy definition
[[ -r /etc/profile.d/proxy.sh ]] && . /etc/profile.d/proxy.sh

readonly SUCCESS=0
readonly ERROR=1
readonly E_WRONG_ARGS=2

get_current_version()
{
  cd /usr/local/bin

  [[ -e setup-x86_64.exe ]] && rm setup-x86_64.exe
  wget -q http://cygwin.com/setup-x86_64.exe
  chmod u+x setup-x86_64.exe
}

main()
{
  local all_parameters="$@"
  local params="--no-admin"
  local packages=

  while :; do
    case "$1" in
      install)
        params="${params} -q -P"
        shift
        # list of comma separated packages
        packages=$(echo $@|sed -e 's/\s\+/,/g')
        params="${params} ${packages}"
        ;;
      remove)
        params="${params} -q -x"
        shift
        packages=$(echo $@|sed -e 's/\s\+/,/g')
        params="${params} ${packages}"
        ;;
      update)
        params="${params} -q -g"
        get_current_version
        ;;
      # Unknonw option
      -?*)
        echo "unknown option: $1"
        exit $E_WRONG_ARGS
        ;;
      # Default case: If no more options then break out of the loop.
      *)
        get_current_version
        break
    esac
    shift
  done

  run /usr/local/bin/setup-x86_64.exe ${params}
  exit $SUCCESS
}

main "$@"
加权限
chmod +x /usr/local/bin/cyg-get
命令
#example
cyg-get install git
cyg-get remove git
cyg-get remove git