美文网首页
安装、配置iterm2中遇到的问题

安装、配置iterm2中遇到的问题

作者: NanNan | 来源:发表于2021-07-02 22:37 被阅读0次

    步骤1

    1、安装iterms2 链接地址
    2、同时可以把字体也下载下来,后面会用到Meslo LG M Regular for Powerline.ttf

    ⚠️:下载Meslo字体的链接如下,Meslo字体是配合主题设置的是ZSH_THEME="agnoster"使用的。详细可以查网上,这个一般不会有什么问题的。

    步骤2

    1、安装oh-my-zsh 到~/.oh-my-zsh文件下

    git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
    

    2、安装完oh-my-zsh后需要做的一件事是配置.zshrc文件,很重要,这一步花费了一些时间

    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    source ~/.zshrc
    

    步骤3

    下载插件到桌面,或者直接找到位置然后下载。

    1、下面是找到指定位置

    cd  /Users/用户名/.oh-my-zsh/plugins
    

    2、自动补充

     git clone https://github.com/zsh-users/zsh-autosuggestions
    

    3、高亮

     git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
    2、把插件放到指定的位置,(**⚠️必须在/.oh-my-zsh/plugins文件夹下**)
    
    
    问题一

    注意⚠️如果使用git下载插件,不需要在~/.zshrc中配置一下代码,以下代码是使用homebrew下载安装才会增加的代码
    1、使用git下载需要在~/.zshrc中配置到代码;可以在.zshrc中全局搜索plugins。

    plugins=( git  
                zsh-autosuggestions 
                zsh-syntax-highlighting
                )
    

    2、homebrew下载需要在~/.zshrc中配置的代码;

    source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    
    问题二
    
    [oh-my-zsh] Insecure completion-dependent directories detected:
    drwxrwxrwx 7 hans admin 238 2 9 10:13 /usr/local/share/zsh
    drwxrwxrwx 6 hans admin 204 10 1 2017 /usr/local/share/zsh/site-functions
    
    [oh-my-zsh] For safety, we will not load completions from these directories until
    [oh-my-zsh] you fix their permissions and ownership and restart zsh.
    [oh-my-zsh] See the above list for directories with group or other writability.
    
    [oh-my-zsh] To fix your permissions you can do so by disabling
    [oh-my-zsh] the write permission of "group" and "others" and making sure that the
    [oh-my-zsh] owner of these directories is either root or your current user.
    [oh-my-zsh] The following command may help:
    [oh-my-zsh] compaudit | xargs chmod g-w,o-w
    
    [oh-my-zsh] If the above didn't help or you want to skip the verification of
    
    解决方法
    chmod 755 /usr/local/share/zsh
    chmod 755 /usr/local/share/zsh/site-functions
    

    问题三
    修改终端前面的用户名
    前往~/.oh-my-zsh/themes/agnoster.zsh-theme文件夹下,打开agnoster.zsh-theme,全局搜索prompt_context(),定位代码做如下修改

    # Context: user@hostname (who am I and where am I)
    prompt_context() {
    # 修改前
      # if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
      #  prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
      # fi
      
    # 修改后
     if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
       # 修改如下代码,@Mac可以你自己定义
       # prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
       prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@Fyn"
      fi
    }
    

    相关文章

      网友评论

          本文标题:安装、配置iterm2中遇到的问题

          本文链接:https://www.haomeiwen.com/subject/xziyultx.html