Skip to content

Commit

Permalink
2024/4/6 update nixos, neovim and all kinds of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Martins3 authored Apr 6, 2024
1 parent 500169c commit e4ecc4e
Show file tree
Hide file tree
Showing 113 changed files with 10,375 additions and 4,091 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ lazy-lock.json

perf.data
perf.data.old
.bash_history
*.qcow2
__pycache__
kernel/module/.gdb_history
51 changes: 51 additions & 0 deletions config/.gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[alias]
adog = "log --all --decorate --oneline --graph"
bug = "log -n 1 --pretty=fixes"
kernel = "log -n 1 --pretty=commit"
log-merge = "!f() { git log --oneline --graph --stat \"$1^..$1\"; }; f"

[core]
abbrev = 12
editor = "nvim"
pager = "delta"

[credential]
helper = "store"

[delta]
light = "false"
navigate = "true"

[diff]
colorMoved = "default"

[http]
proxy = "http://127.0.0.1:8889"

[https]
proxy = "http://127.0.0.1:8889"

[interactive]
diffFilter = "delta --color-only"

[merge]
conflictstyle = "diff3"

[pretty]
commit = "commit %h (\"%s\")"
fixes = "Fixes: %h (\"%s\")"

[sendemail]
smtpencryption = "tls"
smtpserver = "smtp.googlemail.com"
smtpserverport = 587
smtpuser = "[email protected]"

[sendemail "linux"]
cccmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom"
tocmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol"

[user]
email = "[email protected]"
name = "Xueshi Hu"

37 changes: 37 additions & 0 deletions config/alacritty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[colors.bright]
black = "0x002b36"
blue = "0x839496"
cyan = "0x93a1a1"
green = "0x586e75"
magenta = "0x6c71c4"
red = "0xcb4b16"
white = "0xfdf6e3"
yellow = "0x657b83"

[colors.normal]
black = "0x073642"
blue = "0x268bd2"
cyan = "0x2aa198"
green = "0x859900"
magenta = "0xd33682"
red = "0xdc322f"
white = "0xeee8d5"
yellow = "0xb58900"

[colors.primary]
background = "0x002b36"
foreground = "0x839496"

[font]
size = 9.0

[font.normal]
family = "FiraCode Nerd Font"

[shell]
program = "zsh"

[window]
decorations = "none"
opacity = 0.98
startup_mode = "Maximized"
2 changes: 1 addition & 1 deletion config/alacritty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ window:
#
# Window opacity as a floating point number from `0.0` to `1.0`.
# The value `0.0` is completely transparent and `1.0` is opaque.
opacity: 0.9
opacity: 0.98

# Startup Mode (changes require restart)
#
Expand Down
1 change: 1 addition & 0 deletions config/gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dashboard -style prompt_running "\\[\\e[1;32m\\]$\\[\\e[0m\\]"

add-auto-load-safe-path /home/martins3/core/qemu/.gdbinit
add-auto-load-safe-path /home/martins3/core/linux/scripts/gdb/vmlinux-gdb.py
add-auto-load-safe-path /home/martins3/core/linux-build/scripts/gdb/vmlinux-gdb.py

# @todo 有趣
define my-source-profile
Expand Down
1 change: 0 additions & 1 deletion config/nix.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
experimental-features = nix-command flakes
substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
2 changes: 1 addition & 1 deletion config/npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
prefix=~/.npm-packages
registry=https://registry.npm.taobao.org/
# registry=https://registry.npm.taobao.org/
30 changes: 30 additions & 0 deletions config/pueue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
shared:
pueue_directory: ~/.local/share/pueue
use_unix_socket: true
runtime_directory: null
unix_socket_path: ~/.local/share/pueue/pueue_your_user.socket
host: "localhost"
port: "6924"
daemon_cert: ~/.local/share/pueue/certs/daemon.cert
daemon_key: ~/.local/share/pueue/certs/daemon.key
shared_secret_path: ~/.local/share/pueue/shared_secret

client:
restart_in_place: false
read_local_logs: true
show_confirmation_questions: false
show_expanded_aliases: false
dark_mode: false
max_status_height: null
status_time_format: "%H:%M:%S"
status_datetime_format: "%Y-%m-%d\n%H:%M:%S"

daemon:
default_parallel_tasks: 1
pause_group_on_failure: false
pause_all_on_failure: false
callback: "Task {{ id }}\nCommand: {{ command }}\nPath: {{ path }}\nFinished with status '{{ result }}'\""
callback_log_lines: 10
groups:
default: 1
3 changes: 2 additions & 1 deletion config/sh/bpftrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ case "$action" in
scripts="$entry { @[kstack] = count(); }"
;;
realtime)
scripts="$entry { print(\"hit $entry \n\") }"
scripts="$entry { print(\"hit $entry\") }"
;;
*)
exit 1
;;
esac
echo "sudo bpftrace -e \"$scripts\""
sudo bpftrace -e "$scripts"
# XXX 这里使用 bcc 工具集其实会更加简单,新的测试项目用 bcc 实现吧
12 changes: 10 additions & 2 deletions config/sh/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ target=~/core/linux-build

