【脚本】删除idea的工作空间

71 阅读1分钟
function printDeleteIdeaExec(){
    user_home=~

    # 在 ~/Library/Logs/JetBrains 找idea的配置
    log_dir=$user_home/Library/Logs/JetBrains
    ls -1 $log_dir | awk '{ print "rm -rf \""pwd"/"$0"\""}' pwd=$log_dir | grep IntelliJIdea

    # 在 ~/Library/Preferences 找idea的配置
    pre_dir=$user_home/Library/Preferences
    ls -1 $pre_dir | awk '{ print "rm -f \""pwd"/"$0"\""}' pwd=$pre_dir | grep jetbrains

    # 在 ~/Library/Application Support/JetBrains 找idea的配置
    sup_dir="$user_home/Library/Application Support/JetBrains"
    ls -1 "$sup_dir" | awk '{ print "rm -rf \""pwd"/"$0"\""}' pwd="$sup_dir" | grep IntelliJIdea

    # 在 ~/Library/Caches/JetBrains 找idea的配置
    cache_dir="$user_home/Library/Caches/JetBrains"
    ls -1 "$cache_dir" | awk '{ print "rm -rf \""pwd"/"$0"\""}' pwd="$cache_dir" | grep IntelliJIdea

    # 删除idea的工作空间
    idea_dir="$user_home/.idea"

    echo "rm -rf $idea_dir"
}

此方法不会真正执行删除操作,只是把删除的语句打印出来

PS: 此脚本写于2020/05, 后面可能有更新覆盖不到,请在下方评论