一些配置文件存档

通用

ssh config

~/.ssh/config

1
2
3
4
5
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

当ssh难连接git@github.com时,重定向到ssh.github.com
可以在此之前先分别测试一下两个链接的连通性:

1
2
ssh -T git@github.com
ssh -T git@ssh.github.com

Windows

.inputrc

~/.inputrc

1
set bell-style none

这份文件用来解决使用Windows Terminal打开git bash的时候,无效按键会闪屏的问题。

.vimrc

~/.vimrc

1
2
3
4
5
set relativenumber
set number
set vb t_vb=
unlet! skip_defaults_vim
source /usr/share/vim/vim90/defaults.vim

这份文件作为git bash里面附带的vim的配置文件;
前两行设置,当前行显示绝对行号,其它行显示相对行号;
第三行解决Windows Terminal打开vim的时候,无效按键会闪屏的问题;
最后两行启用vim的默认配置(当vim检测到.vimrc文件存在时,会禁用默认配置,这里将其恢复)。

Linux

tty-en.sh

1
2
3
4
5
6
7
8
9
10
# Set tty English

for ttyi in {1..6}; do
if [ "$(tty)" = "/dev/tty$ttyi" ];
then
export LC_ALL="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
fi
done

对于桌面环境跟随系统/etc/locale.conf的Linux系统,当桌面崩溃需要tty救急的时候,tty上面的中文全部显示为菱形会导致几乎无法查看输出。
这段代码检测如果处于tty环境下就将系统全局语音设置为英文(Linux默认开6个tty所以这里设置成从tty1到tty6);
如果需要只对单用户生效,将这段代码追加到~/.bashrc中(或者根据你的默认终端换成~/.zshrc等),或者追加到~/.profile中(未测试);
如果需要全局生效,将这段代码追加到/etc/profile的末尾,或者在/etc/profile.d/目录下创建一个新的文件,取一个你喜欢的名字(例如咱的路径是/etc/profile.d/tty-en.sh),填入这段代码。
全局配置更推荐后者方案,因为前者直接修改系统预设,如果系统更新覆盖了这个文件,你可能需要重新处理(pacman系用户会需要处理/etc/profile.pacnew),而后者是自定义文件因此不会出现此问题。

fish_prompt.fish(git)

~/.config/fish/functions/fish_prompt.fish

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function fish_prompt
set -l last_status $status

if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch brmagenta
end
if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
end
if not set -q __fish_git_prompt_showdirtystate
set -g __fish_git_prompt_showdirtystate "yes"
end
if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
end
if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
end
if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate brgreen
end

printf '%s%s %s%s%s%s ' (set_color $fish_color_host) (prompt_hostname) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (fish_git_prompt)

if not test $last_status -eq 0
set_color $fish_color_error
end
echo -n '$ '
set_color normal
end

fish启用显示git状态的功能,但是个人感觉会变难看(不过fish默认状态也不太好看)
启用前(home目录):

启用后(home目录):

启用前(~/.cache/yay/notepad—git/):

启用后(~/.cache/yay/notepad—git/):


一些配置文件存档
http://silvertuanzi.github.io/2025/01/15/some-rc-files/
作者
silver-lasombra
发布于
2025年1月15日
许可协议