Linux实用小工具

http://blog.csdn.net/pipisorry/article/details/50923957

cloc代码行数统计工具

cloc也可以用来统计源代码的行数, 其本质是一个perl的脚本
sudo apt-get install -y cloc
进入到需要统计的目录执行
cloc .

查看其源代码的信息 cat `which cloc`

皮皮blog

 

 

linux目录间的瞬间转移:dtags

linux下dtags的安装

apt-get install python3-pip #当然也可以用py2

pip3 install dtags

~/.bashrc(or ~/.bash_profile for OS X)最后一行(必须是最后一行,否则重启都不会生效!)添加一句话

command -v dtags-activate > /dev/null 2>&1 && eval "`dtags-activate bash`"

重启终端,就可以使用了。

最新版的改变了很多,见[README.rst ]

dtags的使用

长长的文件路径相当讨厌,cd命令切换到该路径要花了很长时间。急需一个能够在路径间快速转移,而不需要输入那长长的路径的办法!这就是dtags的用途!
dtags的核心是为文件路径起一个别名,也就是打一个标签(结印)。

打标签Tag directories with t

~$ tag ~/web dev work
这样给~/web这个路径打了两个标签,一个是dev,一个是work.

Note: 标签中不能有空格。

如果想用路径的最后一部分作为标签的话,可以省略后面的标签名参数

pika:/media/pika/files/mine$ t .
/media/pika/files/mine +#mine

这表示将当前路径打一个标签名为最后一个部分的标签。

~$ t ~/app

这样dtags就为~/app这个路径打了一个标签app。

$t /media/pika/files/ e
/media/pika/files +#e

~$ t ~/app dev work     # tag ~/app with 'dev' and 'work'
~$ t ~/app              # tag ~/app with its basename, 'app'

管理标签

标签越来越多之后,我们就需要管理我们的标签了。我们可以通过命令
~$ dtags 或者 dtags list  
来查看都有哪些标签。通过命令
~$ u ~/app app

来取消路径对应的某个标签。

Un-tag directories with u:

~$ u ~/app dev          # remove tag 'dev' from ~/app
~$ u ~/app              # remove all tags from ~/app

切换目录

~$ d app  
这样就切换到了目录~/app。另外,d这个命令被设计用来完全替代cd命令,所以d命令也可以接受普通的路径作为参数,并切换当前路径到对应的位置。

当然不可以使用cd命令来切换dtags设计的目录

Change directories with d (designed to fully replace cd!):

~$ d                    # go to the user's home directory
~$ d -                  # go to the last directory
~$ d app                # go to the directory tagged 'app'
~$ d ~/app              # go to directory ~/app

执行命令

更加快捷的是,你可以指定在某个目录中执行命令。语法是
e  标签名/路径 要运行的命令
~$ e app git status 
这条命令在~/app下执行git status命令。
更牛的是,e可以同时在多个目录执行同一条命令,只要用逗号分割这些路径就可以了
~$ e app,~/tmp/direct ls
这条命令同时在~/app, ~/tmp/dirct两个目录中执行ls命令,并打印了结果。

Execute commands in one or more directories with e:

~$ e app git status     # execute 'git status' in all directories tagged 'app'
~$ e ~/vm vagrant halt  # regular directory paths are accepted as well
~$ e app,~/vm,~/foo ls  # multiple tags and/or paths can be specified using commas
~$ e -i app myalias     # use -i (interactive shell) to use functions, aliases etc.

Execute commands in parallel with p (same interface as e):

~$ p app git pull       # execute 'git pull' in all directories tagged 'app' in parallel
~$ p -i app myalias     # again, use -i for interactive shell (read below for caveats)

Display, search and manage tags with dtags:

~$ dtags                # display the directories-to-tags mapping
~$ dtags list ~ ~/vm    # list the tags and directories associated with ~ and ~/vm
~$ dtags list foo bar   # list the tags and directories associated with 'foo' or 'bar'
~$ dtags reverse        # list the tags-to-directories (reverse) mapping
~$ dtags edit           # edit tags and directories via editor
~$ dtags clean          # remove invalid or stale tags and directories
~$ dtags commands       # display all available dtags commands (e.g. t, u, d, e, p)

[dtags项目地址]

from: http://blog.csdn.net/pipisorry/article/details/50923957

ref:

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值