vscode配置c++环境 安装MinGW,
官网下拉没有了,去github下载,Releases · niXman/mingw-builds-binaries
我选择gcc12,posix线程版本
windows下配置path…
添加C/C++扩展,在扩展的配置里面选择编译器配置和编译器路径,添加头文件路径(包括下载的库头文件也加在这里)
比如添加boost库,即加入路径”D:/packet/boost_1_86_0/boost_1_86_0/**”
同时在每个目录的.vscode目录下有一个json记录编译器信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 { "configurations" : [ { "name" : "windows-gcc-x64" , "includePath" : [ "${workspaceFolder}/**" , "D:\\packet\\boost_1_86_0\\boost_1_86_0/**" ] , "compilerPath" : "D:/develop/MinGW/bin/g++.exe" , "cStandard" : "${default}" , "cppStandard" : "${default}" , "intelliSenseMode" : "windows-gcc-x64" , "compilerArgs" : [ "" ] } ] , "version" : 4 }
编写一个hello world程序并点解右上角运行(debug模式launch默认gdb,这里还要下载一个gdb)
这里调试只能暂时先选第一个自动生成launch.json文件
然后再选择c++gdb添加configurations项,这里直接参考第一个生成的项,这里的miDebuggerPath为gdb路径,可以用where gdb找到
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 { "name" : "gdb" , "type" : "cppdbg" , "request" : "launch" , "program" : "c:/Users/ben/Desktop/example/build/Debug/outDebug" , "args" : [ ] , "stopAtEntry" : false , "cwd" : "${fileDirname}" , "environment" : [ ] , "externalConsole" : false , "MIMode" : "gdb" , "miDebuggerPath" : "gdb" , "setupCommands" : [ { "description" : "为 gdb 启用整齐打印" , "text" : "-enable-pretty-printing" , "ignoreFailures" : true } , { "description" : "将反汇编风格设置为 Intel" , "text" : "-gdb-set disassembly-flavor intel" , "ignoreFailures" : true } ] , "preLaunchTask" : "gdb" }
这里的program应该是在tasks.json里设置生成的exe文件,而不是cpp文件,调试成功如下图
vscode配置ssh 编辑C:/Users/your_name/.ssh/config ,填写连接主机user和ip配置
免密配置:ssh-keygen生成密钥文件id_rsa和公钥文件id_rsa.pub,将公钥填入到服务器的~/.ssh/authorized_keys文件中
这里有个问题:当服务器删除配置,或密钥更改损坏时,这时vscode怎么都无法ssh到服务器,需要把know_hosts(远端公钥清单)的那条记录删除,让他自动生成一条新的
.ssh文件中:authorized_keys存放远程公钥;know_hosts存放服务器的公钥和ip来简化ssh免密登录,对称比非对称代价小
oh-my-zsh配置p10k主题 安装更高版本zsh,下载5.9版本的源码
1 2 3 4 5 6 7 yum install ncurses-devel #安装环境 cd zsh-5.9 ./configure make && make install which zsh # /usr/local/bin/zsh一般在这个目录,需要加入到/etc/shells里去 echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells
安装oh my zsh
1 2 yum install git sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
安装p10k,最好去github找md,而不是网上查找
1 2 3 4 5 6 7 git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc source ~/.zshrc # 插件安装 zsh-syntax-highlighting zsh-autosuggestions # git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
给其他用户设置,比如git用户
1 2 3 4 5 6 7 sudo cp -r /root/.oh-my-zsh /home/git/ sudo cp /root/.zshrc /home/git/ sudo cp -r /root/powerlevel10k /home/git sudo chown -R git:git /home/git/.oh-my-zsh sudo chown git:git /home/git/.zshrc su - git chsh -s /usr/local/zsh