zoukankan      html  css  js  c++  java
  • ubuntu中为vscode添加右键菜单--网上没有—就自己做了个

    Ubuntu 添加右键菜单项

    在 ubuntu 中,经常是 open-in-terminal,然后执行相应命令,想起之前一个工具的 readme 中处理过添加到右键的办法,查找一下相关用法:
    在$HOME/.local/share/nautilus/script/添加相关执行文件

    此时我们知道了应该去$HOME/.local/share/nautilus/script/目录下面添加脚本:

    新建一个 文件 ,文件名任意(这个文件名会显示在右键菜单里,最好是通俗易懂的,文件内容如下。

    1. #!/bin/bash
    2. #
    3. # This script opens a gnome-terminal in the directory you select.
    4. #
    5. # Distributed under the terms of GNU GPL version 2 or later
    6. #
    7. # Install in ~/.gnome2/nautilus-scripts or ~/Nautilus/scripts
    8. # You need to be running Nautilus 1.0.3+ to use scripts.
    9. # When a directory is selected, go there. Otherwise go to current
    10. # directory. If more than one directory is selected, show error.
    11. if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
    12. set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
    13. if [ $# -eq 1 ]; then
    14. destination="$1"
    15. # Go to file's directory if it's a file
    16. if [ ! -d "$destination" ]; then
    17. destination="`dirname "$destination"`"
    18. fi
    19. else
    20. zenity --error --title="Error - Open terminal here" /
    21. --text="You can only select one directory."
    22. exit 1
    23. fi
    24. else
    25. destination="`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed 's/^file://////'`"
    26. fi
    27. # It's only possible to go to local directories
    28. if [ -n "`echo "$destination" | grep '^[a-zA-Z0-9]/+:'`" ]; then
    29. zenity --error --title="Error - Open terminal here" /
    30. --text="Only local directories can be used."
    31. exit 1
    32. fi
    33. cd "$destination"
    34. exec visual-studio-code "$destination"
       
      添加完后,把此文件加上可执行的权限。
      chmod +x 刚才创建的文件名
       
      第二种方法建出来的是一个二级菜单,它先是在右键菜单中添加一个名叫scripts的菜单,在这个菜单下才是我们新建的脚本的文件名,所以显得有些不方便。
  • 相关阅读:
    【Vijos1159】岳麓山上打水 [迭代加深]
    【POJ3134】 Power Calculus [迭代加深]
    【2019.1.24】 搜索,动规 经典题目体验赛
    【noip2017】
    【poj3311】Hie With The Pie [状压dp]
    [bzoj3938] [Uoj #88] Robot
    [洛谷P4707] 重返现世
    [洛谷P4097] [HEOI2013] Segment
    KD-tree 学习小记
    NOI2019 酱油记
  • 原文地址:https://www.cnblogs.com/hongdoudou/p/12708510.html
Copyright © 2011-2022 走看看