小编Vic*_*Dev的帖子

如何将 gedit 中当前打开文件的路径复制到剪贴板?

我正在尝试在 Gedit 中编写一个自定义命令,它将当前打开和活动文档的路径(包括父目录和文件)复制到剪贴板,因为我找不到任何可以执行此操作的 gedit 插件或工具。

我还不知道从哪里开始,也没有任何好的参考资料,但我知道我必须在 bash 脚本中编写脚本。

我搜索了外部命令以将任何字符串从终端复制到剪贴板(因为它也运行 bash 脚本)但答案建议使用“xclip”工具,我已经尝试过并且很失望,因为使用 xclip 复制的任何字符串只能粘贴使用“xclip -o”命令。我需要复制的字符串可以用 Ctrl-V 粘贴,这样我就可以在文件管理器(鹦鹉螺)中打开路径。

任何帮助/建议表示赞赏。

gedit command-line bash scripts clipboard

3
推荐指数
1
解决办法
1万
查看次数

删除所有扩展名为“.sh”的文件,但保留一个与终端扩展名匹配的文件

其实这种要求太多了我觉得。

但我想删除与扩展名“.sh”(仅限当前文件夹)匹配的所有文件,我可以使用以下命令执行此操作:

find . -maxdepth 1 -type f -name '*.sh' -exec rm {} +
Run Code Online (Sandbox Code Playgroud)

但我仍然想保持当前文件夹中的文件“cron.sh”不受影响。

如何在单个命令行中实现这一点?

command-line find

3
推荐指数
1
解决办法
542
查看次数

用于克隆 github 组织的每个 repo 的 Shell 脚本

我有一个来自 curl 响应的正常组织回购列表,命令如下:

curl "https://api.github.com/orgs/[organization]/repos?access_token=[access_token]"
Run Code Online (Sandbox Code Playgroud)

这个命令的输出是巨大的。我想提取每个 repo 的clone_url参数,遍历这些 URL 并git clone在其上运行。

下面是JSON输出curl给我的一个条目的一瞥:

[
  {
    "id": 42059877,
    "name": "customrepo",
    "full_name": "SampleOrg/customrepo",
    "owner": {
      "login": "SampleOrg",
      "id": 14164701,
      "avatar_url": "https://avatars1.githubusercontent.com/u/14164701?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/SampleOrg",
      "html_url": "https://github.com/SampleOrg",
      "followers_url": "https://api.github.com/users/SampleOrg/followers",
      "following_url": "https://api.github.com/users/SampleOrg/following{/other_user}",
      "gists_url": "https://api.github.com/users/SampleOrg/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/SampleOrg/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/SampleOrg/subscriptions",
      "organizations_url": "https://api.github.com/users/SampleOrg/orgs",
      "repos_url": "https://api.github.com/users/SampleOrg/repos",
      "events_url": "https://api.github.com/users/SampleOrg/events{/privacy}",
      "received_events_url": "https://api.github.com/users/SampleOrg/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "private": true,
    "html_url": "https://github.com/SampleOrg/customrepo",
    "description": null,
    "fork": false,
    "url": "https://api.github.com/repos/SampleOrg/customrepo",
    "forks_url": "https://api.github.com/repos/SampleOrg/customrepo/forks",
    "keys_url": "https://api.github.com/repos/SampleOrg/customrepo/keys{/key_id}",
    "collaborators_url": …
Run Code Online (Sandbox Code Playgroud)

command-line bash scripts git github

2
推荐指数
1
解决办法
5300
查看次数

标签 统计

command-line ×3

bash ×2

scripts ×2

clipboard ×1

find ×1

gedit ×1

git ×1

github ×1