A=/tmp/martins3/source_build_unstage.diff
B=/tmp/martins3/source_build_staged.diff
if ! cd $target; then
git clone $source $target
fi
cd $source
git diff >$A
git diff --cached >$B
Expand All @@ -20,8 +23,13 @@ git diff --cached >$B1

function update() {
git reset --hard
[[ -s $A ]] && git apply $A
[[ -s $B ]] && git apply $B
if [[ -s $A ]]; then
git apply $A || true
fi

if [[ -s $B ]]; then
git apply $B || true
fi
}

if diff $A $A1 &>/dev/null; then
Expand Down
17 changes: 3 additions & 14 deletions config/sh/funcgraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@ if [[ ! -s $bpftrace_cache ]]; then
sudo cat /sys/kernel/debug/tracing/available_filter_functions | tee $bpftrace_cache
fi

trap finish EXIT

function finish {
echo nop | sudo tee /sys/kernel/debug/tracing/current_tracer
echo | sudo tee /sys/kernel/debug/tracing/set_event
echo | sudo tee /sys/kernel/debug/tracing/trace
}

finish

if [[ $# -eq 0 ]]; then
entry=$(fzf <"$bpftrace_cache")
else
echo "$*"
entry=$(fzf --query="$*" <"$bpftrace_cache")
fi

echo function_graph | sudo tee /sys/kernel/debug/tracing/current_tracer
echo "${entry%\[*\]}" | sudo tee /sys/kernel/debug/tracing/set_graph_function
echo | sudo tee /sys/kernel/debug/tracing/set_ftrace_filter # 有点奇葩,为什么不清空会影响输出的内容
sudo cat /sys/kernel/debug/tracing/trace_pipe
set -x
# 可以指定 CPU
sudo perf ftrace -G "${entry% \[*\]}" -g 'smp_*' -g irq_enter_rcu -g __sysvec_irq_work -g irq_exit_rcu
18 changes: 3 additions & 15 deletions config/sh/tracepoint.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
#!/usr/bin/env bash
set -E -e -u -o pipefail
set -x

mkdir -p /tmp/martins3
tracepoint_cache=/tmp/martins3/tracepoint_cache
if [[ ! -s $tracepoint_cache ]]; then
sudo cat /sys/kernel/debug/tracing/available_events | tee $tracepoint_cache
fi

trap finish EXIT

function finish {
# TODO 才知道,不是清理掉 current_tracer ,而是清理掉 set_event 才对
echo nop | sudo tee /sys/kernel/debug/tracing/current_tracer
echo | sudo tee /sys/kernel/debug/tracing/set_event
echo | sudo tee /sys/kernel/debug/tracing/trace
}

finish

# sudo 和 fzf 使用有一个问题,例如 sudo perf list tracepoint | fzf ,没有办法输密码
if [[ $# -eq 0 ]]; then
entry=$(fzf <"$tracepoint_cache")
else
echo "$*"
entry=$(fzf --query="$*" <"$tracepoint_cache")
fi

echo "${entry}" | sudo tee /sys/kernel/debug/tracing/set_event
# TODO 这个模式有个问题,都是直接输出到屏幕的,需要输出一些到持久的位置
sudo cat /sys/kernel/debug/tracing/trace_pipe
set -x
sudo perf trace -e "${entry}"
11 changes: 2 additions & 9 deletions config/tmux-note-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ windows:
shell_command_before:
- cd ~/core/vn
- mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen)
- window_name: .dotfiles
- window_name: module
layout: tiled
shell_command_before:
- cd ~/.dotfiles
- cd ~/core/vn/code/module/
- mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen)
# - window_name: dmesg
# layout: tiled
# shell_command_before:
# - cd ~/core/amd-crash
# panes:
# - dmesg -w
# - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen)
4 changes: 2 additions & 2 deletions config/tmux-note.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ windows:
shell_command_before:
- cd ~/core/vn
- mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen)
- window_name: .dotfiles
- window_name: module
layout: tiled
shell_command_before:
- cd ~/.dotfiles
- cd ~/core/vn/code/module/
- mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen)
- window_name: draft
layout: tiled
Expand Down
16 changes: 12 additions & 4 deletions config/wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,22 @@ return {
-- action = wezterm.action.ShowLauncher
},
{
key = "m",
mods = "CTRL",
key = "t",
mods = "CTRL|SHIFT",
action = wezterm.action.SpawnCommandInNewTab({
args = { "bash", "-l", "-c", "zellij attach || zellij" },
}),
-- action = wezterm.action.ShowLauncher
},
{
key = "i",
mods = "CTRL|SHIFT",
action = wezterm.action.SpawnCommandInNewTab({
args = { "ssh", "-t", "-p5556", "root@localhost", "zellij attach || zellij" },
args = { "ssh", "-t", "[email protected]", "tmux attach || tmux" },
}),
-- action = wezterm.action.ShowLauncher
},
{ key = "F2", mods = "", action = wezterm.action.ShowLauncher },
{ key = "F8", mods = "", action = wezterm.action.ShowLauncher },
},
adjust_window_size_when_changing_font_size = false,
default_prog = { "bash", "-l", "-c", "/usr/bin/env tmux attach || /usr/bin/env tmux" },
Expand Down
34 changes: 22 additions & 12 deletions config/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ fi

