标签:windows

以下是与标签 “windows” 相关联的文章

vscode 编译调试 java 单文件代码

安装

  • Language Support for Java(TM) by Red Hat
  • Java Debug Extension for Visual Studio Code

设置

  • 需要先打开一个目录,以下配置文件生成于该目录的 .vscode 目录下
  • 编译设置

C-S-p Tasks: Configure Task Runner

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "java build",
            "type": "shell",
            "command": "javac",
            "args": ["-d","${workspaceRoot}","${file}"],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": {
                "owner": "java",
                "fileLocation": ["absolute"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error|fatal error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        }
    ]
}
  • 调试设置

Debug -> Start Debugging

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch)",
            "request": "launch",
            "sourcePaths": [
                "$(workspaceRoot)"
            ],
            "classPaths": [
                "",            
                "$(workspaceRoot)"
            ],
            "mainClass": "${fileBasenameNoExtension}",
            "args": ""
        },
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 0
        }
    ]
}

快捷键

  • 编译 C-S-b
  • 调试 F5

vscode 编译调试 C++ 单文件代码

安装

  • 安装 vscode
  • 安装插件 c/c++ c/c++ snippets

设置

  • 需要先打开一个目录,以下配置文件生成于该目录的 .vscode 目录下
  • IntelliSense 设置

C-S-p c/cpp: Edit Configurations..

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "D:/mingw540-x64/x86_64-w64-mingw32/include/c++",
                "${workspaceRoot}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "D:/mingw540-x64/x86_64-w64-mingw32/include/c++",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}
  • 编译设置

C-S-p Tasks: Configure Task Runner

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "g++ build",
            "type": "shell",
            "command": "g++.exe",
            "args": ["-g","${file}","-o","${file}.exe", "-std=c++1y"], 
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["absolute"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error|fatal error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "taskName": "clang++ build",
            "type": "shell",
            "command": "clang++.exe",
            "args": ["-target", "x86_64-pc-windows-gnu", "-g","${file}","-o","${file}.exe", "-std=c++1y"], 
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["absolute"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error|fatal error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        }
    ]
}
  • 调试设置

Debug -> Start Debugging

{
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${file}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceRoot}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }

快捷键

  • 编译 C-S-b
  • 调试 F5

在 windows 上使用 ag 搜索

安装 chocolately

  • 用管理员登录,打开 cmd.exe ,执行命令
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

安装 ag

choco install ag

在 emacs 中使用 ag 搜索

  • 添加目录到 PATH 环境变量
C:\ProgramData\chocolatey\bin
  • 在 spacemacs 中, SPC s a 是 ag 的操作前缀

在 windows 上使用 oh-my-zsh

安装 cygwin

  • 安装 cygwin 64 位 到 D:/cygwin 目录
    • 添加两个国内镜像地址

      http://mirrors.163.com/cygwin/
      http://mirrors.sohu.com/cygwin/
      
  • 安装基本功能,另外选上 wget,apt-cyt 依赖这个
  • 下载 apt-cygD:/cygwin/bin 目录, 另存一个为 apt
  • 安装软件

    apt install curl git zsh chere python
    
    
  • 去掉路径 /cygdriver 前缀,修改 /etc/fstab

    none / cygdrive binary 0 0
    
    
  • 去掉 zsh 启动提示,修改 /cygwin/bin/xhere

    # echo Starting $1;
    
    
  • /bin/python-2.7.exe 另存一个为 /bin/python.exe ,autojump 用到

安装 oh-my-zsh

  • 执行安装命令
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

  • 修改 ~/.zshrc

    ZSH_THEME="ys"
    DISABLE_AUTO_UPDATE="true"
    DISABLE_UNTRACKED_FILES_DIRTY="true"
    plugins=(git autojump)
    
  • 安装 autojump

    git clone git://github.com/joelthelion/autojump.git
    cd /autojump
    ./install.py #在 bash 下安装,python 用 cygwin 版本
    
  • 修改 .oh-my-zsh/themes/ys.zsh-theme,删除 hg-info git-info 两行

安装 cmder

  • 下载 cmder_mini 并解压,添加快捷方式到桌面
  • 解决中文乱码问题,进入设置 Settings -> Startup -> Environment,添加

    set LANG=zh_CN.UTF-8
    
    
  • 添加 oh-my-zsh Task,进入设置 Settings -> Startup -> Tasks, 点“+”号

    oh-my-zsh
    Hotkey: Ctrl-Alt-O
    Task parameters: /icon D:\cygwin\Cygwin-Terminal.ico
    Commands: sh -c "/bin/xhere /bin/zsh.exe '%V'"
    
  • 设置默认 Task,进入设置 Settings -> Startup

    Specified named task: {oh-my-zsh}
    
    
  • 去掉 git 旧版本提示,修改 d:/green/cmder_mini/vender/init.bat

    rem echo Found old git version in "!test_dir!", but not using...
    
    

整合到 Total Commander

  • USERCMD.ini 最后添加

    [em_Everything]
    cmd=D:\Program Files\Everything\Everything.exe
    param="-search "%P ""
    
    [em_cmder]
    cmd=D:\green\cmder_mini\cmder.exe
    param="%P "
    
  • Wincmd.ini 中修改

    CA+F=cm_SearchFor
    C+F=em_Everything
    CA+G=cm_ExecuteDOS
    C+G=em_cmder
    A+D=cm_EditPath
    
  • Total Commander 最小化
    • 设置->选项->操作->取消“最小化到系统托盘”
    • wincmd.ini

      [Configuration] 
      MinimizeOnClose=1
      

      MinimizeOnClose 数值为以下某几个的值之和:

      1. 关闭按钮
      2. Alt+F4 组
      3. 界面内“Alt+F4 退出“按钮