MAC常用操作

文章介绍了如何在Unix/Linux系统中添加环境变量,以便在终端下方便地使用应用的可执行文件,如cmake。此外,还讲述了如何改变终端和vim编辑器的颜色主题以提升用户体验。在遇到cmake与Xcode集成问题时,提到了解决方案是调整xcode-select的路径。同时,文中还列举了Terminal的一些常用快捷键,提高工作效率。
摘要由CSDN通过智能技术生成

1. 添加环境变量

vi ~/.bash_profile
export PATH=selfdefine_path:$PATH
source ~/.bash_profile

适用于安装Application之后将该Application的Contents/bin下的可执行程序添加到环境变量,使得在终端能够启用。
例如使用cmake-3.25.0-macos-universal.dmg安装好cmake之后将该Application的Contents/bin下的可执行程序添加到环境变量,使得在终端能够启用。
在这里插入图片描述

2. 改变终端颜色

vim ~/.bash_profile
export CLICOLOR=1
export LSCOLORS=ExGxFxdaCxDaDahbadeche
source ~/.bash_profile

参考:
https://zhuanlan.zhihu.com/p/60880207

3. 改变vim颜色

vi ~/.vimrc

  1 " Configuration file for vim                                                
  2 set modelines=0     " CVE-2007-2438
  3 
  4 " Normally we use vim-extensions. If you want true vi-compatibility
  5 " remove change the following statements
  6 set nocompatible    " Use Vim defaults instead of 100% vi compatibility
  7 set backspace=2     " more powerful backspacing
  8 
  9 " Don't write backup file if vim is being called by "crontab -e"
 10 au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
 11 " Don't write backup file if vim is being called by "chpass"
 12 au BufWrite /private/etc/pw.* set nowritebackup nobackup
 13 
 14 let skip_defaults_vim=1
 15 
 16 " 自定义设置
 17 filetype on
 18 syntax on
 19 set number
 20 set cindent
 21 set smartindent
 22 set showmatch
 23 set ruler
 24 set cursorline
 25 set autoindent
 26 set cindent
 27 set tabstop=4
 28 set shiftwidth=4
 29 set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\     %c:%l/%L%)\
 30 set hlsearch

4. Terminal快捷键

Command + K 清屏
Command + T 新建标签
Command +W 关闭当前标签页
Command + S 保存终端输出
Command + D 垂直分隔当前标签页
Command + Shift + D 水平分隔当前标签页
Command + shift + {或} 向左/向右切换标签

5. cmake -G Xcode ..报错提示未找到编译器

cmake指定Xcode为generator时报错:

lg@lgdeMacBook-Pro build % cmake -G Xcode ..
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:22 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:22 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "/Users/lg/01.Tools/01.PanGu/build/CMakeFiles/CMakeOutput.log".
See also "/Users/lg/01.Tools/01.PanGu/build/CMakeFiles/CMakeError.log".

原因是在命令行中xcode-select指向的是/Library/Developer/CommandLineTools,生成xcode项目时,需要将xcode-select指向/Applications/Xcode.app/Contents/Developer
解决方法
终端上执行:sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
参考:CMake生成Xcode失败 No CMAKE_C_COMPILER could be found

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值