• 从命令行打开IntelliJ IDEA及IntelliJ IDEA CE


    假设我们有一个springboot项目,使用Maven构建的。当我们使用git clone xxx.git将项目clone到本地之后,我们怎么打开项目?
    打开idea,新建empty project ,然后import from desk ? 太麻烦了。通过配置快捷命令,可以使用idea pom.xml打开项目。

    在用户目录创建一个.idea.sh ,然后输入下面的一段脚本。

    cd ~/
    touch .idea.sh
    vim .idea.sh
    

    输入如下内容,保存退出。

    #!/bin/sh
    
    # check for where the latest version of IDEA is installed
    IDEA=`ls -1d /Applications/IntelliJ * | tail -n1`
    wd=`pwd`
    
    # were we given a directory?
    if [ -d "$1" ]; then
    #  echo "checking for things in the working dir given"
      wd=`ls -1d "$1" | head -n1`
    fi
    
    # were we given a file?
    if [ -f "$1" ]; then
    #  echo "opening '$1'"
      open -a "$IDEA" "$1"
    else
        # let's check for stuff in our working directory.
        pushd $wd > /dev/null
    
        # does our working dir have an .idea directory?
        if [ -d ".idea" ]; then
    #      echo "opening via the .idea dir"
          open -a "$IDEA" .
    
        # is there an IDEA project file?
        elif [ -f *.ipr ]; then
    #      echo "opening via the project file"
          open -a "$IDEA" `ls -1d *.ipr | head -n1`
    
        # Is there a pom.xml?
        elif [ -f pom.xml ]; then
    #      echo "importing from pom"
          open -a "$IDEA" "pom.xml"
    
        # can't do anything smart; just open IDEA
        else
    #      echo 'cbf'
          open "$IDEA"
        fi
    
        popd > /dev/null
    fi
    

    创建命令别名

    vim ~/.zshrc
    输入 alias idea="sh ~/.idea.sh"
    

    刷新配置,使生效:

    source  ~/.zshrc
    

    测试命令行打开Maven项目

    cd /path/to/maven_project
    idea pom.xml
    

    以上配置无误的话,此时立马就能看到idea启动了,Maven项目已打开。

    如果你像我一样,电脑上安装了IDEA CE的话,可以再配置一个ideace的别名。
    跟上面的步骤一样,新建一个 .ideace.sh,内容跟.idea.sh的内容一样,只需要改变一行:

    IDEA=`ls -1d /Applications/IntelliJ IDEA CE* | tail -n1`
    

    然后创建一个别名alias ideace="sh ~/.ideace.sh"

    接下来,便可以使用 ideace pom.xml来打开项目了。

  • 相关阅读:
    Vue根据URL传参来控制全局 console.log 的开关
    原来你是这样的毛玻璃
    CSS3边框会动的信封
    判断当前系统当前浏览器是否安装启用 Adobe Flash Player,检查在chrome中的状态
    随笔一个正则
    PHP实现栈数据结构
    php实现一个单链表
    php中按值传递和按引用传递的一个问题
    利用shell脚本或者php移动某个文件夹下的文件到各自的日期组成的目录下
    php中DateTime、diff
  • 原文地址:https://www.cnblogs.com/demingblog/p/14169436.html
Copyright © 2020-2023  润新知