Skip to main content

· 5 min read
wen

刚过了不惑之年,有点感伤,碰巧听到这首歌,很有感触。

是不是该写封信给 10 年后的自己呢?😀

LRC 歌词:

曲名 : letter song (10年後の私へ)
作词 : doriko
作曲 : doriko
好きな人と歩いた場所も (曾和喜欢的人一起走过的地方)
その時見た景色も (那时曾看到的景色)
振り返らず 今を駆け抜け (统统抛掉 不再回头 向前飞奔)
私は何と出会うの (我将会遇见些什么呢)
立ち止まるほど (驻足不前)
意味を問うほど (探索意义)
きっとまだ大人ではなくて (一定是我还不够成熟)
今見てるもの (现在看到的事物)
今出会う人 (现在遇见的人)
その中でただ前だけを見てる (在这片纷繁喧嚣之中 我只会看向前方)
10年後の私へ (致十年以后的我)
今は幸せでしょうか (现在的你感到幸福么?)
それとも悲しみで (还是正沉浸在悲伤中)
泣いているのでしょうか (默默地流着泪?)
けどあなたの傍に (不过在你的身旁)
変わらないものがあり (依然会有不变的存在)
気付いていないだけで (未能察觉的你)
守られていませんか (依然在被守护着吧)
過ぎし日々に 想いを預け (把思念寄托于流逝的日子里)
時間だけ ただ追いかけてく (只有时间在不停的追赶)
背に寄り添った 誰かの夢に (托付在我肩上的 是谁的梦想)
振り向ける日がいつか来るのかな (总有一天必须要面对的吧)
10年後の私へ (致十年以后的我)
今は誰を好きですか (现在的你喜欢着谁呢?)
それとも変わらずに (还是和以前一样)
あの人が好きですか (继续喜欢着那个人呢?)
けどいつか (不过 现在的你)
知らない誰かを愛する前に (在爱上某个人之前)
自分のことを好きと (“喜欢自己”这句话)
言えるようになりましたか (能否先说出来呢)
大切な人たちは (我所珍爱的朋友们)
今も変わらずいますか (依然在反复平凡地生活吗?)
それとも遠く離れ (还是已经远去)
それぞれ歩んでますか (踏上了各自的旅途)
けど そんな出会いを (但是在重复了无数次的相遇)
别れを 缲り返して (和离别之后)
今の私よりも (是否比现在的我)
すてきになっていますか (更有魅力呢?)
10年後の私へ (致十年后的我)
今がもし幸せなら (如果现在的你是幸福的)
あの日の私のこと (从前的我)
思い出してくれますか (能否请你想起来呢)
そこにはつらいことに (回忆中的我)
泣いた私がいるけど (一定在伤心的哭泣吧)
その涙を優しく (请将这眼泪温柔地)
思い出に変えてください (融入记忆的海洋)

· 3 min read
wen

0. Background

When changing computers, you need to migrate some configuration files from the old computer to the new one, such as .zshrc, .vimrc, .gitconfig, and so on.

Some files may not necessarily be located in the home directory, such as .ssh/config, .config/.starship.yaml. It's a bit of a hassle to migrate these files manually.

Therefore, you need a tool to manage these configuration files.

1. Requirements

  • Support multiple platforms, such as macOS, Linux, Windows.
  • Support version management, such as git.
  • Support templates.

I did a little research and found that there are several tools that can manage dotfiles:

  • chezmoi
    • Golang written
    • Github Star 10.2k
  • dotbot
    • Python written
    • Github Star 6.5k

chezmoi meets my requirements, and it's written in Golang without any dependencies, so I decided to use chezmoi.

2. Install

sh -c "$(curl -fsLS get.chezmoi.io)"

You could find more installation methods here

3. Usage

3.1 Initialize

tip

After initialization, a ~/.local/share/chezmoi directory (local repository) will be generated in the home directory to store chezmoi configuration files. You can enter the directory with the chezmoi cd command.

3.2 Add files

3.3 Update files

tip

After updating the file, remember to commit to the remote repository. You can refer to the previous section.

3.4 Fetch files from remote repository

Fetch files from remote repository and apply them.

chezmoi update

It's equivalent to

chezmoi git pull origin main
chezmoi apply

3.5 Extend usage

3.5.1 Templating

chezmoi supports templates,which can generate different configuration files for different hosts and so on.

For example, I want to configure different account names for different computers, I can do this:

  • Create ~/.account.json file, the content is as follows:
~/.account.json
{
"name": "thewang"
}
  • Configure the data field in ~/.config/chezmoi/chezmoi.toml.
~/.config/chezmoi/chezmoi.toml
[data]
name = "thewang"
  • Add file with --autotemplate flag.
chezmoi add --autotemplate ~/.account.json

{
"name": "{{ .name }}"
}

· 3 min read
wen

0. Background

I have been using the snippet feature of Alfred 3, but the Alfred snippet feature is paid.

Recently, I discovered Raycast, where the Raycast snippet feature is free and open-source, allowing for personal customization.

Therefore, I plan to migrate my Alfred snippets to Raycast.

1. Migrate Alfred Snippets to Raycast

The format of Alfred's snippet files differs from that of Raycast's snippet files. Hence, it is necessary to first convert Alfred's snippet files to Raycast's snippet files.

1.1 Get Alfred Snippets Files

Open the Snippets feature in Alfred, click the Export button to export the Alfred snippets. Since collections in Alfred 3 do not support bulk export, they need to be exported one by one. 🐶

img

1.2 Convert Alfred Snippets to Raycast Snippets

Create a new folder and place the exported Alfred snippet files in it.

Then, create a file named convert-alfred-snippets-to-raycast-snippets.sh in this folder, with the following content:

convert-alfred-snippets-to-raycast-snippets.sh
#!/bin/sh -e
# Script for converting Alfred snippets to Raycast snippets
# Usage: chmod +x convert-alfred-snippets-to-raycast-snippets.sh; ./convert-alfred-snippets-to-raycast-snippets.sh
# NOTE: Install jq before running this script

# List up all *.alfredsnippets files and rename them to *.zip
for file in *.alfredsnippets; do
mv "$file" "${file%.alfredsnippets}.zip"
done

# Unzip all *.zip files and get the folders name
for file in *.zip; do
unzip -o "$file" # -o: overwrite existing files without prompting
done


# Merge all *.json files to one file for Raycast snippets
jq -s 'map(.alfredsnippet | {name, keyword, text: .snippet})' *.json > ./output.json

# Clean up all files except output.json
for file in *.json; do
if [ "$file" = "output.json" ]; then
continue
fi
rm "$file"
done

for file in *.zip; do
rm "$file"
done

for file in *.plist; do
rm "$file"
done

# You can now import the output.json file to Raycast

echo "Done! 🎉 You can now import the output.json file to Raycast -> Import Snippets"

OR download from Github gist: convert-alfred-snippets-to-raycast-snippets.sh

note

To execute this script, you need to install jq, which is a command-line JSON processor tool.

For Mac, you can install jq using Homebrew with the command: brew install jq. You can also refer to the official website for more installation options.

Run the following command:

chmod +x convert-alfred-snippets-to-raycast-snippets.sh
./convert-alfred-snippets-to-raycast-snippets.sh

An output.json file will be generated in the current directory.

1.3 Import Raycast Snippets

Open Raycast, then click on Import Snippets. Choose the output.json file generated in the previous step to import the snippets into Raycast.

Reference

Migrating Alfred Snippets to Raycast