/dotfiles

Primary LanguageShellMIT LicenseMIT

Linux && Mac OS 平台上用的各种配置文件

简要

目前在用的一些工具的配置文件,工具的选择尽量考虑跨平台,共用同一套配置。

安装

git clone --depth 1 https://github.com/Jackson-soft/dotfiles.git ~/myDoc/dotfiles && cd ~/myDoc/dotfiles && sh ./link.sh

Emacs

具体可见: Emacs

Zsh

整体配置

具体可见: zshrc

实用工具

fzf

fzf 是一个模糊搜索工具。有一个竞品是 skim ,曾经也用过一段时间,奈何周边生态不如 fzf ,后面切回到 fzf

基本键位:

CTRL-T
Paste the selected files and directories onto the command-line
CTRL-R
Paste the selected command from history onto the command-line
ALT-C
cd into the selected directory

zinit 的安装配置如下:

zinit ice as"null" wait lucid from"gh-r" sbin"fzf" atload'eval "$(fzf --zsh)"'
zinit light junegunn/fzf

注意:

  • sbin 关键字需要 zdharma-continuum/zinit-annex-bin-gem-node 插件来支持。
  • 二进制的安装如果要放到 $PATH 里可以用 as"program"= 或 =as"null"= 两种方式,区别在于 =as"program"= 是每个二进制的安装都是单独的目录,而 =as"null"= 是统一在 =~/.zinit/polaris/bin 目录下。个人建议是用 as"null"= 这种方式,这样 =$PATH 相对比较简洁。

如果 Mac 有用 iterm2 的同学要注意, ALT-C 有可能会失效,解决方法是:

Go to Preferences->Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

以上是方法是取自 Alt-C not working on OSX

fd

fdfind 命令的替代品。

bat

batcat 命令的替代品。

delta

delta 是文件对比工具,主要是用来替换 git diff 用的。可以在 ~/.gitconfig 文件中做以下配置:

[pager]
    diff = delta
    log = delta
    reflog = delta
    show = delta

[interactive]
    diffFilter = delta --color-only

[delta]
    features = side-by-side line-numbers decorations
    whitespace-error-style = 22 reverse

[delta "decorations"]
    commit-decoration-style = bold yellow box ul
    file-style = bold yellow ul
    file-decoration-style = none

如果是使用 git-fuzzy 的话,是不用配置这些的。

ripgrep

ripgrep 是一个文本搜索工具。

ugrep

ugrep 同样是一个搜索工具。可以是 grep 的平替,且带有 TUI

procs

procsps 命令的替代品。

eza

ezals 命令的替代品,目前有个小问题,就是官方一直没提供 mac 的二进制。它同样有一个竞品 lsd ,两者功能性上差不多,看个人口味来取舍。

vivid

vivid 是环境变量 LS_COLORS 的数据源。可以做以下配置:

export LS_COLORS="$(vivid generate molokai)"

主要是不同格式的文件显示不同的颜色,相比单一的白色会更好区分。相较于 LS_COLORS 显示颜色更丰富一些。

zoxide

zoxide 是一个快速目录跳转工具,支持模糊匹配和历史纪录。配置如下:

# 快速跳转目录
zi ice wait"2" as"null" from"gh-r" lucid sbin"**/zoxide" atload'eval "$(zoxide init zsh)"'
zi light ajeetdsouza/zoxide

它延伸出两个命令:

z
这个应该叫 cd 命令的智能版;
zi
这个是配合搜索工具( fzf )的 cd 命令。

z.lua

z.lua 同样是一个快速目录跳转工具,是用 lua 写的。配置如下:

zi wait"0a" lucid depth"1" for \
    atload"source <(lua $ZINIT[PLUGINS_DIR]/skywind3000---z.lua/z.lua --init zsh enhanced once fzf);export _ZL_HYPHEN=1" skywind3000/z.lua

插件管理

zinit 是目前用着比较不错的一个 zsh 插件管理器。个人比较相中的几个点:

  • 性能不错;
  • 可以管理一些跨平台的二进制工具;
  • 用什么插件就配置什么插件,不必像 Oh My ZshPrezto 一样,插件不管你用不用都下载下来。

插件

fzf-tab

fzf-tab 依赖于 fzfTab 补全插件,强烈推荐。

基本配置如下:

# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# preview directory's content with exa when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
# switch group using `,` and `.`
zstyle ':fzf-tab:*' switch-group ',' '.'

基本的键位:

Ctrl+Space
select multiple results, can be configured by fzf-bindings tag
F1/F2
switch between groups, can be configured by switch-group tag
/
trigger continuous completion (useful when completing a deep path), can be configured by continuous-trigger tag

git-fuzzy

git-fuzzy 是一个基于 fzf 扩展 git 的工具。

目前支持的子命令:

  • git fuzzy status
  • git fuzzy branch
  • git fuzzy log
  • git fuzzy reflog
  • git fuzzy stash
  • git fuzzy diff
  • git fuzzy pr

forgit

forgit 依赖于 fzfgit 命令封装工具。

一些默认的简写:

forgit_log=glo
forgit_diff=gd
forgit_add=ga
forgit_reset_head=grh
forgit_ignore=gi
forgit_checkout_file=gcf
forgit_checkout_branch=gcb
forgit_checkout_commit=gco
forgit_clean=gclean
forgit_stash_show=gss
forgit_cherry_pick=gcp
forgit_rebase=grb
forgit_fixup=gfu

git-extras

git-extras git 的扩展工具包,有很多实用的工具封装。

Vim

目前是用 Neovim 替代,主要是满足日常配置脚本之用。选择 Neovim 主要原因是配置文件可以用 Lua 来写,我对于 vimscript 还是不 太熟悉。

所有配置都在 init.lua ,用到 Neovim 内置的 tree-siterlsp

终端

原来在 Mac OS 上一直用 iTerm2 ,后来改用跨平台终端 wezterm ,主要原因是:

  • 跨平台
  • 配置文件化

至于说 GPU 加速,目前没什么感觉,配置文件参见 wezterm.lua

PS : wezterm 还有一个 Rust 写的竞品 Alacritty

最近发现了一个比较新的 C++ 写的现代终端 Contour ,目前完成度较低,保持观望中。

这里纪录一些常用的默认快捷键:

键位功能
ctrl+shift+enternew_window
ctrl+shift+wclose_window
ctrl+shift+]next_window
ctrl+shift+[previous_window
ctrl+shift+rightnext_tab
ctrl+shift+leftprevious_tab
ctrl+shift+tnew_tab
ctrl+shift+qclose_tab
F5横向分隔
F6纵向分隔

一些 GUI 工具

对比工具

  • Meld 是由 Gnome 提供的跨平台的文件对比工具,可以比较文件、目录和版本控制项目。
  • KDiff3 是由 KDE 发起的强大的跨平台差异比对及合并工具。