# 参考 https://gist.github.com/iansu/1ad9fc5db90aafbf14ce58e99d5940ef
# prompt 中通过不同的 emoji 来标识架构
if grep "GenuineIntel" /proc/cpuinfo >/dev/null; then
export SHELL_ARCH="🐙"
elif grep "AuthenticAMD" /proc/cpuinfo >/dev/null; then
export SHELL_ARCH="🐉"
if [[ -f ~/core/id ]]; then
export SHELL_ARCH=$(cat ~/core/id)
else
export SHELL_ARCH="ARM"
if grep "GenuineIntel" /proc/cpuinfo >/dev/null; then
export SHELL_ARCH="🐙"
elif grep "AuthenticAMD" /proc/cpuinfo >/dev/null; then
export SHELL_ARCH="🐉"
else
export SHELL_ARCH="ARM"
fi
fi
eval "$(starship init zsh)"

Expand Down Expand Up @@ -112,17 +116,16 @@ function zj() {
}

alias px="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf"
alias mutt="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf neomutt"
# alias mutt="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf mutt -f"
# 快速打开 QEMU
alias dk="/home/martins3/.dotfiles/scripts/qemu/launch.sh -d"
alias qt="/home/martins3/.dotfiles/scripts/qemu/launch.sh -t"
alias rk=/home/martins3/core/vn/docs/qemu/sh/alpine.sh
alias k=/home/martins3/.dotfiles/scripts/qemu/launch.sh
alias kk="/home/martins3/.dotfiles/scripts/qemu/launch.sh -k"
alias rkk="/home/martins3/.dotfiles/scripts/qemu/choose_launch.sh"
# 这里将 $ 转义,从而是执行 ge 命令的时候加载端口而非在
# @todo 似乎我的 tmux 配置有问题导致 ssh 前需要设置一下环境变量
alias ge="TERM=xterm-256color ssh -p\$(cat /tmp/martins3/guest-ssh) root@localhost"
alias gege="TERM=xterm-256color ssh-copy-id -p\$(cat /tmp/martins3/guest-ssh) root@localhost"
alias ge="/home/martins3/.dotfiles/scripts/qemu/launch.sh -s"
alias vnc="/home/martins3/.dotfiles/scripts/qemu/launch.sh -v"
alias gege="/home/martins3/.dotfiles/scripts/qemu/launch.sh -c"
# 打开工作区间并且构建
alias b="/home/martins3/.dotfiles/config/sh/tmux.sh && exit"
alias c="clear"
Expand All @@ -136,7 +139,7 @@ alias kernel_version="git describe --contains"
# https://unix.stackexchange.com/questions/45120/given-a-git-commit-hash-how-to-find-out-which-kernel-release-contains-it
alias knews="/home/martins3/.dotfiles/scripts/systemd/news.sh kernel"
alias ldc="lazydocker"
alias ls="exa --icons"
alias ls="eza --icons"
alias m="chrt -i 0 make CC='ccache gcc' -j$(getconf _NPROCESSORS_ONLN)"
alias bu="/home/martins3/.dotfiles/config/sh/build-linux.sh && cd ~/core/linux-build && m"
alias mc="make clean"
Expand All @@ -151,6 +154,7 @@ alias kvm_stat="sudo /home/martins3/core/linux/tools/kvm/kvm_stat/kvm_stat"
alias p="python -m venv .venv && source .venv/bin/activate"
alias i="ipython"
alias t="/home/martins3/.dotfiles/config/sh/bpftrace.sh"
alias f="xclip -o >> /home/martins3/core/vn/fun.md && echo '' >> /home/martins3/core/vn/fun.md && cat /home/martins3/core/vn/fun.md"
alias tracepoint="/home/martins3/.dotfiles/config/sh/tracepoint.sh"
alias funcgraph="/home/martins3/.dotfiles/config/sh/funcgraph.sh"
alias cloc="tokei . -f --sort lines"
Expand All @@ -165,4 +169,10 @@ function config_repo(){
git config user.name martins3
git config user.email [email protected]
}
function check(){
cd ~/core/linux
tig --author="$*"
}
alias weather="curl wttr.in/beijin"
alias drop_cache="echo 3 | sudo tee /proc/sys/vm/drop_caches"
alias wifi="nmcli dev wifi show-password"
Loading

0 comments on commit e4ecc4e

Please sign in to comment.