mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-08-23 04:03:29 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lujun9972)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11322-1.html)
|
||||
[#]: subject: (How many browser tabs do you usually have open?)
|
||||
[#]: via: (https://opensource.com/article/19/6/how-many-browser-tabs)
|
||||
[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst)
|
||||
|
||||
你通常打开多少个浏览器标签页?
|
||||
======
|
||||
|
||||
> 外加一些提高浏览器效率的技巧。
|
||||
|
||||
![Browser of things][1]
|
||||
|
||||
这里有一个别有用心的问题:你通常一次打开多少个浏览器标签页?你是否有多个窗口,每个窗口都有多个标签页?或者你是一个极简主义者,一次只打开两个标签页。另一种选择是将一个 20 个标签页的浏览器窗口移动到另一个屏幕上去,这样在处理特定任务时它就不会碍事了。你的处理方法在工作、个人和移动浏览器之间有什么不同吗?你的浏览器策略是否与你的[工作习惯][2]有关?
|
||||
|
||||
### 4 个提高浏览器效率的技巧
|
||||
|
||||
1. 了解浏览器快捷键以节省单击。无论你使用 Firefox 还是 Chrome,都有很多快捷键可以让你方便地执行包括切换标签页在内的某些功能。例如,Chrome 可以很方便地打开一个空白的谷歌文档。使用快捷键 `Ctrl + t` 打开一个新标签页,然后键入 `doc.new` 即可。电子表格、幻灯片和表单也可以这样做。
|
||||
2. 用书签文件夹组织最频繁的任务。当开始一项特定的任务时,只需打开文件夹中的所有书签 (`Ctrl + 点击`),就可以快速地从列表中勾选它。
|
||||
3. 使用正确的浏览器扩展。成千上万的浏览器扩展都声称可以提高工作效率。在安装之前,确定你不是仅仅在屏幕上添加更多的干扰而已。
|
||||
4. 使用计时器减少看屏幕的时间。无论你使用的是老式的 egg 定时器还是花哨的浏览器扩展,都没有关系。为了防止眼睛疲劳,执行 20/20/20 规则。每隔 20 分钟,离开屏幕 20 秒,看看 20 英尺以外的东西。
|
||||
|
||||
参加我们的投票来分享你一次打开多少个浏览器标签。请务必在评论中告诉我们你最喜欢的浏览器技巧。
|
||||
|
||||
生产力有两个组成部分——做正确的事情和高效地做那些事情……
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/how-many-browser-tabs
|
||||
|
||||
作者:[Lauren Pritchett][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[lujun9972](https://github.com/lujun9972)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things)
|
||||
[2]: https://enterprisersproject.com/article/2019/1/5-time-wasting-habits-break-new-year
|
||||
@@ -0,0 +1,200 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11324-1.html)
|
||||
[#]: subject: (How to change the color of your Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/19/9/linux-terminal-colors)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
如何改变你的终端颜色
|
||||
======
|
||||
|
||||
> 使 Linux 变得丰富多彩(或单色)。
|
||||
|
||||

|
||||
|
||||
你可以使用特殊的 ANSI 编码设置为 Linux 终端添加颜色,可以在终端命令或配置文件中动态添加,也可以在终端仿真器中使用现成的主题。无论哪种方式,你都可以黑色屏幕上找回怀旧的绿色或琥珀色文本。本文演示了如何使 Linux 变得丰富多彩(或单色)的方法。
|
||||
|
||||
### 终端的功能特性
|
||||
|
||||
现代系统的终端的颜色配置通常默认至少是 xterm-256color,但如果你尝试为终端添加颜色但未成功,则应检查你的 `TERM` 设置。
|
||||
|
||||
从历史上看,Unix 终端从字面上讲是:用户可以输入命令的共享计算机系统上实际的物理端点(终点)。它们专指通常用于远程发出命令的电传打字机(这也是我们今天在 Linux 中仍然使用 `/dev/tty` 设备的原因)。终端内置了 CRT 显示器,因此用户可以坐在办公室的终端上直接与大型机进行交互。CRT 显示器价格昂贵 —— 无论是制造还是使用控制;比担心抗锯齿和现代计算机专家理所当然认为的漂亮信息,让计算机吐出原始 ASCII 文本更容易。然而,即使在那时,技术的发展也很快,很快人们就会发现,随着新的视频显示终端的设计,他们需要新的功能特性来提供可选功能。
|
||||
|
||||
例如,1978 年发布的花哨的新 VT100 支持 ANSI 颜色,因此如果用户将终端类型识别为 vt100,则计算机可以提供彩色输出,而基本串行设备可能没有这样的选项。同样的原则适用于今天,它是由 `TERM` [环境变量][2]设定的。你可以使用 `echo` 检查你的 `TERM` 定义:
|
||||
|
||||
```
|
||||
$ echo $TERM
|
||||
xterm-256color
|
||||
```
|
||||
|
||||
过时的(但在一些系统上仍然为了向后兼容而维护)`/etc/termcap` 文件定义了终端和打印机的功能特性。现代的版本是 `terminfo`,位于 `/etc` 或 `/usr/share` 中,具体取决于你的发行版。 这些文件列出了不同类型终端中可用的功能特性,其中许多都是由历史上的硬件定义的,如 vt100 到 vt220 的定义,以及 xterm 和 Xfce 等现代软件仿真器。大多数软件并不关心你使用的终端类型; 在极少数情况下,登录到检查兼容功能的服务器时,你可能会收到有关错误的终端类型的警告或错误。如果你的终端设置为功能特性很少的配置文件,但你知道你所使用的仿真器能够支持更多功能特性,那么你可以通过定义 `TERM` 环境变量来更改你的设置。你可以通过在 `~/.bashrc` 配置文件中导出 `TERM` 变量来完成此操作:
|
||||
|
||||
```
|
||||
export TERM=xterm-256color
|
||||
```
|
||||
|
||||
保存文件并重新载入设置:
|
||||
|
||||
```
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
### ANSI 颜色代码
|
||||
|
||||
现代终端继承了用于“元”特征的 ANSI 转义序列。这些是特殊的字符序列,终端将其解释为操作而不是字符。例如,此序列将清除屏幕,直到下一个提示符:
|
||||
|
||||
```
|
||||
$ printf '\033[2J'
|
||||
```
|
||||
|
||||
它不会清除你的历史信息;它只是清除终端仿真器中的屏幕,因此它是一个安全且具有示范性的 ANSI 转义序列。
|
||||
|
||||
ANSI 还具有设置终端颜色的序列。例如,键入此代码会将后续文本更改为绿色:
|
||||
|
||||
```
|
||||
$ printf '\033[32m'
|
||||
```
|
||||
|
||||
只要你对相同的计算机使用同一个颜色,就可以使用颜色来帮助你记住你登录的系统。例如,如果你经常通过 SSH 连接到服务器,则可以将服务器的提示符设置为绿色,以帮助你一目了然地将其与本地的提示符区分开来。 要设置绿色提示符,请在提示符前使用 ANSI 代码设置为绿色,并使用代表正常默认颜色的代码结束:
|
||||
|
||||
|
||||
```
|
||||
export PS1=`printf "\033[32m$ \033[39m"`
|
||||
```
|
||||
|
||||
### 前景色和背景色
|
||||
|
||||
你不仅可以设置文本的颜色。使用 ANSI 代码,你还可以控制文本的背景颜色以及做一些基本的样式。
|
||||
|
||||
例如,使用 `\033[4m`,你可以为文本加上下划线,或者使用 `\033[5m` 你可以将其设置为闪烁的文本。起初这可能看起来很愚蠢,因为你可能不会将你的终端设置为所有文本带有下划线并整天闪烁, 但它对某些功能很有用。例如,你可以将 shell 脚本生成的紧急错误设置为闪烁(作为对用户的警报),或者你可以为 URL 添加下划线。
|
||||
|
||||
作为参考,以下是前景色和背景色的代码。前景色在 30 范围内,而背景色在 40 范围内:
|
||||
|
||||
颜色 | 前景色 | 背景色
|
||||
---|---|---
|
||||
黑色 | \033[30m | \033[40m
|
||||
红色 | \033[31m | \033[41m
|
||||
绿色 | \033[32m | \033[42m
|
||||
橙色 | \033[33m | \033[43m
|
||||
蓝色 | \033[34m | \033[44m
|
||||
品红 | \033[35m | \033[45m
|
||||
青色 | \033[36m | \033[46m
|
||||
浅灰 | \033[37m | \033[47m
|
||||
回退到发行版默认值 | \033[39m | \033[49m
|
||||
|
||||
还有一些可用于背景的其他颜色:
|
||||
|
||||
颜色 | 背景色
|
||||
---|---
|
||||
深灰 | \033[100m
|
||||
浅红 | \033[101m
|
||||
浅绿 | \033[102m
|
||||
黄色 | \033[103m
|
||||
浅蓝 | \033[104m
|
||||
浅紫 | \033[105m
|
||||
蓝绿 | \033[106m
|
||||
白色 | \033[107m
|
||||
|
||||
### 持久设置
|
||||
|
||||
在终端会话中设置颜色只是暂时的,相对无条件的。有时效果会持续几行;这是因为这种设置颜色的方法依赖于 `printf` 语句来设置一种模式,该模式仅持续到其他设置覆盖它。
|
||||
|
||||
终端仿真器通常获取使用哪种颜色的指令的方式来自于 `LS_COLORS` 环境变量的设置,该设置又由 `dircolors` 的设置填充。你可以使用 `echo` 语句查看当前设置:
|
||||
|
||||
```
|
||||
$ echo $LS_COLORS
|
||||
rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40;
|
||||
38;5;11:so=38;5;13:do=38;5;5:bd=48;5;
|
||||
232;38;5;11:cd=48;5;232;38;5;3:or=48;
|
||||
5;232;38;5;9:mi=01;05;37;41:su=48;5;
|
||||
196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;
|
||||
196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;
|
||||
[...]
|
||||
```
|
||||
|
||||
或者你可以直接使用 `dircolors`:
|
||||
|
||||
```
|
||||
$ dircolors --print-database
|
||||
[...]
|
||||
# image formats
|
||||
.jpg 01;35
|
||||
.jpeg 01;35
|
||||
.mjpg 01;35
|
||||
.mjpeg 01;35
|
||||
.gif 01;35
|
||||
.bmp 01;35
|
||||
.pbm 01;35
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
[...]
|
||||
```
|
||||
|
||||
这看起来很神秘。文件类型后面的第一个数字是属性代码,它有六种选择:
|
||||
|
||||
* 00 无
|
||||
* 01 粗体
|
||||
* 04 下划线
|
||||
* 05 闪烁
|
||||
* 07 反白
|
||||
* 08 暗色
|
||||
|
||||
下一个数字是简化形式的颜色代码。你可以通过获取 ANSI 代码的最后一个数字来获取颜色代码(绿色前景为 32,绿色背景为 42;红色为 31 或 41,依此类推)。
|
||||
|
||||
你的发行版可能全局设置了 `LS_COLORS`,因此系统上的所有用户都会继承相同的颜色。如果你想要一组自定义的颜色,可以使用 `dircolors`。首先,生成颜色设置的本地副本:
|
||||
|
||||
```
|
||||
$ dircolors --print-database > ~/.dircolors
|
||||
```
|
||||
|
||||
根据需要编辑本地列表。如果你对自己的选择感到满意,请保存文件。你的颜色设置只是一个数据库,不能由 [ls][3] 直接使用,但你可以使用 `dircolors` 获取可用于设置 `LS_COLORS` 的 shellcode:
|
||||
|
||||
```
|
||||
$ dircolors --bourne-shell ~/.dircolors
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:
|
||||
pi=40;33:so=01;35:do=01;35:bd=40;33;01:
|
||||
cd=40;33;01:or=40;31;01:mi=00:su=37;41:
|
||||
sg=30;43:ca=30;41:tw=30;42:ow=34;
|
||||
[...]
|
||||
export LS_COLORS
|
||||
```
|
||||
|
||||
将输出复制并粘贴到 `~/.bashrc` 文件中并重新加载。或者,你可以将该输出直接转储到 `.bashrc` 文件中并重新加载。
|
||||
|
||||
```
|
||||
$ dircolors --bourne-shell ~/.dircolors >> ~/.bashrc
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
你也可以在启动时使 Bash 解析 `.dircolors` 而不是手动进行转换。实际上,你可能不会经常改变颜色,所以这可能过于激进,但如果你打算改变你的配色方案,这是一个选择。在 `.bashrc` 文件中,添加以下规则:
|
||||
|
||||
```
|
||||
[[ -e $HOME/.dircolors ]] && eval "`dircolors --sh $HOME/.dircolors`"
|
||||
```
|
||||
|
||||
如果你的主目录中有 `.dircolors` 文件,Bash 会在启动时对其进行评估并相应地设置 `LS_COLORS`。
|
||||
|
||||
### 颜色
|
||||
|
||||
在终端中使用颜色是一种可以为你自己提供特定信息的快速视觉参考的简单方法。但是,你可能不希望过于依赖它们。毕竟,颜色不是通用的,所以如果其他人使用你的系统,他们可能不会像你那样看懂颜色代表的含义。此外,如果你使用各种工具与计算机进行交互,你可能还会发现某些终端或远程连接无法提供你期望的颜色(或根本不提供颜色)。
|
||||
|
||||
除了上述警示之外,颜色在某些工作流程中可能很有用且很有趣,因此创建一个 `.dircolor` 数据库并根据你的想法对其进行自定义吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/linux-terminal-colors
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos.png?itok=aOBLy7Ky (4 different color terminal windows with code)
|
||||
[2]: https://opensource.com/article/19/8/what-are-environment-variables
|
||||
[3]: https://opensource.com/article/19/7/master-ls-command
|
||||
@@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
@@ -1,614 +0,0 @@
|
||||
qfzy1233 is translating
|
||||
|
||||
|
||||
|
||||
数码文件与文件夹收纳术(以照片为例)
|
||||
======
|
||||
更新 2014-05-14:增加了一些具体实例
|
||||
|
||||
更新 2015-03-16:根据照片的 GPS 坐标过滤图片
|
||||
|
||||
更新 2016-08-29:以新的 `filetags--filter` (LCTT译注:文件标签过滤器)替换已经过时的 `show-sel.sh` 脚本(LCTT译注:show-sel 为 show firmware System Event Log records 即硬件系统事件及日志显示)
|
||||
|
||||
Update 2017-08-28: Email comment on geeqie video thumbnails
|
||||
更新 2017-08-28:
|
||||
I am a passionate photographer when being on vacation or whenever I see something beautiful. This way, I collected many [JPEG][1] files over the past years. Here, I describe how I manage my digital photographs while avoiding any [vendor lock-in][2] which binds me to a temporary solution and leads to loss of data. Instead, I prefer solutions where I am able to **invest my time and effort for a long-term relationship**.
|
||||
|
||||
This (very long) entry is **not about image files only** : I am going to explain further things like my folder hierarchy, file name convention, and so forth. Therefore, this information applies to all kind of files I process.
|
||||
|
||||
Before I start explaining my method, we should come to an agreement whether or not we do have the same set of requirements I am trying to match with my method. If you are into [raw image formats][3], storing your photographs somewhere in the cloud or anything else very special to you (and not to me), you might not get satisfied with the things described here. Decide yourself.
|
||||
|
||||
### My requirements
|
||||
|
||||
For **getting the photographs (and movies) from my digital camera to my computer** , I just want to put the SD card into my computer and invoke the fetch-workflow. This thing also has to **pre-process the files** to meet my file name convention (described further down) and to rotate images that are in portrait orientation (and not in landscape).
|
||||
|
||||
Those files are written to my photography inbox folder `$HOME/tmp/digicam/`. In this folder, I want to **look through my image files and play movies** to **sort out/delete, rename, add/remove tags, and put sets of related files into separate destination folders**.
|
||||
|
||||
After that, I want to **navigate through my set of folders** containing the sets of image/movie files. In rare occasions, I want to **open an image file in an independent image processing tool** like [the GIMP][4]. Just for **rotating JPEG files** , I want to have a quick method which does not require an image processing tool and which is rotating JPEG images [in a loss-less way][5].
|
||||
|
||||
My digital camera has now support for tagging images with [GPS][6] coordinates. Therefore, I need a method to **visualize GPS coordinates for single files as well as for a set of files** showing the path I was walking.
|
||||
|
||||
There is another nice feature I want to use: imagine a beautiful vacation in Venice where you took hundreds of photographs. Each of them is so beautiful so that you do not want to delete some of them. On the other side, you might want to get a smaller set of photographs for presenting to your friends at home. And they are only expecting maybe two dozens of files before being too jealous. Therefore, I want to be able to **define and show a certain sub-set of photos**.
|
||||
|
||||
In terms of being independent and **avoid lock-in effects** , I do not want to use a tool I am not able to use when a company discontinues a product or service. For the very same reason and because I am a privacy-aware person, **I do not want to use any cloud-based service**. In order to keep myself open for new possibilities, I do not want to invest any effort in something which is only available on one specific operating system platform. **Basic stuff has to be available on any platform** (viewing, navigation, ...). But the **full set of requirements have to work on GNU/Linux** , in my case Debian GNU/Linux.
|
||||
|
||||
Before I describe my current solutions to this fairly large set of requirements mentioned above, I have to explain my general folder structure and file naming convention I also use for digital photographs. But first, there is an important fact you have to consider:
|
||||
|
||||
#### iPhoto, Picasa, and such considered harmful
|
||||
|
||||
Software tools which manage collections of photographs do provide pretty cool features. They offer a nice user interface and try to give you cozy work-flows for all kinds of requirements.
|
||||
|
||||
The big issue I do have got with them is numerous. They mostly use proprietary storage formats for almost everything: image files, meta-data, and so forth. This is a huge issue, when you are going to change to a different software in a couple of years. Trust me: **you are going to switch** , some day, in any case, for multiple reasons.
|
||||
|
||||
If you are in the position where you need to switch your tool, you are going to realize that iPhoto or Picasa do store original image files and everything you did to them separately. Rotation of images, adding description to image files, tags, cropping, and so forth: **everything will be lost forever** if you are not able to export it and re-import it to the new tool. Chances are very high that you are not going to do this without loss of information or data.
|
||||
|
||||
I do not want to invest any effort in a tool which locks away my work. **I refuse to lock-in myself to any proprietary tool.** Been there, done that. Learned my lessons.
|
||||
|
||||
This is the reason why I keep time-stamps, image descriptions, or tags in the file name itself. File names are permanent unless I manually change them. They do not get lost when I backup my photographs or when I copy them to USB memory sticks or other operating systems. Everybody is able to read them. Any future system is able to process them.
|
||||
|
||||
### My file name convention
|
||||
|
||||
All my files which do have a relation to a specific day or a time I start with a **date-stamp** or a **time-stamp** according to an adopted [ISO 8601][7].
|
||||
|
||||
Example file name with a date-stamp and two tags: `2014-05-09 Budget export for project 42 -- finance company.csv`
|
||||
|
||||
Example file name with a time-stamp (even including optional seconds) and two tags: `2014-05-09T22.19.58 Susan presenting her new shoes -- family clothing.jpg`
|
||||
|
||||
I have to use adopted ISO time-stamps because colons are not suitable for the Windows [file system NTFS][8]. Therefore, I replaced colons with dots for separating hours from minutes from the optional seconds.
|
||||
|
||||
In case of **time or date duration** , I separate the two date- or time-stamps with two minus signs: "`2014-05-09--2014-05-13 Jazz festival Graz -- folder tourism music.pdf`".
|
||||
|
||||
Time/date-stamps in file names have the advantage that they remain unchanged until I manually change them. Meta-data which is included in the file content itself (like [Exif][9]) tends to get lost when files are processed via tools that do not take care of those meta-data. Additionally, starting a file name with such a date/time-stamp ensures that files are displayed in a temporal order instead of alphabetic order. The alphabet is a [totally artificial sort order][10] and it is typically less practical for locating files by the user.
|
||||
|
||||
When I want to associate **tags** to a file name, I place them between the original file name and the [file name extension][11] separated by a space, two minus signs and an additional space: "`--`". My tags are lower case English words which do not contain spaces or special characters. Sometimes, I might use concatenated words like `quantifiedself` or `usergenerated`. I [tend to prefer general categories][12] instead of more (too) more specific describing tags. I re-use my tags on Twitter [hashtags][13], file names, folder names, bookmarks, blog entries like this one, and so forth.
|
||||
|
||||
Tags as part of the file name have several advantages. You are able to locate files with the help of tags by using your usual desktop search engine. Tags in file-names can not be lost because of copying on different storage media. This usually happens, whenever a system uses a different storage place than the file name: meta-data data-base, [dot-files][14], [alternate data streams][15], and so forth.
|
||||
|
||||
Of course, please do **avoid special characters** , umlauts, colons, and so forth in file and folder names in general. Especially when you synchronize files between different operating system platforms.
|
||||
|
||||
My **file name convention for folders** is the same as for files.
|
||||
|
||||
Note: Because of the clever [filenametimestamps][16]-module of [Memacs][17], all files and folders with a date/time-stamp appear on the very same time/day on my Org-mode calendar (agenda). This way, I get a very cool overview on what happened when on which day including all photographs I took.
|
||||
|
||||
### My general folder structure
|
||||
|
||||
In this section, I will describe my most important folders within my home folder. NOTE: this might get moved to an independent page somewhere in the future. Or not. Time will tell. :-)
|
||||
|
||||
Lots of stuff is only of interest for a certain period of time. These are things like downloads to quickly skim through its content, unpack ZIP files to examine the files contained, minor interesting stuff, and so forth. For **temporary stuff** I do have the `$HOME/tmp/` sub-hierarchy. New photographs are placed in `$HOME/tmp/digicam/`. Stuff I temporary copy from a CD, DVD, or USB memory stick are put in `$HOME/tmp/fromcd/`. Whenever a software tool needs temporary data within my user folder hierarchy, I use `$HOME/tmp/Tools/` as an starting point. A very frequent folder for me is `$HOME/tmp/2del/`: "2del" means "ready for being deleted any time". All my browser are using this folder as the default download folder for example. In case I need to free space on a machine, I firstly look at this `2del`-folder for stuff to delete.
|
||||
|
||||
In contrast to the temporary stuff described above, I certainly want to keep files **for a longer period of time** as well. Those files gets moved to my `$HOME/archive/` sub-hierarchy. Its got several sub-folders for backups, web/download-stuff I want to keep, binary files I want to archive, index files of removable media (CD, DVD, memory sticks, external hard drives), and a folder where I place stuff I want to archive (and look for a decent destination folder) in the near future. Sometimes, I am too busy or impatient for the moment to file things properly. Yes, that's me I even have a "do not bug me now"-folder. Is this weird to you? :-)
|
||||
|
||||
The most important sub-hierarchy within my archive is `$HOME/archive/events_memories/` and its sub/folders `2014/`, `2013/`, `2012/`, and so forth. As you might have guessed already, there is one **sub-folder per year**. Within each of them, there are single files and folders. The files are named according to my file name convention described in the previous section. Folder names start with an [ISO 8601][7] datestamp in the form "YYYY-MM-DD" followed by a hopefully descriptive name like `$HOME/archive/events_memories/2014/2014-05-08 Business marathon with colleagues/`. Within those date-related folders I keep all kinds of files which are related to a certain event: photographs, (scanned) PDF-files, text files, and so forth.
|
||||
|
||||
For **sharing data** , I maintain a `$HOME/share/` sub-hierarchy. There is my Dropbox folder, folders for important people I share data using all kinds of methods (like [unison][18]). I also share data among my set of devices: Mac Mini at home, GNU/Linux notebook at home, Android phone, root-server (my personal cloud), Windows-notebook at work. I don't want to elaborate on my synchronization set-up here. There might be another blog entry for this if you ask nicely. :-)
|
||||
|
||||
Within my `$HOME/templates_labels/` sub-hierarchy, I keep all kinds of **template files** ([LaTeX][19], scripts, ...), cliparts and **logos** , and so forth.
|
||||
|
||||
My **Org-mode** files, I mostly keep within `$HOME/org/`. I practice retentiveness and do not explain how much I love [Emacs/Org-mode][20] and how much I get out of it this time. You probably have read or heard me elaborating the awesome things I do with it. Just look out for [my `emacs` tag][21] on my blog and its [hashtag `#orgmode`][22] on twitter.
|
||||
|
||||
So far about my most important folder sub-hierarchies.
|
||||
|
||||
### My workflows
|
||||
|
||||
Tataaaa, after you learned about my folder structure and file name convention, here are my current workflows and tools I use for the requirements I described further up.
|
||||
|
||||
Please note that **you have to know, what you are doing**. My examples here contain folder paths and more that **only works on my machine or my set-up**. **You have to adopt stuff** like paths, file names, and so forth to meet your requirements!
|
||||
|
||||
#### Workflow: Moving files from my SD card to the laptop, rotating portrait images, and renaming files
|
||||
|
||||
When I want to move data from my digital camera to my GNU/Linux notebook, I take out its Mini-SD storage card and put it in my notebook. Then it gets mounted on `/media/digicam` automatically.
|
||||
|
||||
Then, I invoke [getdigicamdata.sh][23] which does several things: it moves the files from the SD card to a temporary folder for processing. The original file names are being converted to lower-case characters. All portrait photographs are rotated using [jhead][24]. Also with jhead, I generate file-name time-stamps from the Exif header time-stamps. Using [date2name][25] I add time-stamps also to the movie files. After processing all those files, they get moved to the destination folder for new digicam files: $HOME/tmp/digicam/tmp/~.
|
||||
|
||||
#### Workflow: Folder navigation, viewing, renaming, deleting image files
|
||||
|
||||
For skimming through my image and movie files, I prefer to use [geeqie][26] on GNU/Linux. It is a fairly lightweight image browser which has one big advantage other file browsers are missing: I can add external scripts/tools that can be invoked by a keyboard shortcut. This way, I am able to extend the feature-set of the image browser by arbitrary external commands.
|
||||
|
||||
Basic image management functionality is built-in to geeqie: navigating my folder hierarchy, viewing image files in window-mode and in full-screen more (shortcut `f`), renaming file names, deleting files, showing Exif meta-data (shortcut `Ctrl-e`).
|
||||
|
||||
On OS X, I use [Xee][27]. Unlike geeqie, it is not extendable by external commands. However, the basic navigation, viewing, and renaming functions are available as well.
|
||||
|
||||
#### Workflow: Adding and removing tags
|
||||
|
||||
I created a Python script called [filetags][28] which I use for adding and removing tags to single files as well as a set of files.
|
||||
|
||||
For digital photographs, I use tags like, e.g., `specialL` for landscape images that I consider suitable for desktop backgrounds and so forth, `specialP` for portrait photographs I would like to show to others, `sel` for a selection, and many more.
|
||||
|
||||
##### Initial set-up of filetags with geeqie
|
||||
|
||||
Adding filetags to geeqie is a manual step: `Edit > Preferences > Configure Editors ...`. Then create an additional entry with `New`. There, you can define a new desktop-file which looks like this:
|
||||
|
||||
add-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetags
|
||||
GenericName=filetags
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
The wrapper-script `vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh` is necessary because I want a new terminal window to pop-up in order to add tags to my files:
|
||||
|
||||
vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --interactive "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
In geeqie, you can add a keyboard shortcut in `Edit > Preferences > Preferences ... > Keyboard`. I associated `t` with the `filetags` command.
|
||||
|
||||
The filetags script is also able to remove tags from a single file or a set of files. It basically uses the same method as described above. The only difference is the additional `--remove` parameter for the filetags script:
|
||||
|
||||
remove-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetags-remove
|
||||
GenericName=filetags-remove
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --interactive --remove "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
For removing tags, I created a keyboard shortcut for `T`.
|
||||
|
||||
##### Using filetags within geeqie
|
||||
|
||||
When I skim though image files in the geeqie file browser, I select files I want to tag (one to many) and press `t`. Then, a small window pops up and asks me for one or more tags. After confirming with `Return`, these tags gets added to the file names.
|
||||
|
||||
The same goes for removing tags: selecting multiple files, pressing `T`, entering tags to be removed, and confirming with `Return`. That's it. There is [almost no simpler way to add or remove tags to files][29].
|
||||
|
||||
#### Workflow: Advanced file renaming with appendfilename
|
||||
|
||||
##### Without appendfilename
|
||||
|
||||
Renaming a large set of files can be a tedious process. With original file names like `2014-04-20T17.09.11_p1100386.jpg`, the process to add a description to its file name is quite annoying. You are going to press `Ctrl-r` (rename) in geeqie which opens the file rename dialog. The base-name (file-name without the file extension) is marked by default. So if you do not want to delete/overwrite the file name (but append to it), you have to press the cursor key for `<right>`. Then, the cursor is placed between the base name and the extension. Type in your description (don't forget the initial space character) and confirm with `Return`.
|
||||
|
||||
##### Using appendfilename with geeqie
|
||||
|
||||
With [appendfilename][30], my process is simplified to gain maximum user experience for appending text to file names: When I press `a` (append) in geeqie, a dialog window pops up, asking for a text. After confirming with `Return`, the entered text gets placed between the time-stamp and the optional tags.
|
||||
|
||||
For example when I press `a` on `2014-04-20T17.09.11_p1100386.jpg` and I type `Pick-nick in Graz`, the file name gets changed to `2014-04-20T17.09.11_p1100386 Pick-nick in Graz.jpg`. When I press `a` once again and enter `with Susan`, the file name gets changed to `2014-04-20T17.09.11_p1100386 Pick-nick in Graz with Susan.jpg`. When the file name got tags as well, the appended text gets appended before the tag-separator.
|
||||
|
||||
This way, I do not have to be afraid to overwrite time-stamps or tags. The process for renaming gets much more enjoyable for me!
|
||||
|
||||
And the best part: when I want to add the same text to multiple selected files, this also works with appendfilename.
|
||||
|
||||
##### Initial set-up of appendfilename with geeqie
|
||||
|
||||
Add an additional editor to geeqie: `Edit > Preferences > Configure Editors ... > New`. Then enter the desktop file definition:
|
||||
|
||||
appendfilename.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=appendfilename
|
||||
GenericName=appendfilename
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
Once again, I do use a wrapper-script that provides me the terminal window:
|
||||
|
||||
vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=90x5+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/appendfilename/appendfilename.py "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
#### Workflow: Play movie files
|
||||
|
||||
On GNU/Linux, I use [mplayer][31] to play-back video files. Since geeqie does not play movie files on itself, I have to create a set-up where I can open a movie file in mplayer.
|
||||
|
||||
##### Initial set-up of mplayer with geeqie
|
||||
|
||||
I did already associate movie file extensions to mplayer using [xdg-open][32]. Therefore, I only had to create a general "open" command to geeqie which uses xdg-open to open any file with its associated application.
|
||||
|
||||
Once again, visit `Edit > Preferences > Configure Editors ...` in geeqie and add an entry for `open`:
|
||||
|
||||
open.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=open
|
||||
GenericName=open
|
||||
Comment=
|
||||
Exec=/usr/bin/xdg-open %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
hidden=false
|
||||
NOMimeType=*;
|
||||
MimeType=image/*;video/*
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
When you also associate the shortcut `o` (see above) to geeqie, you are able to open video files (and other files) with their associated application.
|
||||
|
||||
##### Opening movie files (and others) with xdg-open
|
||||
|
||||
After the set-up process from above, you just have to press `o` when your geeqie cursor is above the file. That's it.
|
||||
|
||||
#### Workflow: Open in an external image editor
|
||||
|
||||
I rarely want to be able to quickly edit image files in the GIMP. Therefore, I added a shortcut `g` and associated it with the external editor "GNU Image Manipulation Program" (GIMP) which was already created by default by geeqie.
|
||||
|
||||
This way, only pressing `g` opens the current image file in the GIMP.
|
||||
|
||||
#### Workflow: Move to archive folder
|
||||
|
||||
Now that I have added comments to my file names, I want to move single files to `$HOME/archive/events_memories/2014/` or set of files to new folders within this folder like `$HOME/archive/events_memories/2014/2014-05-08 Business-Marathon After-Show-Party`.
|
||||
|
||||
The usual way is to select one or multiple files and move them to a folder with the shortcut `Ctrl-m`.
|
||||
|
||||
So booooring.
|
||||
|
||||
Therefore, I (again) wrote a Python script which does this job for me: [move2archive][33] (in short: `m2a`) expects one or more files as command line parameters. Then, a dialog appears where I am able to enter an optional folder name. When I do not enter anything at all but press `Return`, the files gets moved to the folder of the corresponding year. When I enter a folder name like `Business-Marathon After-Show-Party`, the date-stamp of the first image file is appended to the folder (`$HOME/archive/events_memories/2014/2014-05-08 Business-Marathon After-Show-Party`), the resulting folder gets created, and the files gets moved.
|
||||
|
||||
Once again: I am in geeqie, select one or more files, press `m` (move) and either press only `Return` (no special sub-folder) or enter a descriptive text which is the name of the sub-folder to be created (optionally without date-stamp).
|
||||
|
||||
**No image managing tool is as quick and as fun to use as my geeqie with appendfilename and move2archive via shotcuts.**
|
||||
|
||||
##### Initial set-up of m2a with geeqie
|
||||
|
||||
Once again, adding `m2a` to geeqie is a manual step: `Edit > Preferences > Configure Editors ...`. Then create an additional entry with `New`. There, you can define a new desktop-file which looks like this:
|
||||
|
||||
m2a.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=move2archive
|
||||
GenericName=move2archive
|
||||
Comment=Moving one or more files to my archive folder
|
||||
Exec=/home/vk/src/misc/vk-m2a-interactive-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
The wrapper-script `vk-m2a-interactive-wrapper-with-gnome-terminal.sh` is necessary because I want a new terminal window to pop-up in order to enter my desired destination folder for my files:
|
||||
|
||||
vk-m2a-interactive-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=157x56+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/m2a/m2a.py --pauseonexit "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
In geeqie, you can add a keyboard shortcut in `Edit > Preferences > Preferences ... > Keyboard`. I associated `m` with the `m2a` command.
|
||||
|
||||
#### Workflow: Rotate images (loss-less)
|
||||
|
||||
Usually, portrait photographs are being marked automatically as portrait photographs by my digital camera. However, there are certain situations (like taking a photograph from above the motif) where my camera gets it wrong. In those **rare cases** , I have to manually fix the orientation.
|
||||
|
||||
You have to know that the JPEG file format is a lossy format which should be used only for photographs and not for computer-generated stuff like screen-shots or diagrams. Rotating a JPEG image file in the dumb way usually results in decompressing/visualizing the image file, rotating the resulting image, and re-encoding the result once again. This causes a resulting image with [much worse image quality than the original image][5].
|
||||
|
||||
Therefore, you should use a lossless method to rotate you JPEG image files.
|
||||
|
||||
Once again, I add an "external editor" to geeqie: `Edit > Preferences > Configure Editors ... > New`. There, I add two entries: one for rotating 270 degrees (which is 90 degrees counter-clock-wise) and one for rotating 90 degrees (clock-wise) using [exiftran][34]:
|
||||
|
||||
rotate-270.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=Losslessly rotate JPEG image counterclockwise
|
||||
|
||||
# call the helper script
|
||||
TryExec=exiftran
|
||||
Exec=exiftran -p -2 -i -g %f
|
||||
|
||||
# Desktop files that are usable only in Geeqie should be marked like this:
|
||||
Categories=X-Geeqie;
|
||||
OnlyShowIn=X-Geeqie;
|
||||
|
||||
# Show in menu "Edit/Orientation"
|
||||
X-Geeqie-Menu-Path=EditMenu/OrientationMenu
|
||||
|
||||
MimeType=image/jpeg;
|
||||
|
||||
```
|
||||
|
||||
rotate-90.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=Losslessly rotate JPEG image clockwise
|
||||
|
||||
# call the helper script
|
||||
TryExec=exiftran
|
||||
Exec=exiftran -p -9 -i -g %f
|
||||
|
||||
# Desktop files that are usable only in Geeqie should be marked like this:
|
||||
Categories=X-Geeqie;
|
||||
OnlyShowIn=X-Geeqie;
|
||||
|
||||
# Show in menu "Edit/Orientation"
|
||||
X-Geeqie-Menu-Path=EditMenu/OrientationMenu
|
||||
|
||||
# It can be made verbose
|
||||
# X-Geeqie-Verbose=true
|
||||
|
||||
MimeType=image/jpeg;
|
||||
|
||||
```
|
||||
|
||||
I created geeqie keyboard shortcuts for `[` (counter-clock-wise) and `]` (clock-wise).
|
||||
|
||||
#### Workflow: Visualizing GPS coordinates
|
||||
|
||||
My digital camera has a GPS sensor which stores the current geographic location within the Exif meta-data of the JPEG files. The location data gets stored in [WGS 84][35] format like "47, 58, 26.73; 16, 23, 55.51" (latitude; longitude). This is not human-readable in the sense I would expect: either a map or a location name. Therefore, I added functionality to geeqie so, that I am able to see the location of a single image file on [OpenStreetMap][36]: `Edit > Preferences > Configure Editors ... > New`
|
||||
|
||||
photolocation.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=vkphotolocation
|
||||
GenericName=vkphotolocation
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vkphotolocation.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-gray;image/x-icb;image/x-ico;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-xbitmap;image/x-xpixmap;image/x-pcx;image/svg+xml;image/svg+xml-compressed;image/vnd.wap.wbmp;
|
||||
|
||||
```
|
||||
|
||||
This calls my wrapper-script named `vkphotolocation.sh` which uses [ExifTool][37] to extract the coordinates in a suitable format that [Marble][38] is able to read and visualize:
|
||||
|
||||
vkphotolocation.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
IMAGEFILE="${1}"
|
||||
IMAGEFILEBASENAME=`basename ${IMAGEFILE}`
|
||||
|
||||
COORDINATES=`exiftool -c %.6f "${IMAGEFILE}" | awk '/GPS Position/ { print $4 " " $6 }'`
|
||||
|
||||
if [ "x${COORDINATES}" = "x" ]; then
|
||||
zenity --info --title="${IMAGEFILEBASENAME}" --text="No GPS-location found in the image file."
|
||||
else
|
||||
/usr/bin/marble --latlon "${COORDINATES}" --distance 0.5
|
||||
fi
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
Mapped to the keyboard shortcut `G`, I can quickly get to the **map position of its location of a single image file**.
|
||||
|
||||
When I want to visualize the **positions of multiple JPEG image files as a path** , I am using [GpsPrune][39]. I was not able to derive a method where GpsPrune takes a set of files as command line parameters. And because of this, I have to manually start GpsPrune, select a set of files or a folder with `File > Add photos`.
|
||||
|
||||
This way, I get a dot for each JPEG location on a map of OpenStreetMap (if configured so). By clicking on such a dot, I get details of the corresponding image.
|
||||
|
||||
If you happen to be abroad while taking photographs, visualizing the GPS positions is a **great help for adding descriptions** to the file name!
|
||||
|
||||
#### Workflow: Filtering photographs according to their GPS coordinates
|
||||
|
||||
This is no workflow of mine. For the sake of completeness, I list features of tools that make this workflow possible. What I would like to do is looking for only those photographs out of a big pile of images, that are within a certain area (rectangle or point + distance).
|
||||
|
||||
So far, I found only [DigiKam][40] which is able to [filter according to a rectangle][41]. If you know another tool, please add it to the comments below or write an email.
|
||||
|
||||
#### Workflow: Showing a sub-set of a given set
|
||||
|
||||
As described in the requirements above, I want to be able to define a sub-set of files within a folder in order to present this small collection to other people.
|
||||
|
||||
The work-flow is pretty simple: I add a tag (via `t`/filetags) to the files of the selection. For this, I use the tag `sel` which is short for "selection". After I tagged the set of files, I can press `s` which I associated with a script that shows only the files tagged with `sel`.
|
||||
|
||||
Of course, this also works with any tag or tag combination. Therefore, with the same method, you are able to get a decent overview on all photos of your wedding that are tagged with "church" and "rings".
|
||||
|
||||
Nifty feature, isn't it? :-)
|
||||
|
||||
##### Initial set-up of filetags for filtering according to tags + geeqie
|
||||
|
||||
You have to define an additional "external editor": `Edit > Preferences > Configure Editors ... > New`:
|
||||
|
||||
filter-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetag-filter
|
||||
GenericName=filetag-filter
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetag-filter-wrapper-with-gnome-terminal.sh
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
This once again calls a wrapper-script I wrote:
|
||||
|
||||
vk-filetag-filter-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --filter
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
What `filetags` with parameter `--filter` does is basically the following: the user gets asked to enter one or more tags. Then, all matching files of the current folder are linked to `$HOME/.filetags_tagfilter/` using [symbolic links][42]. Then, a new geeqie instance is started which shows the linked files.
|
||||
|
||||
After quitting this new geeqie instance, you see the old geeqie instance, from where you invoked the selection process.
|
||||
|
||||
#### Summary with a real world example
|
||||
|
||||
Wow, this was a very long blog entry. No wonder that you might have lost the overview here and there. To sum up the things I am able to do within geeqie (that extends the standard feature set), I have this cool table below:
|
||||
|
||||
shortcut function `m` m2a `o` open (for non-images) `a` add text to file name `t` filetags (add) `T` filetags (remove) `s` filetags (filter) `g` gimp `G` show GPS position `[` lossless rotate counterclockwise `]` lossless rotate clockwise `Ctrl-e` EXIF `f` full-screen
|
||||
|
||||
Parts of a file name (including its path) and tools I use to manipulate the components accordingly:
|
||||
```
|
||||
/this/is/a/folder/2014-04-20T17.09 Pick-nick in Graz -- food graz.jpg
|
||||
[ m2a ] [ date2name ] [ appendfilename ] [filetags]
|
||||
|
||||
```
|
||||
|
||||
In practice, I do the following steps to get my photographs from the camera to my archive: I put the SD memory card into my SD card reader of my computer. Then I start [getdigicamdata.sh][23]. After it is finished, I open `$HOME/tmp/digicam/tmp/` within geeqie. I skim through the photographs and delete the ones that did not work out. If there is an image with the wrong orientation, I correct it by `[` or `]`.
|
||||
|
||||
In a second run, I add descriptions to files I consider worth commenting on (`a`). Whenever I want to add tags I do so as well: I quickly mark all files that should share a tag (`Ctrl` \+ mouse-click) and tag them using [filetags][28] (`t`).
|
||||
|
||||
To combine files from a given event, I select corresponding files and move them to their "event-folder" within the yearly archive folder by typing the event description in [move2archive][33] (`m`). The rest (no special event folder) is moved to the yearly archive directly by move2archive (`m`) without stating a event description.
|
||||
|
||||
To finish my work-flow, I delete all files on my SD card, dismount it from the operating system, and put it back into my digital camera.
|
||||
|
||||
That's it.
|
||||
|
||||
Because this work-flow requires almost no overhead at all, commenting, tagging, and filing photographs is not a tedious job any more.
|
||||
|
||||
### Finally
|
||||
|
||||
So, this is a detailed description of my work-flows related to photographs and movies I make. You probably have found additional stuff I might be interested in. So please do not hesitate and leave a comment or email by using the links below.
|
||||
|
||||
I also would like to get feed-back if my work-flow works for you as well. And: if you have published your work-flows or find descriptions of other peoples work-flows, please do leave a comment as well!
|
||||
|
||||
Have fun and don't waste your time with the wrong tools or inefficient methods!
|
||||
|
||||
### Other Tools
|
||||
|
||||
Read about [gThumb in this article][43].
|
||||
|
||||
Please do suggest your tools of choice when you've got the feeling that they fit my requirements mentioned above.
|
||||
|
||||
### Email Comments
|
||||
|
||||
> Date: Sat, 26 Aug 2017 22:05:09 +0200
|
||||
> Hello Karl,
|
||||
> I like your articles and work with memacs and of course orgmode but I am not very familiar with python by the way... in your blog post of "managing-digital-photographs" you write about to open videos with [Geeqie][26].
|
||||
> It works, but I cant see any video thumbnails in the browser of Geeqie. Do you have any suggestions to get this to work?
|
||||
> Thank you, Thomas
|
||||
|
||||
Hi Thomas,
|
||||
|
||||
Thanks for your kind words. I always feel great when somebody finds my work useful in his/her life. Unfortunately most of the time, I never hear of them.
|
||||
|
||||
Yes, I sometimes use Geeqie to visualize folders that not only contain image files but movie files as well. In those cases, I don't see any thumbnail image of the video. You're absolutely right, there are many file browsers out there which are able to display some kind of preview image of a video.
|
||||
|
||||
Quite frankly, I never thought of video thumbnails and I don't miss them. A quick research in the preferences and with my search engine did not suggest that there is a possible way to enable video previews in Geeqie. So no luck here.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://karl-voit.at/managing-digital-photographs/
|
||||
|
||||
作者:[Karl Voit][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://karl-voit.at
|
||||
[1]:https://en.wikipedia.org/wiki/Jpeg
|
||||
[2]:http://en.wikipedia.org/wiki/Vendor_lock-in
|
||||
[3]:https://en.wikipedia.org/wiki/Raw_image_format
|
||||
[4]:http://www.gimp.org/
|
||||
[5]:http://petapixel.com/2012/08/14/why-you-should-always-rotate-original-jpeg-photos-losslessly/
|
||||
[6]:https://en.wikipedia.org/wiki/Gps
|
||||
[7]:https://en.wikipedia.org/wiki/Iso_date
|
||||
[8]:https://en.wikipedia.org/wiki/Ntfs
|
||||
[9]:https://en.wikipedia.org/wiki/Exif
|
||||
[10]:http://www.isisinform.com/reinventing-knowledge-the-medieval-controversy-of-alphabetical-order/
|
||||
[11]:https://en.wikipedia.org/wiki/File_name_extension
|
||||
[12]:http://karl-voit.at/tagstore/en/papers.shtml
|
||||
[13]:https://en.wikipedia.org/wiki/Hashtag
|
||||
[14]:https://en.wikipedia.org/wiki/Dot-file
|
||||
[15]:https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_.28ADS.29
|
||||
[16]:https://github.com/novoid/Memacs/blob/master/docs/memacs_filenametimestamps.org
|
||||
[17]:https://github.com/novoid/Memacs
|
||||
[18]:http://www.cis.upenn.edu/~bcpierce/unison/
|
||||
[19]:https://github.com/novoid/LaTeX-KOMA-template
|
||||
[20]:http://orgmode.org/
|
||||
[21]:http://karl-voit.at/tags/emacs
|
||||
[22]:https://twitter.com/search?q%3D%2523orgmode&src%3Dtypd
|
||||
[23]:https://github.com/novoid/getdigicamdata.sh
|
||||
[24]:http://www.sentex.net/%3Ccode%3Emwandel/jhead/
|
||||
[25]:https://github.com/novoid/date2name
|
||||
[26]:http://geeqie.sourceforge.net/
|
||||
[27]:http://xee.c3.cx/
|
||||
[28]:https://github.com/novoid/filetag
|
||||
[29]:http://karl-voit.at/tagstore/
|
||||
[30]:https://github.com/novoid/appendfilename
|
||||
[31]:http://www.mplayerhq.hu
|
||||
[32]:https://wiki.archlinux.org/index.php/xdg-open
|
||||
[33]:https://github.com/novoid/move2archive
|
||||
[34]:http://manpages.ubuntu.com/manpages/raring/man1/exiftran.1.html
|
||||
[35]:https://en.wikipedia.org/wiki/WGS84#A_new_World_Geodetic_System:_WGS_84
|
||||
[36]:http://www.openstreetmap.org/
|
||||
[37]:http://www.sno.phy.queensu.ca/~phil/exiftool/
|
||||
[38]:http://userbase.kde.org/Marble/Tracking
|
||||
[39]:http://activityworkshop.net/software/gpsprune/
|
||||
[40]:https://en.wikipedia.org/wiki/DigiKam
|
||||
[41]:https://docs.kde.org/development/en/extragear-graphics/digikam/using-kapp.html#idp7659904
|
||||
[42]:https://en.wikipedia.org/wiki/Symbolic_link
|
||||
[43]:http://karl-voit.at/2017/02/19/gthumb
|
||||
@@ -0,0 +1,266 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How writers can get work done better with Git)
|
||||
[#]: via: (https://opensource.com/article/19/4/write-git)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/noreplyhttps://opensource.com/users/seth)
|
||||
|
||||
How writers can get work done better with Git
|
||||
======
|
||||
If you're a writer, you could probably benefit from using Git. Learn how
|
||||
in our series about little-known uses of Git.
|
||||
![Writing Hand][1]
|
||||
|
||||
[Git][2] is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for many other applications. While it's best-known for tracking source code changes in software development, it has many other uses that can make your life easier and more organized. In this series leading up to Git's 14th anniversary on April 7, we'll share seven little-known ways to use Git. Today, we'll look at ways writers can use Git to get work done.
|
||||
|
||||
### Git for writers
|
||||
|
||||
Some people write fiction; others write academic papers, poetry, screenplays, technical manuals, or articles about open source. Many do a little of each. The common thread is that if you're a writer, you could probably benefit from using Git. While Git is famously a highly technical tool used by computer programmers, it's ideal for the modern author, and this article will demonstrate how it can change the way you write—and why you'd want it to.
|
||||
|
||||
Before talking about Git, though, it's important to talk about what _copy_ (or _content_ , for the digital age) really is, and why it's different from your delivery _medium_. It's the 21 st century, and the tool of choice for most writers is a computer. While computers are deceptively good at combining processes like copy editing and layout, writers are (re)discovering that separating content from style is a good idea, after all. That means you should be writing on a computer like it's a typewriter, not a word processor. In computer lingo, that means writing in _plaintext_.
|
||||
|
||||
### Writing in plaintext
|
||||
|
||||
It used to be a safe assumption that you knew what market you were writing for. You wrote content for a book, or a website, or a software manual. These days, though, the market's flattened: you might decide to use content you write for a website in a printed book project, and the printed book might release an EPUB version later. And in the case of digital editions of your content, the person reading your content is in ultimate control: they may read your words on the website where you published them, or they might click on Firefox's excellent [Reader View][3], or they might print to physical paper, or they could dump the web page to a text file with Lynx, or they may not see your content at all because they use a screen reader.
|
||||
|
||||
It makes sense to write your words as words, leaving the delivery to the publishers. Even if you are also your own publisher, treating your words as a kind of source code for your writing is a smarter and more efficient way to work, because when it comes time to publish, you can use the same source (your plaintext) to generate output appropriate to your target (PDF for print, EPUB for e-books, HTML for websites, and so on).
|
||||
|
||||
Writing in plaintext not only means you don't have to worry about layout or how your text is styled, but you also no longer require specialized tools. Anything that can produce text becomes a valid "word processor" for you, whether it's a basic notepad app on your mobile or tablet, the text editor that came bundled with your computer, or a free editor you download from the internet. You can write on practically any device, no matter where you are or what you're doing, and the text you produce integrates perfectly with your project, no modification required.
|
||||
|
||||
And, conveniently, Git specializes in managing plaintext.
|
||||
|
||||
### The Atom editor
|
||||
|
||||
When you write in plaintext, a word processor is overkill. Using a text editor is easier because text editors don't try to "helpfully" restructure your input. It lets you type the words in your head onto the screen, no interference. Better still, text editors are often designed around a plugin architecture, such that the application itself is woefully basic (it edits text), but you can build an environment around it to meet your every need.
|
||||
|
||||
A great example of this design philosophy is the [Atom][4] editor. It's a cross-platform text editor with built-in Git integration. If you're new to working in plaintext and new to Git, Atom is the easiest way to get started.
|
||||
|
||||
#### Install Git and Atom
|
||||
|
||||
First, make sure you have Git installed on your system. If you run Linux or BSD, Git is available in your software repository or ports tree. The command you use will vary depending on your distribution; on Fedora, for instance:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install git`
|
||||
```
|
||||
|
||||
You can also download and install Git for [Mac][5] and [Windows][6].
|
||||
|
||||
You won't need to use Git directly, because Atom serves as your Git interface. Installing Atom is the next step.
|
||||
|
||||
If you're on Linux, install Atom from your software repository through your software installer or the appropriate command, such as:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install atom`
|
||||
```
|
||||
|
||||
Atom does not currently build on BSD. However, there are very good alternatives available, such as [GNU Emacs][7]. For Mac and Windows users, you can find installers on the [Atom website][4].
|
||||
|
||||
Once your installs are done, launch the Atom editor.
|
||||
|
||||
#### A quick tour
|
||||
|
||||
If you're going to live in plaintext and Git, you need to get comfortable with your editor. Atom's user interface may be more dynamic than what you are used to. You can think of it more like Firefox or Chrome than as a word processor, in fact, because it has tabs and panels that can be opened and closed as they are needed, and it even has add-ons that you can install and configure. It's not practical to try to cover all of Atom's many features, but you can at least get familiar with what's possible.
|
||||
|
||||
When Atom opens, it displays a welcome screen. If nothing else, this screen is a good introduction to Atom's tabbed interface. You can close the welcome screens by clicking the "close" icons on the tabs at the top of the Atom window and create a new file using **File > New File**.
|
||||
|
||||
Working in plaintext is a little different than working in a word processor, so here are some tips for writing content in a way that a human can connect with and that Git and computers can parse, track, and convert.
|
||||
|
||||
#### Write in Markdown
|
||||
|
||||
These days, when people talk about plaintext, mostly they mean Markdown. Markdown is more of a style than a format, meaning that it intends to provide a predictable structure to your text so computers can detect natural patterns and convert the text intelligently. Markdown has many definitions, but the best technical definition and cheatsheet is on [CommonMark's website][8].
|
||||
|
||||
|
||||
```
|
||||
# Chapter 1
|
||||
|
||||
This is a paragraph with an *italic* word and a **bold** word in it.
|
||||
And it can even reference an image.
|
||||
|
||||

|
||||
```
|
||||
|
||||
As you can tell from the example, Markdown isn't meant to read or feel like code, but it can be treated as code. If you follow the expectations of Markdown defined by CommonMark, then you can reliably convert, with just one click of a button, your writing from Markdown to .docx, .epub, .html, MediaWiki, .odt, .pdf, .rtf, and a dozen other formats _without_ loss of formatting.
|
||||
|
||||
You can think of Markdown a little like a word processor's styles. If you've ever written for a publisher with a set of styles that govern what chapter titles and section headings look like, this is basically the same thing, except that instead of selecting a style from a drop-down menu, you're adding little notations to your text. These notations look natural to any modern reader who's used to "txt speak," but are swapped out with fancy text stylings when the text is rendered. It is, in fact, what word processors secretly do behind the scenes. The word processor shows bold text, but if you could see the code generated to make your text bold, it would be a lot like Markdown (actually it's the far more complex XML). With Markdown, that barrier is removed, which looks scarier on the one hand, but on the other hand, you can write Markdown on literally anything that generates text without losing any formatting information.
|
||||
|
||||
The popular file extension for Markdown files is .md. If you're on a platform that doesn't know what a .md file is, you can associate the extension to Atom manually or else just use the universal .txt extension. The file extension doesn't change the nature of the file; it just changes how your computer decides what to do with it. Atom and some platforms are smart enough to know that a file is plaintext no matter what extension you give it.
|
||||
|
||||
#### Live preview
|
||||
|
||||
Atom features the **Markdown Preview** plugin, which shows you both the plain Markdown you're writing and the way it will (commonly) render.
|
||||
|
||||
![Atom's preview screen][9]
|
||||
|
||||
To activate this preview pane, select **Packages > Markdown Preview > Toggle Preview** or press **Ctrl+Shift+M**.
|
||||
|
||||
This view provides you with the best of both worlds. You get to write without the burden of styling your text, but you also get to see a common example of what your text will look like, at least in a typical digital format. Of course, the point is that you can't control how your text is ultimately rendered, so don't be tempted to adjust your Markdown to force your render preview to look a certain way.
|
||||
|
||||
#### One sentence per line
|
||||
|
||||
Your high school writing teacher doesn't ever have to see your Markdown.
|
||||
|
||||
It won't come naturally at first, but maintaining one sentence per line makes more sense in the digital world. Markdown ignores single line breaks (when you've pressed the Return or Enter key) and only creates a new paragraph after a single blank line.
|
||||
|
||||
![Writing in Atom][10]
|
||||
|
||||
The advantage of writing one sentence per line is that your work is easier to track. That is, if you've changed one word at the start of a paragraph, then it's easy for Atom, Git, or any application to highlight that change in a meaningful way if the change is limited to one line rather than one word in a long paragraph. In other words, a change to one sentence should only affect that sentence, not the whole paragraph.
|
||||
|
||||
You might be thinking, "many word processors track changes, too, and they can highlight a single word that's changed." But those revision trackers are bound to the interface of that word processor, which means you can't look through revisions without being in front of that word processor. In a plaintext workflow, you can review revisions in plaintext, which means you can make or approve edits no matter what you have on hand, as long as that device can deal with plaintext (and most of them can).
|
||||
|
||||
Writers admittedly don't usually think in terms of line numbers, but it's a useful tool for computers, and ultimately a great reference point in general. Atom numbers the lines of your text document by default. A _line_ is only a line once you have pressed the Enter or Return key.
|
||||
|
||||
![Writing in Atom][11]
|
||||
|
||||
If a line has a dot instead of a number, that means it's part of the previous line wrapped for you because it couldn't fit on your screen.
|
||||
|
||||
#### Theme it
|
||||
|
||||
If you're a visual person, you might be very particular about the way your writing environment looks. Even if you are writing in plain Markdown, it doesn't mean you have to write in a programmer's font or in a dark window that makes you look like a coder. The simplest way to modify what Atom looks like is to use [theme packages][12]. It's conventional for theme designers to differentiate dark themes from light themes, so you can search with the keyword Dark or Light, depending on what you want.
|
||||
|
||||
To install a theme, select **Edit > Preferences**. This opens a new tab in the Atom interface. Yes, tabs are used for your working documents _and_ for configuration and control panels. In the **Settings** tab, click on the **Install** category.
|
||||
|
||||
In the **Install** panel, search for the name of the theme you want to install. Click the **Themes** button on the right of the search field to search only for themes. Once you've found your theme, click its **Install** button.
|
||||
|
||||
![Atom's themes][13]
|
||||
|
||||
To use a theme you've installed or to customize a theme to your preference, navigate to the **Themes** category in your **Settings** tab. Pick the theme you want to use from the drop-down menu. The changes take place immediately, so you can see exactly how the theme affects your environment.
|
||||
|
||||
You can also change your working font in the **Editor** category of the **Settings** tab. Atom defaults to monospace fonts, which are generally preferred by programmers. But you can use any font on your system, whether it's serif or sans or gothic or cursive. Whatever you want to spend your day staring at, it's entirely up to you.
|
||||
|
||||
On a related note, by default Atom draws a vertical marker down its screen as a guide for people writing code. Programmers often don't want to write long lines of code, so this vertical line is a reminder to them to simplify things. The vertical line is meaningless to writers, though, and you can remove it by disabling the **wrap-guide** package.
|
||||
|
||||
To disable the **wrap-guide** package, select the **Packages** category in the **Settings** tab and search for **wrap-guide**. When you've found the package, click its **Disable** button.
|
||||
|
||||
#### Dynamic structure
|
||||
|
||||
When creating a long document, I find that writing one chapter per file makes more sense than writing an entire book in a single file. Furthermore, I don't name my chapters in the obvious syntax **chapter-1.md** or **1.example.md** , but by chapter titles or keywords, such as **example.md**. To provide myself guidance in the future about how the book is meant to be assembled, I maintain a file called **toc.md** (for "Table of Contents") where I list the (current) order of my chapters.
|
||||
|
||||
I do this because, no matter how convinced I am that chapter 6 just couldn't possibly happen before chapter 1, there's rarely a time that I don't swap the order of one or two chapters or sections before I'm finished with a book. I find that keeping it dynamic from the start helps me avoid renaming confusion, and it also helps me treat the material less rigidly.
|
||||
|
||||
### Git in Atom
|
||||
|
||||
Two things every writer has in common is that they're writing for keeps and their writing is a journey. You don't sit down to write and finish with a final draft; by definition, you have a first draft. And that draft goes through revisions, each of which you carefully save in duplicate and triplicate just in case one of your files turns up corrupted. Eventually, you get to what you call a final draft, but more than likely you'll be going back to it one day, either to resurrect the good parts or to fix the bad.
|
||||
|
||||
The most exciting feature in Atom is its strong Git integration. Without ever leaving Atom, you can interact with all of the major features of Git, tracking and updating your project, rolling back changes you don't like, integrating changes from a collaborator, and more. The best way to learn it is to step through it, so here's how to use Git within the Atom interface from the beginning to the end of a writing project.
|
||||
|
||||
First thing first: Reveal the Git panel by selecting **View > Toggle Git Tab**. This causes a new tab to open on the right side of Atom's interface. There's not much to see yet, so just keep it open for now.
|
||||
|
||||
#### Starting a Git project
|
||||
|
||||
You can think of Git as being bound to a folder. Any folder outside a Git directory doesn't know about Git, and Git doesn't know about it. Folders and files within a Git directory are ignored until you grant Git permission to keep track of them.
|
||||
|
||||
You can create a Git project by creating a new project folder in Atom. Select **File > Add Project Folder** and create a new folder on your system. The folder you create appears in the left **Project Panel** of your Atom window.
|
||||
|
||||
#### Git add
|
||||
|
||||
Right-click on your new project folder and select **New File** to create a new file in your project folder. If you have files you want to import into your new project, right-click on the folder and select **Show in File Manager** to open the folder in your system's file viewer (Dolphin or Nautilus on Linux, Finder on Mac, Explorer on Windows), and then drag-and-drop your files.
|
||||
|
||||
With a project file (either the empty one you created or one you've imported) open in Atom, click the **Create Repository** button in the **Git** tab. In the pop-up dialog box, click **Init** to initialize your project directory as a local Git repository. Git adds a **.git** directory (invisible in your system's file manager, but visible to you in Atom) to your project folder. Don't be fooled by this: The **.git** directory is for Git to manage, not you, so you'll generally stay out of it. But seeing it in Atom is a good reminder that you're working in a project actively managed by Git; in other words, revision history is available when you see a **.git** directory.
|
||||
|
||||
In your empty file, write some stuff. You're a writer, so type some words. It can be any set of words you please, but remember the writing tips above.
|
||||
|
||||
Press **Ctrl+S** to save your file and it will appear in the **Unstaged Changes** section of the **Git** tab. That means the file exists in your project folder but has not yet been committed over to Git's purview. Allow Git to keep track of your file by clicking on the **Stage All** button in the top-right of the **Git** tab. If you've used a word processor with revision history, you can think of this step as permitting Git to record changes.
|
||||
|
||||
#### Git commit
|
||||
|
||||
Your file is now staged. All that means is Git is aware that the file exists and is aware that it has been changed since the last time Git was made aware of it.
|
||||
|
||||
A Git commit sends your file into Git's internal and eternal archives. If you're used to word processors, this is similar to naming a revision. To create a commit, enter some descriptive text in the **Commit** message box at the bottom of the **Git** tab. You can be vague or cheeky, but it's more useful if you enter useful information for your future self so that you know why the revision was made.
|
||||
|
||||
The first time you make a commit, you must create a branch. Git branches are a little like alternate realities, allowing you to switch from one timeline to another to make changes that you may or may not want to keep forever. If you end up liking the changes, you can merge one experimental branch into another, thereby unifying different versions of your project. It's an advanced process that's not worth learning upfront, but you still need an active branch, so you have to create one for your first commit.
|
||||
|
||||
Click on the **Branch** icon at the very bottom of the **Git** tab to create a new branch.
|
||||
|
||||
![Creating a branch][14]
|
||||
|
||||
It's customary to name your first branch **master**. You don't have to; you can name it **firstdraft** or whatever you like, but adhering to the local customs can sometimes make talking about Git (and looking up answers to questions) a little easier because you'll know that when someone mentions **master** , they really mean **master** and not **firstdraft** or whatever you called your branch.
|
||||
|
||||
On some versions of Atom, the UI may not update to reflect that you've created a new branch. Don't worry; the branch will be created (and the UI updated) once you make your commit. Press the **Commit** button, whether it reads **Create detached commit** or **Commit to master**.
|
||||
|
||||
Once you've made a commit, the state of your file is preserved forever in Git's memory.
|
||||
|
||||
#### History and Git diff
|
||||
|
||||
A natural question is how often you should make a commit. There's no one right answer to that. Saving a file with **Ctrl+S** and committing to Git are two separate processes, so you will continue to do both. You'll probably want to make commits whenever you feel like you've done something significant or are about to try out a crazy new idea that you may want to back out of.
|
||||
|
||||
To get a feel for what impact a commit has on your workflow, remove some text from your test document and add some text to the top and bottom. Make another commit. Do this a few times until you have a small history at the bottom of your **Git** tab, then click on a commit to view it in Atom.
|
||||
|
||||
![Viewing differences][15]
|
||||
|
||||
When viewing a past commit, you see three elements:
|
||||
|
||||
1. Text in green was added to a document when the commit was made.
|
||||
2. Text in red was removed from the document when the commit was made.
|
||||
3. All other text was untouched.
|
||||
|
||||
|
||||
|
||||
#### Remote backup
|
||||
|
||||
One of the advantages of using Git is that, by design, it is distributed, meaning you can commit your work to your local repository and push your changes out to any number of servers for backup. You can also pull changes in from those servers so that whatever device you happen to be working on always has the latest changes.
|
||||
|
||||
For this to work, you must have an account on a Git server. There are several free hosting services out there, including GitHub, the company that produces Atom but oddly is not open source, and GitLab, which is open source. Preferring open source to proprietary, I'll use GitLab in this example.
|
||||
|
||||
If you don't already have a GitLab account, sign up for one and start a new project. The project name doesn't have to match your project folder in Atom, but it probably makes sense if it does. You can leave your project private, in which case only you and anyone you give explicit permissions to can access it, or you can make it public if you want it to be available to anyone on the internet who stumbles upon it.
|
||||
|
||||
Do not add a README to the project.
|
||||
|
||||
Once the project is created, it provides you with instructions on how to set up the repository. This is great information if you decide to use Git in a terminal or with a separate GUI, but Atom's workflow is different.
|
||||
|
||||
Click the **Clone** button in the top-right of the GitLab interface. This reveals the address you must use to access the Git repository. Copy the **SSH** address (not the **https** address).
|
||||
|
||||
In Atom, click on your project's **.git** directory and open the **config**. Add these configuration lines to the file, adjusting the **seth/example.git** part of the **url** value to match your unique address.
|
||||
|
||||
* * *
|
||||
|
||||
|
||||
```
|
||||
[remote "origin"]
|
||||
url = [git@gitlab.com][16]:seth/example.git
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
||||
```
|
||||
|
||||
At the bottom of the **Git** tab, a new button has appeared, labeled **Fetch**. Since your server is brand new and therefore has no data for you to fetch, right-click on the button and select **Push**. This pushes your changes to your Gitlab account, and now your project is backed up on a Git server.
|
||||
|
||||
Pushing changes to a server is something you can do after each commit. It provides immediate offsite backup and, since the amount of data is usually minimal, it's practically as fast as a local save.
|
||||
|
||||
### Writing and Git
|
||||
|
||||
Git is a complex system, useful for more than just revision tracking and backups. It enables asynchronous collaboration and encourages experimentation. This article has covered the basics, but there are many more articles—and entire books—on Git and how to use it to make your work more efficient, more resilient, and more dynamic. It all starts with using Git for small tasks. The more you use it, the more questions you'll find yourself asking, and eventually the more tricks you'll learn.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/4/write-git
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/sethhttps://opensource.com/users/noreplyhttps://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/write-hand_0.jpg?itok=Uw5RJD03 (Writing Hand)
|
||||
[2]: https://git-scm.com/
|
||||
[3]: https://support.mozilla.org/en-US/kb/firefox-reader-view-clutter-free-web-pages
|
||||
[4]: http://atom.io
|
||||
[5]: https://git-scm.com/download/mac
|
||||
[6]: https://git-scm.com/download/win
|
||||
[7]: http://gnu.org/software/emacs
|
||||
[8]: https://commonmark.org/help/
|
||||
[9]: https://opensource.com/sites/default/files/uploads/atom-preview.jpg (Atom's preview screen)
|
||||
[10]: https://opensource.com/sites/default/files/uploads/atom-para.jpg (Writing in Atom)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/atom-linebreak.jpg (Writing in Atom)
|
||||
[12]: https://atom.io/themes
|
||||
[13]: https://opensource.com/sites/default/files/uploads/atom-theme.jpg (Atom's themes)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/atom-branch.jpg (Creating a branch)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/git-diff.jpg (Viewing differences)
|
||||
[16]: mailto:git@gitlab.com
|
||||
@@ -1,103 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to build Fedora container images)
|
||||
[#]: via: (https://fedoramagazine.org/how-to-build-fedora-container-images/)
|
||||
[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/)
|
||||
|
||||
How to build Fedora container images
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
With the rise of containers and container technology, all major Linux distributions nowadays provide a container base image. This article presents how the Fedora project builds its base image. It also shows you how to use it to create a layered image.
|
||||
|
||||
### Base and layered images
|
||||
|
||||
Before we look at how the Fedora container base image is built, let’s define a base image and a layered image. A simple way to define a base image is an image that has no parent layer. But what does that concretely mean? It means a base image usually contains only the root file system (_rootfs_) of an operating system. The base image generally provides the tools needed to install software in order to create layered images.
|
||||
|
||||
A layered image adds a collections of layers on top of the base image in order to install, configure, and run an application. Layered images reference base images in a _Dockerfile_ using the _FROM_ instruction:
|
||||
|
||||
```
|
||||
FROM fedora:latest
|
||||
```
|
||||
|
||||
### How to build a base image
|
||||
|
||||
Fedora has a full suite of tools available to build container images. [This includes][2] _[podman][2]_, which does not require running as the root user.
|
||||
|
||||
#### Building a rootfs
|
||||
|
||||
A base image comprises mainly a [tarball][3]. This tarball contains a rootfs. There are different ways to build this rootfs. The Fedora project uses the [kickstart][4] installation method coupled with [imagefactory][5] software to create these tarballs.
|
||||
|
||||
The kickstart file used during the creation of the Fedora base image is available in Fedora’s build system [Koji][6]. The _[Fedora-Container-Base][7]_ package regroups all the base image builds. If you select a build, it gives you access to all the related artifacts, including the kickstart files. Looking at an [example][8], the _%packages_ section at the end of the file defines all the packages to install. This is how you make software available in the base image.
|
||||
|
||||
#### Using a rootfs to build a base image
|
||||
|
||||
Building a base image is easy, once a rootfs is available. It requires only a Dockerfile with the following instructions:
|
||||
|
||||
```
|
||||
FROM scratch
|
||||
ADD layer.tar /
|
||||
CMD ["/bin/bash"]
|
||||
```
|
||||
|
||||
The important part here is the _FROM scratch_ instruction, which is creating an empty image. The following instructions then add the rootfs to the image, and set the default command to be executed when the image is run.
|
||||
|
||||
Let’s build a base image using a Fedora rootfs built in Koji:
|
||||
|
||||
```
|
||||
$ curl -o fedora-rootfs.tar.xz https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ tar -xJvf fedora-rootfs.tar.xz 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar
|
||||
$ mv 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar layer.tar
|
||||
$ printf "FROM scratch\nADD layer.tar /\nCMD [\"/bin/bash\"]" > Dockerfile
|
||||
$ podman build -t my-fedora .
|
||||
$ podman run -it --rm my-fedora cat /etc/os-release
|
||||
```
|
||||
|
||||
The _layer.tar_ file which contains the rootfs needs to be extracted from the downloaded archive. This is only needed because Fedora generates images that are ready to be consumed by a container run-time.
|
||||
|
||||
So using Fedora’s generated image, it’s even easier to get a base image. Let’s see how that works:
|
||||
|
||||
```
|
||||
$ curl -O https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ podman load --input Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ podman run -it --rm localhost/fedora-container-base-rawhide-20190902.n.0.x86_64:latest cat /etc/os-release
|
||||
```
|
||||
|
||||
### Building a layered image
|
||||
|
||||
To build a layered image that uses the Fedora base image, you only need to specify _fedora_ in the _FROM_ line instruction:
|
||||
|
||||
```
|
||||
FROM fedora:latest
|
||||
```
|
||||
|
||||
The _latest_ tag references the latest active Fedora release (Fedora 30 at the time of writing). But it is possible to get other versions using the image tag. For example, _FROM fedora:31_ will use the Fedora 31 base image.
|
||||
|
||||
Fedora supports building and releasing software as containers. This means you can maintain a Dockerfile to make your software available to others. For more information about becoming a container image maintainer in Fedora, check out the [Fedora Containers Guidelines][9].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/how-to-build-fedora-container-images/
|
||||
|
||||
作者:[Clément Verna][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/cverna/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/fedoracontainers-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/running-containers-with-podman/
|
||||
[3]: https://en.wikipedia.org/wiki/Tar_(computing)
|
||||
[4]: https://en.wikipedia.org/wiki/Kickstart_(Linux)
|
||||
[5]: http://imgfac.org/
|
||||
[6]: https://koji.fedoraproject.org/koji/
|
||||
[7]: https://koji.fedoraproject.org/koji/packageinfo?packageID=26387
|
||||
[8]: https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Base/30/20190902.0/images/koji-f30-build-37420478-base.ks
|
||||
[9]: https://docs.fedoraproject.org/en-US/containers/guidelines/guidelines/
|
||||
@@ -1,211 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to change the color of your Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/19/9/linux-terminal-colors)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/jason-bakerhttps://opensource.com/users/tlaihttps://opensource.com/users/amjithhttps://opensource.com/users/greg-phttps://opensource.com/users/marcobravo)
|
||||
|
||||
How to change the color of your Linux terminal
|
||||
======
|
||||
Make Linux as colorful (or as monochromatic) as you want.
|
||||
![4 different color terminal windows with code][1]
|
||||
|
||||
You can add color to your Linux terminal using special ANSI encoding settings, either dynamically in a terminal command or in configuration files, or you can use ready-made themes in your terminal emulator. Either way, the nostalgic green or amber text on a black screen is wholly optional. This article demonstrates how you can make Linux as colorful (or as monochromatic) as you want.
|
||||
|
||||
### Terminal capabilities
|
||||
|
||||
Modern systems usually default to at least xterm-256color, but if you try to add color to your terminal without success, you should check your TERM setting.
|
||||
|
||||
Historically, Unix terminals were literally that: physical points at the literal endpoint (termination) of a shared computer system where users could type in commands. They were unique from the teletype machines (which is why we still have /dev/tty devices in Linux today) that were often used to issue commands remotely. Terminals had CRT monitors built-in, so users could sit at a terminal in their office to interact directly with the mainframe. CRT monitors were expensive—both to manufacture and to control; it was easier to have a computer spit out crude ASCII text than to worry about anti-aliasing and other niceties that modern computerists take for granted. However, developments in technology happened fast even then, and it quickly became apparent that as new video display terminals were designed, they needed new capabilities to be available on an optional basis.
|
||||
|
||||
For instance, the fancy new VT100 released in 1978 supported ANSI color, so if a user identified the terminal type as vt100, then a computer could deliver color output, while a basic serial device might not have such an option. The same principle applies today, and it's set by the TERM [environment variable][2]. You can check your TERM definition with **echo**:
|
||||
|
||||
|
||||
```
|
||||
$ echo $TERM
|
||||
xterm-256color
|
||||
```
|
||||
|
||||
The obsolete (but still maintained on some systems in the interest of backward compatibility) /etc/termcap file defined the capabilities of terminals and printers. The modern version of that is terminfo, located in either /etc or /usr/share, depending on your distribution. These files list features available in different kinds of terminals, many of which are defined by historical hardware: there are definitions for vt100 through vt220, as well as for modern software emulators like xterm and Xfce. Most software doesn't care what terminal type you're using; in rare instances, you might get a warning or error about an incorrect terminal type when logging into a server that checks for compatible features. If your terminal is set to a profile with very few features, but you know the emulator you use is capable of more, then you can change your setting by defining the TERM environment variable. You can do this by exporting the TERM variable in your ~/.bashrc configuration file:
|
||||
|
||||
|
||||
```
|
||||
`export TERM=xterm-256color`
|
||||
```
|
||||
|
||||
Save the file, and reload your settings:
|
||||
|
||||
|
||||
```
|
||||
`$ source ~/.bashrc`
|
||||
```
|
||||
|
||||
### ANSI color codes
|
||||
|
||||
Modern terminals have inherited ANSI escape sequences for "meta" features. These are special sequences of characters that a terminal interprets as actions instead of characters. For instance, this sequence clears the screen up to the next prompt:
|
||||
|
||||
|
||||
```
|
||||
`$ printf `\033[2J``
|
||||
```
|
||||
|
||||
It doesn't clear your history; it just clears up the screen in your terminal emulator, so it's a safe and demonstrative ANSI escape sequence.
|
||||
|
||||
ANSI also has sequences to set the color of your terminal. For example, typing this code changes the subsequent text to green:
|
||||
|
||||
|
||||
```
|
||||
`$ printf '\033[32m'`
|
||||
```
|
||||
|
||||
As long as you see color the same way your computer does, you could use color to help you remember what system you're logged into. For example, if you regularly SSH into your server, you can set your server prompt to green to help you differentiate it at a glance from your local prompt. For a green prompt, use the ANSI code for green before your prompt character and end it with the code representing your normal default color:
|
||||
|
||||
|
||||
```
|
||||
`export PS1=`printf "\033[32m$ \033[39m"``
|
||||
```
|
||||
|
||||
### Foreground and background
|
||||
|
||||
You're not limited to setting the color of your text. With ANSI codes, you can control the background color of your text as well as do some rudimentary styling.
|
||||
|
||||
For instance, with **\033[4m**, you can cause text to be underlined, or with **\033[5m** you can set it to blink. That might seem silly at first—because you're probably not going to set your terminal to underline all text and blink all day—but it can be useful for select functions. For instance, you might set an urgent error produced by a shell script to blink (as an alert for your user), or you might underline a URL.
|
||||
|
||||
For your reference, here are the foreground and background color codes. Foreground colors are in the 30 range, while background colors are in the 40 range:
|
||||
|
||||
Color | Foreground | Background
|
||||
---|---|---
|
||||
Black | \033[30m | \033[40m
|
||||
Red | \033[31m | \033[41m
|
||||
Green | \033[32m | \033[42m
|
||||
Orange | \033[33m | \033[43m
|
||||
Blue | \033[34m | \033[44m
|
||||
Magenta | \033[35m | \033[45m
|
||||
Cyan | \033[36m | \033[46m
|
||||
Light gray | \033[37m | \033[47m
|
||||
Fallback to distro's default | \033[39m | \033[49m
|
||||
|
||||
There are some additional colors available for the background:
|
||||
|
||||
Color | Background
|
||||
---|---
|
||||
Dark gray | \033[100m
|
||||
Light red | \033[101m
|
||||
Light green | \033[102m
|
||||
Yellow | \033[103m
|
||||
Light blue | \033[104m
|
||||
Light purple | \033[105m
|
||||
Teal | \033[106m
|
||||
White | \033[107m
|
||||
|
||||
### Permanency
|
||||
|
||||
Setting colors in your terminal session is only temporary and relatively unconditional. Sometimes the effect lasts for a few lines; that's because this method of setting colors relies on a printf statement to set a mode that lasts only until something else overrides it.
|
||||
|
||||
The way a terminal emulator typically gets instructions on what colors to use is from the settings of the LS_COLORS environment variable, which is in turn populated by the settings of dircolors. You can view your current settings with an echo statement:
|
||||
|
||||
|
||||
```
|
||||
$ echo $LS_COLORS
|
||||
rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40;
|
||||
38;5;11:so=38;5;13:do=38;5;5:bd=48;5;
|
||||
232;38;5;11:cd=48;5;232;38;5;3:or=48;
|
||||
5;232;38;5;9:mi=01;05;37;41:su=48;5;
|
||||
196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;
|
||||
196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;
|
||||
[...]
|
||||
```
|
||||
|
||||
Or you can use dircolors directly:
|
||||
|
||||
|
||||
```
|
||||
$ dircolors --print-database
|
||||
[...]
|
||||
# image formats
|
||||
.jpg 01;35
|
||||
.jpeg 01;35
|
||||
.mjpg 01;35
|
||||
.mjpeg 01;35
|
||||
.gif 01;35
|
||||
.bmp 01;35
|
||||
.pbm 01;35
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
[...]
|
||||
```
|
||||
|
||||
If that looks cryptic, it's because it is. The first digit after a file type is the attribute code, and it has six options:
|
||||
|
||||
* 00 none
|
||||
* 01 bold
|
||||
* 04 underscore
|
||||
* 05 blink
|
||||
* 07 reverse
|
||||
* 08 concealed
|
||||
|
||||
|
||||
|
||||
The next digit is the color code in a simplified form. You can get the color code by taking the final digit of the ANSII code (32 for green foreground, 42 for green background; 31 or 41 for red, and so on).
|
||||
|
||||
Your distribution probably sets LS_COLORS globally, so all users on your system inherit the same colors. If you want a customized set of colors, you can use dircolors for that. First, generate a local copy of your color settings:
|
||||
|
||||
|
||||
```
|
||||
`$ dircolors --print-database > ~/.dircolors`
|
||||
```
|
||||
|
||||
Edit your local list as desired. When you're happy with your choices, save the file. Your color settings are just a database and can't be used directly by [ls][3], but you can use dircolors to get shellcode you can use to set LS_COLORS:
|
||||
|
||||
|
||||
```
|
||||
$ dircolors --bourne-shell ~/.dircolors
|
||||
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:
|
||||
pi=40;33:so=01;35:do=01;35:bd=40;33;01:
|
||||
cd=40;33;01:or=40;31;01:mi=00:su=37;41:
|
||||
sg=30;43:ca=30;41:tw=30;42:ow=34;
|
||||
[...]
|
||||
export LS_COLORS
|
||||
```
|
||||
|
||||
Copy and paste that output into your ~/.bashrc file and reload. Alternatively, you can dump that output straight into your .bashrc file and reload.
|
||||
|
||||
|
||||
```
|
||||
$ dircolors --bourne-shell ~/.dircolors >> ~/.bashrc
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
You can also make Bash resolve .dircolors upon launch instead of doing the conversion manually. Realistically, you're probably not going to change colors often, so this may be overly aggressive, but it's an option if you plan on changing your color scheme a lot. In your .bashrc file, add this rule:
|
||||
|
||||
|
||||
```
|
||||
`[[ -e $HOME/.dircolors ]] && eval "`dircolors --sh $HOME/.dircolors`"`
|
||||
```
|
||||
|
||||
Should you have a .dircolors file in your home directory, Bash evaluates it upon launch and sets LS_COLORS accordingly.
|
||||
|
||||
### Color
|
||||
|
||||
Colors in your terminal are an easy way to give yourself a quick visual reference for specific information. However, you might not want to lean on them too heavily. After all, colors aren't universal, so if someone else uses your system, they may not see the colors the same way you do. Furthermore, if you use a variety of tools to interact with computers, you might also find that some terminals or remote connections don't provide the colors you expect (or colors at all).
|
||||
|
||||
Those warnings aside, colors can be useful and fun in some workflows, so create a .dircolor database and customize it to your heart's content.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/linux-terminal-colors
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/sethhttps://opensource.com/users/jason-bakerhttps://opensource.com/users/tlaihttps://opensource.com/users/amjithhttps://opensource.com/users/greg-phttps://opensource.com/users/marcobravo
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos.png?itok=aOBLy7Ky (4 different color terminal windows with code)
|
||||
[2]: https://opensource.com/article/19/8/what-are-environment-variables
|
||||
[3]: https://opensource.com/article/19/7/master-ls-command
|
||||
@@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
@@ -0,0 +1,611 @@
|
||||
|
||||
|
||||
|
||||
|
||||
数码文件与文件夹收纳术(以照片为例)
|
||||
======
|
||||
更新 2014-05-14:增加了一些具体实例
|
||||
|
||||
更新 2015-03-16:根据照片的 GPS 坐标过滤图片
|
||||
|
||||
更新 2016-08-29:以新的 `filetags--filter` (LCTT译注:文件标签过滤器)替换已经过时的 `show-sel.sh` 脚本(LCTT译注:show-sel 为 show firmware System Event Log records 即硬件系统事件及日志显示)
|
||||
|
||||
更新 2017-08-28: geeqier 视频缩略图的邮件评论
|
||||
|
||||
每当度假或去哪游玩时我就会化身为一个富有激情的摄影师。所以,过去的几年中我积累了许多的 [JPEG][1] 文件。这篇文章中我会介绍我是如何避免[vendor lock-in][2](LCTT译注:vendor lock-in 供应商锁定,原为经济学术语,这里引申为避免过于依赖某一服务平台)造成受限于那些临时性的解决方案及数据丢失。相反,我更倾向于使用那些可以让我投入时间和精力打理并能长久使用的解决方案。
|
||||
|
||||
这一(相当长的)攻略 **并不仅仅适用于图像文件** :我将进一步阐述像是文件夹结构,文件的命名规则,等等许多领域的事情。因此,这些规范适用于我所能接触到的所以类型的文件。
|
||||
|
||||
在我开始传授我的方法之前,我们应该先就我将要介绍方法的达成一个共识,那就是我们是否有相同的需求。如果你对[raw 图像格式][3]十分推崇,将照片存储在云端或其他你信赖的地方(对我而言可能不会),那么你可能不会认同这篇文章将要描述的方式了。请根据你的情况来灵活做出选择。
|
||||
|
||||
### 我的需求
|
||||
|
||||
对于 **将照片(或视频)从我的数码相机中导出到电脑里**,我仅仅将 SD 卡茶道我的电脑里并调用 fetch-workflow 软件。这一步也完成了 **图像软件的预处理** 适用于我提出的文件命名规范(下文会具体论述)同时也可以将图片旋转至正常的方向(而不是横着)。
|
||||
|
||||
这些文件将会被存入到我的摄影收藏文件夹 `$HOME/tmp/digicam/`。 在这一文件夹中我希望能完成以下的操作 **浏览图像和视频文件** 以便于 **整理排序/删除,重命名,添加/移除标签,以及将一系列相关的文件移动到相应的文件夹中**。
|
||||
|
||||
在完成这些以后,我将会**浏览包含图像/电影文件集的文件夹**。在极少数情况下,我希望**在独立的图像处理工具**中打开一个图像文件,比如[GIMP][4]。如果仅是为了**旋转JPEG文件**,我想找到一个快速的方法,不需要图像处理工具,这是旋转JPEG图像[无损的方式][5]。
|
||||
|
||||
我的数码相机支持用[GPS][6]坐标标记图像。因此,我需要一个方法来**可视化GPS坐标的单个文件以及一组文件**显示我走过的路径。
|
||||
|
||||
我想安利的另一个好功能是:假设你在威尼斯度假时拍了几百张照片。每一个都很漂亮,所以你每张都舍不得删除。另一方面,你可能想要一组更小的照片,送给家里的朋友。而且,为了不让他们过于嫉妒,他们可能只希望看到20多张照片。因此,我希望能够**定义并显示一组特定的照片**。
|
||||
|
||||
就独立性和**避免锁定效应**而言,我不想使用那种一旦公司停止产品或服务就无法使用的工具。出于同样的原因,由于我是一个注重隐私的人,**我不想使用任何基于云的服务**。为了让自己对新的可能性保持开放的心态,我不希望仅在一个特定的操作系统平台上倾注全部的精力。**基本的东西必须在任何平台上可用**(查看、导航、……)。但是**全套需求必须在GNU/Linux上运行**且我选择Debian GNU/Linux。
|
||||
|
||||
在我传授当前针对上述大量需求的解决方案之前,我必须解释一下我的一般文件夹结构和文件命名约定,我也使用它来命名数码照片。但首先,你必须考虑一个重要的事实:
|
||||
|
||||
#### iPhoto, Picasa, 诸如此类应被认为是有害的
|
||||
|
||||
管理照片集合的软件工具确实提供了相当酷的功能。他们提供了一个良好的用户界面,并试图为你提供各种需求的舒适的工作流程。
|
||||
|
||||
这些软件的功能和我的个人需求之间的差异很大。它们几乎对所有东西都使用专有的存储格式:图像文件、元数据等等。这是一个大问题,当你打算在几年内换一个不同的软件。相信我:总有一天你会因为多种原因而改变。
|
||||
|
||||
如果你现在正打算更换 相应的工具,你将会意识到iPhoto或Picasa确实分别存储原始图像文件和你对它们所做的所有操作。旋转图像,向图像文件添加描述,标签,裁剪,等等,如果你不能导出并重新导入到新工具,那么**所有的东西都将永远丢失**。而无损的进行转换和迁移几乎是不可能的。
|
||||
|
||||
我不想在一个锁住我工作的工具上投入任何精力。**我也拒绝把自己锁在任何专有工具上**。我是一个过来人,希望你们吸取我的经验。
|
||||
|
||||
这就是我在文件名中保留时间戳、图像描述或标记的原因。文件名是永久性的,除非我手动更改它们。当我把照片备份或复制到u盘或其他操作系统时,它们不会丢失。每个人都能读懂。任何未来的系统都能够处理它们。
|
||||
|
||||
### 我的文件命名约定
|
||||
|
||||
我所有的文件都与一个特定的日期或时间有关,根据所采用的[ISO 8601][7]规范,我采用的是**日期-标记**或**时间-标记**
|
||||
带有日期戳和两个标签的示例文件名:`2014-05-09 42号项目的预算 -- 金融公司.csv`
|
||||
|
||||
带有时间戳(甚至包括可选秒)和两个标签的示例文件名:`2014-05-09T22.19.58 Susan展示她的新鞋子 -- 家庭衣物.jpg`
|
||||
|
||||
由于冒号不适用于Windows[文件系统NTFS][8],所以我必须使用已采用的ISO时间戳。因此,我用点代替冒号,以便将小时与分钟区别开来。
|
||||
|
||||
如果是**时间或日期持续时间**,我将两个日期或时间戳用两个负号分开:`2014-05-09—2014-05-13爵士音乐节Graz—folder 旅游音乐.pdf`。
|
||||
|
||||
文件名中的时间/日期戳的优点是,除非我手动更改它们,否则它们保持不变。当通过某些不处理这些元数据的软件进行处理时,包含在文件内容本身中的元数据(如[Exif][9])往往会丢失。此外,使用这样的日期/时间戳启动文件名可以确保文件按时间顺序显示,而不是按字母顺序显示。字母表是一种[完全人工的排序顺序][10],对于用户定位文件通常不太实用。
|
||||
|
||||
当我想将**tags**关联到文件名时,我将它们放在原始文件名和[文件名扩展名][11]之间,中间用空格、两个减号和一个额外的空格分隔"`--`"。我的标签是小写的英文单词,不包含空格或特殊字符。有时,我可能会使用`quantifiedself`或`usergenerated`等连接词。我[倾向于选择一般类别][12],而不是太过具体的描述标签。我用这一方式在Twitter [hashtags][13]上重用标记、文件名、文件夹名、书签、诸如此类的博客条目等等。
|
||||
|
||||
标签作为文件名的一部分有几个优点。通过使用常用的桌面搜索引擎,你可以在标签的帮助下定位文件。文件名称中的标签不能因为在不同的存储介质上复制而丢失。当系统使用与文件名不同的存储位置如:元数据数据库、[dot-files][14]、[备用数据流][15]等,通常会发生这种情况
|
||||
|
||||
当然,在一般的文件和文件夹名称中,**请避免使用特殊字符**,umlauts,冒号等。尤其是在不同操作系统平台之间同步文件时。
|
||||
|
||||
我的**文件夹名命名约定**与文件的相应规范相同。
|
||||
|
||||
注意:由于[Memacs][17]的[filenametimestamp][16]-module的聪明之处,所有带有日期/时间戳的文件和文件夹都在同一时间/天出现在我的组织模式日历(agenda)上。这样,我就能很好地了解当天发生了什么,包括我拍的所有照片。
|
||||
|
||||
### 我的一般文件夹结构
|
||||
|
||||
在本节中,我将描述主文件夹中最重要的文件夹。注意:这可能在将来的被移动到一个独立的页面。或许不是。让我们等着瞧:-)
|
||||
很多东西只有在一定的时间内才会引起人们的兴趣。这些内容包括快速浏览其内容的下载、解压缩文件以检查包含的文件、一些有趣的小内容等等。对于**临时的东西**,我有 `$HOME/tmp/ ` 子层次结构。新照片放在`$HOME/tmp/digicam/`中。我从CD、DVD或USB记忆棒临时复制的东西放在`$HOME/tmp/fromcd/`中。每当软件工具需要用户文件夹层次结构中的临时数据时,我就使用` $HOME/tmp/Tools/ `作为起点。我经常使用的文件夹是`$HOME/tmp/2del/`:`2del`的意思是“随时可以删除”。例如,我所有的浏览器都使用这个文件夹作为默认的下载文件夹。如果我需要在机器上腾出空间,我首先查看这个`2del`-文件夹,用于删除内容。
|
||||
|
||||
与上面描述的临时文件相比,我当然也想将文件**保存更长的时间**。这些文件被移动到我的`$HOME/archive/`子层次结构中。它有几个子文件夹备份,web /下载我想保留,二进制文件我要存档,索引文件的可移动媒体(CD, DVD,记忆棒、外部硬盘驱动器),和一个文件夹用来存档(和寻找一个合适的的目标文件夹)在不久的将来。有时,我太忙或没有耐心的时候将文件妥善整理。是的,那就是我,我甚至有一个名为`现在不要整理我`的文件夹。这对你而言是否很怪?:-)
|
||||
|
||||
我的归档中最重要的子层次结构是 `$HOME/archive/events_memories/ `及其子文件夹` 2014/ `、` 2013/ `、` 2012/ `等等。正如你可能已经猜到的,每个年份有一个**子文件夹**。其中每个文件中都有单个文件和文件夹。这些文件是根据我在前一节中描述的文件名约定命名的。文件夹名称符合“YYYY-MM-DD”[ISO 8601][7] 日期标签开头,后面跟着一个具有描述性的名称,如`$HOME/archive/events_memories/2014/2014-05-08 Business marathon with /`。在这些与日期相关的文件夹中,我保存着各种与特定事件相关的文件:照片、(扫描的)pdf文件、文本文件等等。
|
||||
|
||||
对于**共享数据**,我设置一个`$HOME/share/`子层次结构。这是我的Dropbox文件夹,我用各种各样的方法(比如[unison][18])来分享数据。我也在我的设备之间共享数据:家里的Mac Mini,家里的GNU/Linux笔记本,Android手机,root-server(我的个人云),工作时的windows笔记本。我不想在这里详细说明我的同步设置。如果你想了解相关的设置,可以参考另一篇相关的文章。:-)
|
||||
|
||||
在我的` $HOME/ templates_tags / `子层次结构中,我保存了各种**模板文件** ([LaTeX][19], 脚本,…),剪辑和**logos**,等等。
|
||||
|
||||
我的**Org-mode**文件,主要是保存在`$ HOME /org/`。我练习保持记忆,并没有解释我有多喜欢 [Emacs/Org-mode][20]以及这我从中获益多少。你可能读过或听过我详细描述我用它做的很棒的事情。具体可以在我的博客上查找[我的' emacs '标签][21],在twitter上查找[hashtag ' #orgmode '][22]。
|
||||
|
||||
以上就是我最重要的文件夹子层次结构设置方式。
|
||||
|
||||
### 我的工作流程
|
||||
|
||||
Tataaaa,在你了解了我的文件夹结构和文件名约定之后,下面是我当前的工作流程和工具,我使用它们来满足我前面描述的需求。
|
||||
请注意,**你必须知道你在做什么**。我这里的示例及文件夹路径和更多只**适用我的机器或我的设置的文件夹路径。**你必须采用**相应的路径、文件名等**来满足你的需求!
|
||||
|
||||
#### 工作流程:将文件从SD卡移动到笔记本电脑,旋转人像图像,并重命名文件
|
||||
|
||||
当我想把数据从我的数码相机移到我的GNU/Linux笔记本上时,我拿出它的mini sd存储卡,把它放在我的笔记本上。然后它会自动挂载在` /media/digicam `上。
|
||||
|
||||
然后,调用[getdigicamdata]。它做了如下几件事:它将文件从SD卡移动到一个临时文件夹中进行处理。原始文件名会转换为小写字符。使用[jhead][24]旋转所有人像照片。同样使用jhead,我从Exif头时间戳生成文件名称时间戳。使用[date2name][25],我将时间戳添加到电影文件中。处理完所有这些文件后,它们将被移动到新的digicam文件的目标文件夹:$HOME/tmp/digicam/tmp/~。
|
||||
|
||||
#### 工作流程:文件夹索引、查看、重命名、删除图像文件
|
||||
|
||||
为了快速浏览我的图像和电影文件,我更喜欢在GNU/Linux上使用[geeqie][26]。这是一个相当轻量级的图像浏览器,它具有其他文件浏览器所缺少的一大优势:我可以通过键盘快捷方式调用的外部脚本/工具。通过这种方式,我可以通过任意的外部命令扩展图像浏览器的特性。
|
||||
|
||||
基本的图像管理功能是内置在geeqie:索引我的文件夹层次结构,在窗口模式或全屏查看图像(快捷键' f '),重命名文件名,删除文件,显示Exif元数据(快捷键` Ctrl-e `)。
|
||||
|
||||
在OS X上,我使用[Xee][27]。与geeqie不同,它不能通过外部命令进行扩展。不过,基本的导航、查看和重命名功能也是可用的。
|
||||
|
||||
#### 工作流:添加和删除标签
|
||||
|
||||
我创建了一个名为[filetags][28]的Python脚本,用于向单个文件以及一组文件添加和删除标记。
|
||||
|
||||
对于数码照片,我使用标签,例如,`specialL`用于我认为适合桌面背景的风景图片,`specialP`用于我想展示给其他人的人像照片,`sel`用于筛选,等等。
|
||||
|
||||
##### 使用geeqie初始设置文件标签
|
||||
|
||||
向geeqie添加文件标签是一个手动步骤:`编辑>首选项>配置编辑器…`然后创建一个带有`New`的附加条目。在这里,你可以定义一个新的桌面文件,如下所示:
|
||||
|
||||
add-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetags
|
||||
GenericName=filetags
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
包装器脚本的`vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh `是必须的,因为我想要弹出一个新的终端,以便添加标签到我的文件:
|
||||
|
||||
vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --interactive "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
在geeqie中,你可以在` Edit > Preferences > Preferences…>键盘`。我将`t`与`filetags`命令相关联。
|
||||
|
||||
标签脚本还能够从单个文件或一组文件中删除标记。它基本上使用与上面相同的方法。唯一的区别是文件标签脚本额外的`--remove`参数:
|
||||
|
||||
remove-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetags-remove
|
||||
GenericName=filetags-remove
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --interactive --remove "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
为了删除标签,我为`T`参数创建了一个键盘快捷方式。
|
||||
|
||||
##### 在geeqie中使用文件标签
|
||||
|
||||
当我在geeqie文件浏览器中浏览图像文件时,我选择要标记的文件(一到多个)并按`t`。然后,一个小窗口弹出,要求我提供一个或多个标签。在与` Return `确认后,这些标签被添加到文件名中。
|
||||
|
||||
删除标签也是一样:选择多个文件,按下`T`,输入要删除的标签,然后用`Return`确认。就是这样。几乎没有[更简单的方法来添加或删除标签到文件][29]。
|
||||
|
||||
#### 工作流:使用appendfilename重命名高级文件
|
||||
|
||||
##### 不使用 appendfilename
|
||||
|
||||
重命名一组大型文件可能是一个冗长乏味的过程。对于`2014-04-20T17.09.11_p1100386.jpg`这样的原始文件名,在文件名中添加描述的过程相当烦人。你将按`Ctrl-r`(重命名)在geeqie打开文件重命名对话框。默认情况下,原始名称(没有文件扩展名的文件名称)被标记。因此,如果不希望删除/覆盖文件名(但要追加),则必须按下光标键` <right> `。然后,光标放在基本名称和扩展名之间。输入你的描述(不要忘记初始空格字符),并用`Return`进行确认。
|
||||
|
||||
##### 在geeqie使中用appendfilename
|
||||
|
||||
使用[appendfilename][30],我的过程得到了简化,可以获得将文本附加到文件名的最佳用户体验:当我在geeqie中按下` a ` (append)时,会弹出一个对话框窗口,询问文本。在`Return`确认后,输入的文本将放置在时间戳和可选标记之间。
|
||||
|
||||
例如,当我在`2014-04-20T17.09.11_p1100386.jpg`上按下`a`,然后在`Graz`中键入`Pick-nick in Graz`时,文件名变为`2014-04-20T17.09.11_p1100386 Pick-nick in Graz.jpg`。当我再次按下`a`并输入`with Susan`时,文件名变为`2014-04-20T17.09.11_p1100386 Pick-nick in Graz with Susan.jpg`。当文件名也获得标记时,附加的文本将附加在标记分隔符之前。
|
||||
|
||||
这样,我就不必担心覆盖时间戳或标记。重命名的过程对我来说变得更加有趣!
|
||||
|
||||
最好的部分是:当我想要将相同的文本添加到多个选定的文件中时,也可以使用appendfilename。
|
||||
|
||||
##### 使用geeqie初始appendfilename
|
||||
|
||||
添加一个额外的编辑器到geeqie: ` Edit > Preferences > Configure editor…>New`。然后输入桌面文件定义:
|
||||
|
||||
appendfilename.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=appendfilename
|
||||
GenericName=appendfilename
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
同样,我也使用了一个包装脚本,它将为我打开一个新的终端:
|
||||
|
||||
vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=90x5+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/appendfilename/appendfilename.py "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
#### 工作流程:播放电影文件
|
||||
|
||||
在GNU/Linux上,我使用[mplayer][31]回放视频文件。由于geeqie本身不播放电影文件,所以我必须创建一个设置,以便在mplayer中打开电影文件。
|
||||
|
||||
##### 在geeqie中初始化mplayer的设置
|
||||
|
||||
我已经使用[xdg-open][32]将电影文件扩展名关联到mplayer。因此,我只需要为geeqie创建一个通用的“open”命令,使用xdg-open打开任何文件及其关联的应用程序。
|
||||
|
||||
再次访问` Edit > Preferences > Configure editor…`在geeqie中添加`open`的条目:
|
||||
|
||||
open.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=open
|
||||
GenericName=open
|
||||
Comment=
|
||||
Exec=/usr/bin/xdg-open %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
hidden=false
|
||||
NOMimeType=*;
|
||||
MimeType=image/*;video/*
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
当你还将快捷方式`o`(见上文)与geeqie关联时,你就能够打开与其关联的应用程序的视频文件(和其他文件)。
|
||||
|
||||
##### 使用xdg-open打开电影文件(和其他文件)
|
||||
|
||||
在上面的设置过程之后,当你的geeqie光标位于文件上方时,你只需按下`o`即可。就是如此简洁。
|
||||
|
||||
#### 工作流:在外部图像编辑器中打开
|
||||
|
||||
我不太希望能够在GIMP中快速编辑图像文件。因此,我添加了一个快捷方式`g`,并将其与外部编辑器“GNU图像处理程序”(GIMP)关联起来,geeqie已经默认创建了该程序
|
||||
|
||||
这样,只需按下`g`就可以打开GIMP中的当前图像。
|
||||
|
||||
#### 工作流程:移动到存档文件夹
|
||||
|
||||
现在我已经在我的文件名中添加了注释,我想将单个文件移动到`$HOME/archive/events_memories/2014/`,或者将一组文件移动到这个文件夹中的新文件夹中,如`$HOME/archive/events_memories/2014/2014-05-08 business marathon after show - party`。
|
||||
|
||||
通常的方法是选择一个或多个文件,并将它们移动到具有快捷方式`Ctrl-m`的文件夹中。
|
||||
|
||||
何等繁复无趣之至!
|
||||
|
||||
因此,我(再次)编写了一个Python脚本,它为我完成了这项工作:[move2archive][33](简而言之:` m2a `需要一个或多个文件作为命令行参数。然后,出现一个对话框,我可以在其中输入一个可选文件夹名。当我不输入任何东西,但按`Return`,文件被移动到相应年份的文件夹。当我输入一个类似`business marathon after show - party`的文件夹名称时,第一个图像文件的日期戳被附加到该文件夹(`$HOME/archive/events_memories/2014/2014-05-08 business marathon after show - party`),得到的文件夹是(`$HOME/archive/events_memories/2014/2014-05-08 Business-Marathon After-Show-Party`),并移动文件。
|
||||
|
||||
再一次:我在geeqie中,选择一个或多个文件,按`m`(移动),或者只按`Return`(没有特殊的子文件夹),或者输入一个描述性文本,这是要创建的子文件夹的名称(可选不带日期戳)。
|
||||
|
||||
**没有一个图像管理工具像我的geeqie一样通过快捷键快速且有趣的使用 appendfilename和move2archive完成工作。**
|
||||
|
||||
##### 在geeqie里初始化m2a的相关设置
|
||||
|
||||
同样,向geeqie添加`m2a`是一个手动步骤:“编辑>首选项>配置编辑器……”然后创建一个带有“New”的附加条目。在这里,你可以定义一个新的桌面文件,如下所示:
|
||||
|
||||
m2a.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=move2archive
|
||||
GenericName=move2archive
|
||||
Comment=Moving one or more files to my archive folder
|
||||
Exec=/home/vk/src/misc/vk-m2a-interactive-wrapper-with-gnome-terminal.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
包装器脚本的`vk-m2a-interactive-wrapper-with-gnome-terminal.sh `是必要的,因为我想要弹出一个新的终端窗口,以便我的文件进入我指定的目标文件夹:
|
||||
|
||||
vk-m2a-interactive-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=157x56+330+5 \
|
||||
--tab-with-profile=big \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/m2a/m2a.py --pauseonexit "${@}"
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
在geeqie中,你可以在`Edit > Preferences > Preferences ... > Keyboard`将`m`与`m2a`命令相关联。
|
||||
|
||||
#### 工作流程:旋转图像(无损)
|
||||
|
||||
通常,我的数码相机会自动将人像照片标记为人像照片。然而,在某些特定的情况下(比如从主题上方拍照),我的相机会出错。在那些**罕见的情况下**,我必须手动修正方向。
|
||||
|
||||
你必须知道,JPEG文件格式是一种有损格式,应该只用于照片,而不是计算机生成的东西,如屏幕截图或图表。以傻瓜方式旋转JPEG图像文件通常会解压/可视化图像文件,旋转生成新的图像,然后重新编码结果。这将导致生成的图像[比原始图像质量差得多][5]。
|
||||
|
||||
因此,你应该使用无损方法来旋转JPEG图像文件。
|
||||
|
||||
再一次,我添加了一个“外部编辑器”到geeqie:`Edit > Preferences > Configure Editors ... > New`。在这里,我添加了两个条目:一个用于旋转270度(即逆时针旋转90度),另一个用于使用[exiftran][34]旋转90度(逆时针旋转90度):
|
||||
|
||||
rotate-270.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=Losslessly rotate JPEG image counterclockwise
|
||||
|
||||
# call the helper script
|
||||
TryExec=exiftran
|
||||
Exec=exiftran -p -2 -i -g %f
|
||||
|
||||
# Desktop files that are usable only in Geeqie should be marked like this:
|
||||
Categories=X-Geeqie;
|
||||
OnlyShowIn=X-Geeqie;
|
||||
|
||||
# Show in menu "Edit/Orientation"
|
||||
X-Geeqie-Menu-Path=EditMenu/OrientationMenu
|
||||
|
||||
MimeType=image/jpeg;
|
||||
|
||||
```
|
||||
|
||||
rotate-90.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=Losslessly rotate JPEG image clockwise
|
||||
|
||||
# call the helper script
|
||||
TryExec=exiftran
|
||||
Exec=exiftran -p -9 -i -g %f
|
||||
|
||||
# Desktop files that are usable only in Geeqie should be marked like this:
|
||||
Categories=X-Geeqie;
|
||||
OnlyShowIn=X-Geeqie;
|
||||
|
||||
# Show in menu "Edit/Orientation"
|
||||
X-Geeqie-Menu-Path=EditMenu/OrientationMenu
|
||||
|
||||
# It can be made verbose
|
||||
# X-Geeqie-Verbose=true
|
||||
|
||||
MimeType=image/jpeg;
|
||||
|
||||
```
|
||||
|
||||
我为“[”(逆时针方向)和“]”(逆时针方向)创建了geeqie快捷键。
|
||||
|
||||
#### 工作流程:可视化GPS坐标
|
||||
|
||||
我的数码相机有一个GPS传感器,它在JPEG文件的Exif元数据中存储当前的地理位置。位置数据以[WGS 84][35]格式存储,如“47,58,26.73;16、23、55.51”(纬度;经度)。这一方式可读性较差,从我所期望的意义上讲:要么是地图,要么是位置名称。因此,我向geeqie添加了一些功能,这样我就可以在[OpenStreetMap][36]上看到单个图像文件的位置: `Edit > Preferences > Configure Editors ... > New`
|
||||
|
||||
photolocation.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=vkphotolocation
|
||||
GenericName=vkphotolocation
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vkphotolocation.sh %F
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-gray;image/x-icb;image/x-ico;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-xbitmap;image/x-xpixmap;image/x-pcx;image/svg+xml;image/svg+xml-compressed;image/vnd.wap.wbmp;
|
||||
|
||||
```
|
||||
|
||||
这就调用了我的名为`vkphotolocation.sh`的包装脚本,它使用[ExifTool][37]让[Marble][38]能够读取和可视化的适当格式并提取坐标:
|
||||
|
||||
vkphotolocation.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
IMAGEFILE="${1}"
|
||||
IMAGEFILEBASENAME=`basename ${IMAGEFILE}`
|
||||
|
||||
COORDINATES=`exiftool -c %.6f "${IMAGEFILE}" | awk '/GPS Position/ { print $4 " " $6 }'`
|
||||
|
||||
if [ "x${COORDINATES}" = "x" ]; then
|
||||
zenity --info --title="${IMAGEFILEBASENAME}" --text="No GPS-location found in the image file."
|
||||
else
|
||||
/usr/bin/marble --latlon "${COORDINATES}" --distance 0.5
|
||||
fi
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
映射到键盘快捷键“G”,我可以快速地得到**单个图像文件的映射位置位置**。
|
||||
|
||||
当我想将多个JPEG图像文件的**位置可视化为路径**时,我使用[GpsPrune][39]。我无法派生出GpsPrune将一组文件作为命令行参数的方法。正因为如此,我必须手动启动GpsPrune,`选择一组文件或一个文件夹>添加照片`。
|
||||
|
||||
通过这种方式,我可以为OpenStreetMap地图上的每个JPEG位置获得一个点(如果配置为这样)。通过单击这样一个点,我可以得到相应图像的详细信息。
|
||||
|
||||
如果你恰好在国外拍摄照片,可视化GPS位置对**在文件名中添加描述**大有帮助!
|
||||
|
||||
#### 工作流程:根据GPS坐标过滤照片
|
||||
|
||||
这并非我的工作流程。为了完整起见,我列出该工作流对应工具的特性。我想做的就是从一大堆图片中寻找那些在一定区域内(范围或点+距离)的照片。
|
||||
|
||||
到目前为止,我只找到了[DigiKam][40],它能够[根据矩形区域进行过滤][41]。如果你知道其他工具,请将其添加到下面的评论或写一封电子邮件。
|
||||
|
||||
#### 工作流:显示给定集合的子集
|
||||
|
||||
如上面的需求所述,我希望能够在一个文件夹中定义一组子文件,以便将这个小集合呈现给其他人。
|
||||
|
||||
工作流程非常简单:我向选择的文件添加一个标记(通过` t ` /filetags)。为此,我使用标记`sel`,它是“selection”的缩写。在标记了一组文件之后,我可以按下` s `,它与一个脚本相关联,该脚本只显示标记为` sel `的文件。
|
||||
|
||||
当然,这也适用于任何标签或标签组合。因此,用同样的方法,你可以得到一个适当的概述,你的婚礼上的所有照片都标记着“教堂”和“戒指”。
|
||||
|
||||
很棒的功能,不是吗?:-)
|
||||
|
||||
##### 根据标签和geeqie初始设置文件标签
|
||||
|
||||
你必须定义一个额外的“外部编辑器”:`Edit > Preferences > Configure Editors ... > New`:
|
||||
|
||||
filter-tags.desktop
|
||||
```
|
||||
[Desktop Entry]
|
||||
Name=filetag-filter
|
||||
GenericName=filetag-filter
|
||||
Comment=
|
||||
Exec=/home/vk/src/misc/vk-filetag-filter-wrapper-with-gnome-terminal.sh
|
||||
Icon=
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Application;Graphics;
|
||||
hidden=false
|
||||
MimeType=image/*;video/*;image/mpo;image/thm
|
||||
Categories=X-Geeqie;
|
||||
|
||||
```
|
||||
|
||||
再次调用我编写的包装脚本:
|
||||
|
||||
vk-filetag-filter-wrapper-with-gnome-terminal.sh
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/gnome-terminal \
|
||||
--geometry=85x15+330+5 \
|
||||
--hide-menubar \
|
||||
-x /home/vk/src/filetags/filetags.py --filter
|
||||
|
||||
#end
|
||||
|
||||
```
|
||||
|
||||
带参数`--filter`的`filetags`基本上完成的是:用户被要求输入一个或多个标签。然后,当前文件夹中所有匹配的文件都能使用[符号链接][42]都链接到` $HOME/.filetags_tagfilter/ `。然后,启动一个新的geeqie实例,显示链接的文件。
|
||||
|
||||
在退出这个新的geeqie实例之后,你将从该实例调用了选择过程中看到旧的geeqie实例。
|
||||
|
||||
#### 用一个真实的案例来总结
|
||||
|
||||
Wow, 这是一篇很长的博客文章。难怪你可能已经忘了之前的概述。总结一下我在geeqie(扩展了标准功能集)中可以做的事情,我有一个很酷的总结:
|
||||
|
||||
快捷功能 `m` m2a `o` 打开(针对非图像文件) `a` 在文件名里添加字段 `t` 文件标签(添加) `T` 文件标签(删除) `s` 文件标签(排序) `g` gimp `G` 显示GPS信息 `[` 无损的逆时针旋转 `]` 无损的顺时针旋转 `Ctrl-e` EXIF图像信息 `f` 全屏显示
|
||||
|
||||
一些针对文件名的(包括它的路径)及我用来操作组件的示例:
|
||||
```
|
||||
/this/is/a/folder/2014-04-20T17.09 Pick-nick in Graz -- food graz.jpg
|
||||
[ m2a ] [ date2name ] [ appendfilename ] [filetags]
|
||||
|
||||
```
|
||||
在示例中,我按照以下步骤将照片从相机保存到存档:我将SD存储卡放入计算机的SD卡读卡器中。然后我运行[getdigicamdata.sh][23]。完成之后,我在geeqie中打开`$HOME/tmp/digicam/tmp/`。我浏览了一下照片,把那些不成功的删除了。如果有一个图像的方向错误,我用`[`or`]`纠正它。
|
||||
|
||||
在第二步中,我向我认为值得评论的文件添加描述(` a `)。每当我想添加标签时,我也这样做:我快速地标记所有应该共享标签的文件(` Ctrl ` \+鼠标点击),并使用[filetags][28] (` t `)进行标记。
|
||||
|
||||
要组合来自给定事件的文件,我选中相应的文件,将它们移动到年度归档文件夹中的“event-folder”,并通过在[move2archive][33] (`m `)中键入事件描述,其余的(非特殊的文件夹)由move2archive (`m `)直接移动到年度归档中,而不需要声明事件描述。
|
||||
|
||||
为了完成我的工作流程,我删除了SD卡上的所有文件,把它从操作系统上弹出,然后把它放回我的数码相机里。
|
||||
|
||||
以上。
|
||||
|
||||
因为这种工作流程几乎不需要任何开销,所以评论、标记和归档照片不再是一项乏味的工作。
|
||||
|
||||
### 最后
|
||||
|
||||
所以,这是一个详细描述我关于照片和电影的工作流程的叙述。你可能已经发现了我可能感兴趣的其他东西。所以请不要犹豫,请使用下面的链接留下评论或电子邮件。
|
||||
我也希望得到反馈,如果我的工作流程适用于你。并且:如果你已经发布了你的工作流程或者找到了其他人工作流程的描述,也请留下评论!
|
||||
及时行乐,莫让错误的工具或低效的方法浪费了我们的人生!
|
||||
|
||||
### 其他工具
|
||||
|
||||
阅读关于[本文中关于 gThumb 的部分][43].
|
||||
|
||||
当你觉得你以上文中所叙述的符合你的需求时,请根据相关的建议来选择对应的工具。
|
||||
|
||||
### 邮件回复
|
||||
|
||||
> Date: Sat, 26 Aug 2017 22:05:09 +0200
|
||||
|
||||
> 你好卡尔,
|
||||
我喜欢你的文章,喜欢和memacs一起工作,当然还有orgmode,但是我对python不是很熟悉……在你的博客文章“管理数码照片”,你写了关于打开视频与[Geeqie][26]。是的,但是我在浏览器里看不到任何视频缩略图。你有什么建议吗?
|
||||
|
||||
> 谢谢你,托马斯
|
||||
|
||||
|
||||
|
||||
你好托马斯,
|
||||
|
||||
谢谢你的美言。当有人发现我的工作对他/她的生活有用时,我总是感觉很棒。
|
||||
不幸的是,大多数时候,我从未听到过这些。
|
||||
是的,我有时使用Geeqie来可视化文件夹,这些文件夹不仅包含图像文件,还包含电影文件。在这些情况下,我没有看到任何视频的缩略图。你说得对,有很多文件浏览器可以显示视频的预览图像。
|
||||
坦白地说,我从来没有想过视频缩略图,我也不怀念它们。在我的首选项和搜索引擎上做了一个快速的研究,并没有发现在Geeqie中启用视频预览的相关方法。所以这里要说声抱歉。
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://karl-voit.at/managing-digital-photographs/
|
||||
|
||||
作者:[Karl Voit][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://karl-voit.at
|
||||
[1]:https://en.wikipedia.org/wiki/Jpeg
|
||||
[2]:http://en.wikipedia.org/wiki/Vendor_lock-in
|
||||
[3]:https://en.wikipedia.org/wiki/Raw_image_format
|
||||
[4]:http://www.gimp.org/
|
||||
[5]:http://petapixel.com/2012/08/14/why-you-should-always-rotate-original-jpeg-photos-losslessly/
|
||||
[6]:https://en.wikipedia.org/wiki/Gps
|
||||
[7]:https://en.wikipedia.org/wiki/Iso_date
|
||||
[8]:https://en.wikipedia.org/wiki/Ntfs
|
||||
[9]:https://en.wikipedia.org/wiki/Exif
|
||||
[10]:http://www.isisinform.com/reinventing-knowledge-the-medieval-controversy-of-alphabetical-order/
|
||||
[11]:https://en.wikipedia.org/wiki/File_name_extension
|
||||
[12]:http://karl-voit.at/tagstore/en/papers.shtml
|
||||
[13]:https://en.wikipedia.org/wiki/Hashtag
|
||||
[14]:https://en.wikipedia.org/wiki/Dot-file
|
||||
[15]:https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_.28ADS.29
|
||||
[16]:https://github.com/novoid/Memacs/blob/master/docs/memacs_filenametimestamps.org
|
||||
[17]:https://github.com/novoid/Memacs
|
||||
[18]:http://www.cis.upenn.edu/~bcpierce/unison/
|
||||
[19]:https://github.com/novoid/LaTeX-KOMA-template
|
||||
[20]:http://orgmode.org/
|
||||
[21]:http://karl-voit.at/tags/emacs
|
||||
[22]:https://twitter.com/search?q%3D%2523orgmode&src%3Dtypd
|
||||
[23]:https://github.com/novoid/getdigicamdata.sh
|
||||
[24]:http://www.sentex.net/%3Ccode%3Emwandel/jhead/
|
||||
[25]:https://github.com/novoid/date2name
|
||||
[26]:http://geeqie.sourceforge.net/
|
||||
[27]:http://xee.c3.cx/
|
||||
[28]:https://github.com/novoid/filetag
|
||||
[29]:http://karl-voit.at/tagstore/
|
||||
[30]:https://github.com/novoid/appendfilename
|
||||
[31]:http://www.mplayerhq.hu
|
||||
[32]:https://wiki.archlinux.org/index.php/xdg-open
|
||||
[33]:https://github.com/novoid/move2archive
|
||||
[34]:http://manpages.ubuntu.com/manpages/raring/man1/exiftran.1.html
|
||||
[35]:https://en.wikipedia.org/wiki/WGS84#A_new_World_Geodetic_System:_WGS_84
|
||||
[36]:http://www.openstreetmap.org/
|
||||
[37]:http://www.sno.phy.queensu.ca/~phil/exiftool/
|
||||
[38]:http://userbase.kde.org/Marble/Tracking
|
||||
[39]:http://activityworkshop.net/software/gpsprune/
|
||||
[40]:https://en.wikipedia.org/wiki/DigiKam
|
||||
[41]:https://docs.kde.org/development/en/extragear-graphics/digikam/using-kapp.html#idp7659904
|
||||
[42]:https://en.wikipedia.org/wiki/Symbolic_link
|
||||
[43]:http://karl-voit.at/2017/02/19/gthumb
|
||||
@@ -1,44 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lujun9972)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How many browser tabs do you usually have open?)
|
||||
[#]: via: (https://opensource.com/article/19/6/how-many-browser-tabs)
|
||||
[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst)
|
||||
|
||||
您通常打开多少个浏览器选项卡?
|
||||
======
|
||||
外加一些提高浏览器效率的技巧。
|
||||
![Browser of things][1]
|
||||
|
||||
这里有一个别有用心的问题:您通常一次打开多少个浏览器选项卡?您是否有多个窗口,每个窗口都有多个选项卡?或者你是一个极简主义者,一次只打开几个标签。另一种选择是将一个 20 个选项卡的浏览器窗口移动到另一个屏幕上去,这样在处理特定任务时它就不会碍事了。您的处理方法在工作、个人和移动浏览器之间有什么不同吗?您的浏览器策略是否与您的[工作习惯 ][2] 有关?
|
||||
|
||||
### 4 个提高浏览器效率的技巧
|
||||
|
||||
1。了解浏览器快捷键以节省单击。无论你使用 Firefox 还是 Chrome,都有很多快捷键可以让你方便地执行包括切换标签页在内的某些功能。例如,Chrome 可以很方便地打开一个空白的谷歌文档。使用快捷键 **“Ctrl + t”** 打开一个新选项卡,然后键入 **“doc.new”** 即可。电子表格、幻灯片和表单也可以这样做。
|
||||
2。用书签文件夹组织最频繁的任务。当开始一项特定的任务时,只需打开文件夹**中的所有书签 (Ctrl + click)**,就可以快速地从列表中勾选它。
|
||||
3。使用正确的浏览器扩展。成千上万的浏览器扩展都声称可以提高工作效率。在安装之前,确定你不是仅仅在屏幕上添加更多的干扰而已。
|
||||
4。使用计时器减少看屏幕的时间。无论您使用的是老式的 egg 定时器还是花哨的浏览器扩展,都没有关系。为了防止眼睛疲劳,执行 20/20/20 规则。每隔 20 分钟,离开屏幕 20 秒,看看 20 英尺以外的东西。
|
||||
|
||||
|
||||
|
||||
参加我们的投票来分享你一次打开多少个浏览器标签。请务必在评论中告诉我们您最喜欢的浏览器技巧。
|
||||
|
||||
生产力有两个组成部分——做正确的事情和高效地做那些事情……
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/how-many-browser-tabs
|
||||
|
||||
作者:[Lauren Pritchett][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[lujun9972](https://github.com/lujun9972)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/lauren-pritchett/users/sarahwall/users/ksonney/users/jwhitehurst
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things)
|
||||
[2]: https://enterprisersproject.com/article/2019/1/5-time-wasting-habits-break-new-year
|
||||
@@ -7,25 +7,24 @@
|
||||
[#]: via: (https://opensource.com/article/19/8/getting-started-httpie)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshezhttps://opensource.com/users/mkalindepauleduhttps://opensource.com/users/jamesf)
|
||||
|
||||
Getting started with HTTPie for API testing
|
||||
使用 HTTPie 进行 API 测试
|
||||
======
|
||||
Debug API clients with HTTPie, an easy-to-use command-line tool written
|
||||
in Python.
|
||||
使用 HTTPie 调试 API,一个用 Python 写的简易命令行工具。
|
||||
![Raspberry pie with slice missing][1]
|
||||
|
||||
[HTTPie][2] is a delightfully easy to use and easy to upgrade HTTP client. Pronounced "aitch-tee-tee-pie" and run as **http**, it is a command-line tool written in Python to access the web.
|
||||
[HTTPie][2] 是一个非常易于使用且易于升级的 HTTP 客户端。它的发音为 “aitch-tee-tee-pie” 并以 **http** 运行,它是一个用 Python 编写的命令行工具来用于访问 Web。
|
||||
|
||||
Since this how-to is about an HTTP client, you need an HTTP server to try it out; in this case, [httpbin.org][3], a simple, open source HTTP request-and-response service. The httpbin.org site is a powerful way to test to test web API clients and carefully manage and show details in requests and responses, but for now we will focus on the power of HTTPie.
|
||||
由于这篇是关于 HTTP 客户端的,因此你需要一个 HTTP 服务器来试用它。在这里,访问 [httpbin.org] [3],它是一个简单的开源 HTTP 请求和响应服务。httpbin.org 网站是一种测试 Web API 的强大方式,并能仔细管理并显示请求和相应内容,但现在我们将专注于 HTTPie 的强大功能。
|
||||
|
||||
### An alternative to Wget and cURL
|
||||
### Wget 和 cURL 的替代品
|
||||
|
||||
You might have heard of the venerable [Wget][4] or the slightly newer [cURL][5] tools that allow you to access the web from the command line. They were written to access websites, whereas HTTPie is for accessing _web APIs_.
|
||||
你可能听说过古老的 [Wget][4] 或稍微更新的 [cURL][5] 工具,它们允许你从命令行访问 Web。它们是为访问网站而编写的,而 HTTPie 则用于访问 _Web API_。
|
||||
|
||||
Website requests are designed to be between a computer and an end user who is reading and responding to what they see. This doesn't depend much on structured responses. However, API requests make _structured_ calls between two computers. The human is not part of the picture, and the parameters of a command-line tool like HTTPie handle this effectively.
|
||||
网站请求设计介于计算机和正在阅读并响应他们所看到的内容的最终用户之间。这并不太依赖于结构化的响应。但是,API 请求会在两台计算机之间进行_结构化_调用。人类不是图片的一部分,像 HTTPie 这样的命令行工具的参数可以有效地处理这个问题。
|
||||
|
||||
### Install HTTPie
|
||||
### 安装 HTTPie
|
||||
|
||||
There are several ways to install HTTPie. You can probably get it as a package for your package manager, whether you use **brew**, **apt**, **yum**, or **dnf**. However, if you have configured [virtualenvwrapper][6], you can own your own installation:
|
||||
有几种方法可以安装 HTTPie。你可以通过包管理器安装,无论你使用的是 **brew**、**apt**、**yum** 还是 **dnf**。但是,如果你已配置 [virtualenvwrapper] [6],那么你可以用自己的方式安装:
|
||||
|
||||
|
||||
```
|
||||
@@ -49,16 +48,16 @@ $ http -b GET <https://httpbin.org/get>
|
||||
}
|
||||
```
|
||||
|
||||
By aliasing **http** directly to the command inside the virtual environment, you can run it even when the virtual environment is not active. You can put the **alias** command in **.bash_profile** or **.bashrc** so you can upgrade HTTPie with the command:
|
||||
通过直接将 **http** 设置为虚拟环境中的命令别名,即使虚拟环境在非活动状态,你也可以运行它。 你可以将 **alias** 命令放在 **.bash_profile** 或 **.bashrc** 中,这样你就可以使用以下命令升级 HTTPie:
|
||||
|
||||
|
||||
```
|
||||
`$ ~/.virtualenvs/httpie/bin/pip install -U pip`
|
||||
```
|
||||
|
||||
### Query a website with HTTPie
|
||||
### 使用 HTTPie 查询网站
|
||||
|
||||
HTTPie can simplify querying and testing an API. One option for running it, **-b** (also known as **\--body**), was used above. Without it, HTTPie will print the entire response, including the headers, by default:
|
||||
HTTPie 可以简化查询和测试 API。 这里使用了一个选项, **-b**(也可以是 **\--body**)。 没有它,HTTPie 将默认打印整个响应,包括头:
|
||||
|
||||
|
||||
```
|
||||
@@ -90,7 +89,7 @@ X-XSS-Protection: 1; mode=block
|
||||
}
|
||||
```
|
||||
|
||||
This is crucial when debugging an API service because a lot of information is sent in the headers. For example, it is often important to see which cookies are being sent. Httpbin.org provides options to set cookies (for testing purposes) through the URL path. The following sets a cookie titled **opensource** to the value **awesome**:
|
||||
这在调试 API 服务时非常重要,因为大量信息在 HTTP 头中发送。 例如,查看发送的 cookie 通常很重要。Httpbin.org 提供了通过 URL 路径设置 cookie(用于测试目的)的选项。 以下设置一个标题为 **opensource**, 值为 **awesome** 的 cookie:
|
||||
|
||||
|
||||
```
|
||||
@@ -110,14 +109,14 @@ X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
||||
X-XSS-Protection: 1; mode=block
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<title>Redirecting...</title>
|
||||
<h1>Redirecting...</h1>
|
||||
<p>You should be redirected automatically to target URL:
|
||||
<a href="/cookies">/cookies</a>. If not click the link.
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<title>Redirecting...</title>
|
||||
<h1>Redirecting...</h1>
|
||||
<p>You should be redirected automatically to target URL:
|
||||
<a href="/cookies">/cookies</a>. If not click the link.
|
||||
```
|
||||
|
||||
Notice the **Set-Cookie: opensource=awesome; Path=/** header. This shows the cookie you expected to be set is set correctly and with a **/** path. Also notice that, even though you got a **302** redirect, **http** did not follow it. If you want to follow redirects, you need to ask for it explicitly with the **\--follow** flag:
|
||||
注意 **Set-Cookie: opensource=awesome; Path=/** 的 HTTP 头。 这表明你预期设置的 cookie 已正确设置,路径为 **/**。 另请注意,即使你有 **302**重定向,**http** 也不会遵循它。 如果你想要遵循重定向,则需要使用 **\--follow** 标志请求:
|
||||
|
||||
|
||||
```
|
||||
@@ -143,7 +142,7 @@ X-XSS-Protection: 1; mode=block
|
||||
}
|
||||
```
|
||||
|
||||
But now you cannot see the original **Set-Cookie** header. In order to see intermediate replies, you need to use **\--all**:
|
||||
但此时你无法看到原来的 **Set-Cookie** 头。为了看到中间响应,你需要使用 **\--all**:
|
||||
|
||||
|
||||
```
|
||||
@@ -179,7 +178,7 @@ Content-Length: 66
|
||||
Connection: keep-alive
|
||||
```
|
||||
|
||||
Printing the body is uninteresting because you are mostly interested in the cookies. If you want to see the headers from the intermediate request but the body from the final request, you can do that with:
|
||||
打印 body 并不有趣,因为你大多数关心 cookie。如果你像看到中间请求的头,而不是最终请求中的 body,你可以使用:
|
||||
|
||||
|
||||
```
|
||||
@@ -221,11 +220,11 @@ Connection: keep-alive
|
||||
}
|
||||
```
|
||||
|
||||
You can control exactly what is being printed with **\--print** and override what is printed for intermediate requests with **\--history-print**.
|
||||
你可以使用 **\--print** 精确控制打印,并使用 **\--history-print** 覆盖中间请求的打印。
|
||||
|
||||
### Download binary files with HTTPie
|
||||
### 使用 HTTPie 下载二进制文件
|
||||
|
||||
Sometimes the body is non-textual and needs to be sent to a file that can be opened by a different application:
|
||||
有时 body 并不是文本形式,它需要发送到可被不同应用打开的文件:
|
||||
|
||||
|
||||
```
|
||||
@@ -248,7 +247,7 @@ X-XSS-Protection: 1; mode=block
|
||||
+-----------------------------------------+
|
||||
```
|
||||
|
||||
To get the right image, you need to save it to a file:
|
||||
要得到正确的图片,你需要保存到文件:
|
||||
|
||||
|
||||
```
|
||||
@@ -270,11 +269,11 @@ Downloading 34.75 kB to "jpeg.jpe"
|
||||
Done. 34.75 kB in 0.00068s (50.05 MB/s)
|
||||
```
|
||||
|
||||
Try it! The picture is adorable.
|
||||
试一下!图片很可爱。
|
||||
|
||||
### Sending custom requests with HTTPie
|
||||
### 使用 HTTPie 发送自定义请求
|
||||
|
||||
You can also send specific headers. This is useful for custom web APIs that require a non-standard header:
|
||||
你可以发送指定头。这对于需要非标准头的自定义 Web API 很有用:
|
||||
|
||||
|
||||
```
|
||||
@@ -290,7 +289,7 @@ $ http GET <https://httpbin.org/headers> X-Open-Source-Com:Awesome
|
||||
}
|
||||
```
|
||||
|
||||
Finally, if you want to send JSON fields (although it is possible to specify exact content), for many less-nested inputs, you can use a shortcut:
|
||||
最后,如果要发送 JSON 字段(尽管可以指定确切的内容),对于许多嵌套较少的输入,你可以使用快捷方式:
|
||||
|
||||
|
||||
```
|
||||
@@ -318,7 +317,7 @@ $ http --body PUT <https://httpbin.org/anything> open-source=awesome author=mosh
|
||||
}
|
||||
```
|
||||
|
||||
The next time you are debugging a web API, whether your own or someone else's, put down your cURL and reach for HTTPie, the command-line client for web APIs.
|
||||
下次在调试 Web API 时,无论时你自己还是别人,记得放下 cURL,试试 HTTPie 这个命令行工具。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -326,7 +325,7 @@ via: https://opensource.com/article/19/8/getting-started-httpie
|
||||
|
||||
作者:[Moshe Zadka][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
103
translated/tech/20190904 How to build Fedora container images.md
Normal file
103
translated/tech/20190904 How to build Fedora container images.md
Normal file
@@ -0,0 +1,103 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to build Fedora container images)
|
||||
[#]: via: (https://fedoramagazine.org/how-to-build-fedora-container-images/)
|
||||
[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/)
|
||||
|
||||
如何构建 Fedora 容器镜像
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
随着容器和容器技术的兴起,现在所有主流的 Linux 发行版都提供了容器基础镜像。本文介绍 Fedora 项目如何构建其基本镜像。同时还展示了如何使用它来创建分层图像。
|
||||
|
||||
### 基础和分层镜像
|
||||
|
||||
在看如何构建 Fedora 容器基础镜像之前,让我们定义基础镜像和分层镜像。定义基础镜像的简单方法是没有父镜像的镜像。但这具体意味着什么呢?这意味着基础镜像通常只包含操作系统的根文件系统基础镜像(_rootfs_)。基础镜像通常提供安装软件以创建分层镜像所需的工具。
|
||||
|
||||
分层镜像在基础镜像上添加了一组层,以便安装、配置和运行应用。分层镜像在 _Dockerfile_ 中使用 _FROM_ 指令引用基础镜像:
|
||||
|
||||
```
|
||||
FROM fedora:latest
|
||||
```
|
||||
|
||||
### 如何构建基础镜像
|
||||
|
||||
Fedora 有一整套用于构建容器镜像的工具。[其中包括][2] _[podman][2]_,它不需要以 root 身份运行
|
||||
|
||||
#### 构建 rootfs
|
||||
|
||||
基础镜像主要包括 [tarball][3]。这个 tarball 包含一个 rootfs。有不同的方法来构建此 rootfs。Fedora 项目使用 [kickstart][4] 安装方式以及 [imagefactory][5] 来创建这些 tarball。
|
||||
|
||||
在创建 Fedora 基础镜像期间使用的 kickstart 文件可以在 Fedora 的构建系统 [Koji][6] 中找到。_[Fedora-Container-Base][7]_ 包重新组合所有基础镜像构建。如果选择了一个构建,那么可以访问所有相关文件,包括 kickstart 文件。查看 [示例][8],文件末尾的 _%packages_ 部分定义了要安装的所有软件包。这就是让软件在基础镜像中的方法。
|
||||
|
||||
#### 使用 rootfs 构建基础镜像
|
||||
|
||||
ootfs 完成后,构建基础镜像就很容易了。它只需要一个包含以下指令的 Dockerfile:
|
||||
|
||||
```
|
||||
FROM scratch
|
||||
ADD layer.tar /
|
||||
CMD ["/bin/bash"]
|
||||
```
|
||||
|
||||
这里的重要部分是 _FROM scratch_ 指令,它会创建一个空镜像。然后,以下指令将 rootfs 添加到镜像,并设置在运行镜像时要执行的默认命令。
|
||||
|
||||
让我们使用 Koji 内置的 Fedora rootfs 构建一个基础镜像:
|
||||
|
||||
```
|
||||
$ curl -o fedora-rootfs.tar.xz https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ tar -xJvf fedora-rootfs.tar.xz 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar
|
||||
$ mv 51c14619f9dfd8bf109ab021b3113ac598aec88870219ff457ba07bc29f5e6a2/layer.tar layer.tar
|
||||
$ printf "FROM scratch\nADD layer.tar /\nCMD [\"/bin/bash\"]" > Dockerfile
|
||||
$ podman build -t my-fedora .
|
||||
$ podman run -it --rm my-fedora cat /etc/os-release
|
||||
```
|
||||
|
||||
需要从下载的存档中提取包含 rootfs 的 _layer.tar_ 文件。这在 Fedora 生成的镜像已经可以被容器运行时使用才需要。
|
||||
|
||||
因此,使用 Fedora 生成的镜像,获得基础镜像会更容易。让我们看看它是如何工作的:
|
||||
|
||||
```
|
||||
$ curl -O https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Rawhide/20190902.n.0/images/Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ podman load --input Fedora-Container-Base-Rawhide-20190902.n.0.x86_64.tar.xz
|
||||
$ podman run -it --rm localhost/fedora-container-base-rawhide-20190902.n.0.x86_64:latest cat /etc/os-release
|
||||
```
|
||||
|
||||
### 构建分层镜像
|
||||
|
||||
要构建使用 Fedora 基础镜像的分层镜像,只需在 _FROM_ 行指令中指定 _fedora_:
|
||||
|
||||
```
|
||||
FROM fedora:latest
|
||||
```
|
||||
|
||||
_latest_ 标记引用了最新的 Fedora 版本(编写本文时是 Fedora 30)。但是可以使用 image 标签获得其他版本。例如,_FROM fedora:31_ 将使用 Fedora 31 基础镜像。
|
||||
|
||||
Fedora 支持将软件作为容器来构建并发布。这意味着你可以维护 Dockerfile 来使其他人可以使用你的软件。关于在 Fedora 中成为容器镜像维护者的更多信息,请查看 [Fedora 容器指南][9]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/how-to-build-fedora-container-images/
|
||||
|
||||
作者:[Clément Verna][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/cverna/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/fedoracontainers-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/running-containers-with-podman/
|
||||
[3]: https://en.wikipedia.org/wiki/Tar_(computing)
|
||||
[4]: https://en.wikipedia.org/wiki/Kickstart_(Linux)
|
||||
[5]: http://imgfac.org/
|
||||
[6]: https://koji.fedoraproject.org/koji/
|
||||
[7]: https://koji.fedoraproject.org/koji/packageinfo?packageID=26387
|
||||
[8]: https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Base/30/20190902.0/images/koji-f30-build-37420478-base.ks
|
||||
[9]: https://docs.fedoraproject.org/en-US/containers/guidelines/guidelines/
|
||||
Reference in New Issue
Block a user