Skip to content

Instantly share code, notes, and snippets.

View bingzhangdai's full-sized avatar

Bingzhang Dai bingzhangdai

  • Shanghai
  • 08:39 (UTC +08:00)
View GitHub Profile
@bingzhangdai
bingzhangdai / git_branch.md
Last active January 7, 2024 17:31
Fasted way to get git branch

Sometimes, we want to show current git branch in Bash prompt. git symbolic-ref --short -q HEAD is too slow, especially in WSL. Here is a pure Bash version to print git branch.

function _get_git_branch() {
    local _head_file _head
    local _dir="$PWD"

    while [[ -n "$_dir" ]]; do
        _head_file="$_dir/.git/HEAD"
        if [[ -f "$_dir/.git" ]]; then
@bingzhangdai
bingzhangdai / wsl.md
Last active March 3, 2024 03:19
Common settings for WSL

The common settings for WSL

These are recommended steps for setting up your WSL

Mount disk C: with "metadata" flag

This will allow users to set the owner and group of files using chmod/chown and modify read/write/execute permissions in WSL.

  1. unmount drvfs
@bingzhangdai
bingzhangdai / 9p_virtio.md
Created July 18, 2020 08:13
Set up VirtFS (9p virtio) for sharing files between Guest and Host on Proxmox VE

How-to

  1. On Host(PVE), edit /etc/pve/qemu-server/VMID.conf
args: -fsdev local,security_model=mapped,id=fsdev0,path=/path/to/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare

This tells qemu to create a 9pvirtio device exposing the mount_tag hostshare (just a name to identify the mount point). That device is coupled to an fsdev named fsdev0, which specifies which portion of the host filesystem we are sharing, and in which mode.