分配文件关键字以便以后轻松找到它们

分配文件关键字以便以后轻松找到它们

假设我有一个文件。该文件存储在一些复杂的位置(在一百个子文件夹内),但我仍然经常使用它。有没有某种方法可以为此文件分配一组关键字(即“我最喜欢的文件”),然后稍后在某些自然语言处理器(命令行界面或语音识别软件)中输入这些关键字以打开该文件?就像我可能会在命令行中输入“打开最喜欢的文件”,或者我可能会在语音识别软件中说“打开我最喜欢的文件”。

有这样的服务吗?

答案1

是的,它确实:

  1. 按照 @emory 的说明创建指向它的链接。

  2. 使其成为环境变量。将此行添加到 shell 的初始化文件中(~/.bashrc如果您使用的是 bash):

    myfile =“/荒谬/长/路径/那个/你/会/而不是/类型/每次/时间”

    然后,从命令行,您可以$myfile像实际文件名一样使用:

    $ echo $myfile 
    /absurdly/long/path/that/you/would/rather/not/type/every/time
    $ cat > $myfile 
    This is so much easier now!
    $ cat $myfile 
    This is so much easier now!
    
  3. 如果您将该文件用于特定目的,例如,您只需将cat其发送到终端,那么您还可以设置一个别名来执行相同的操作。将其添加到 shell 的初始化文件中:

    alias myfile='cat /absurdly/long/path/that/you/would/rather/not/type/every/time'
    

    然后,运行它:

    $ myfile 
    This is so much easier now!
    

答案2

你能创建一个符号链接吗

ln -sf /some/complex/location/1/2/{your complex directory structure}/100/FavoriteFile /home/me/Desktop/FavoriteFile

该文件仍然位于其复杂的位置,但可以从您的桌面访问。

答案3

ctags 或许可以帮助你。它的创建是为了索引计算机源代码文件,并可以轻松地定位函数或例程,并且需要确切地知道哪个文件包含它或该文件所在的位置。

手册页摘录:

   Tag index files are supported by numerous editors, which allow the user
   to locate the object associated with a name appearing in a source  file
   and jump to the file and line which defines the name. Those known about
   at the time of this release are:

   Vi(1) and its derivatives (e.g. Elvis, Vim,  Vile,  Lemmy),  CRiSP,
   Emacs, FTE (Folding Text Editor), JED, jEdit, Mined, NEdit (Nirvana
   Edit), TSE (The SemWare Editor), UltraEdit, WorkSpace, X2, Zeus

   Ctags is capable of generating different kinds of tags for each of many
   different  languages.  For  a complete list of supported languages, the
   names by which they are recognized, and the kinds  of  tags  which  are
   generated  for each, see the --list-languages and --list-kinds options.

祝你好运。

相关内容