Skip to content

Instantly share code, notes, and snippets.

@c0ns0le
Forked from kppullin/config.fish
Created May 13, 2021 12:58
Show Gist options
  • Save c0ns0le/42bb97551a846bce76c9ff89c022dbe4 to your computer and use it in GitHub Desktop.
Save c0ns0le/42bb97551a846bce76c9ff89c022dbe4 to your computer and use it in GitHub Desktop.

Revisions

  1. @kppullin kppullin created this gist May 16, 2020.
    30 changes: 30 additions & 0 deletions config.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #
    # This fish config sets up a working `gnome-keyring` on WSL2.
    # I imagine it will work with WSL1 as well, perhaps after adjusting the `DISPLAY` value.
    #
    # Based off this bash script: https://askubuntu.com/questions/815327/running-gnome-keyring-on-wsl-windows-subsystem-for-linux
    # Tested and working with `aws-vault` and `jetbrains-toolbox`.
    #

    # Be sure your x server is running!!!
    set -x DISPLAY (cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

    pgrep dbus-daemon > /dev/null

    if test $status -eq 1
    dbus-launch --sh-syntax | read --line bus_address ignored bus_pid bus_windowid

    set -Ux DBUS_SESSION_BUS_ADDRESS (string match -r "'(.*)'" $bus_address)[2]
    set -Ux DBUS_SESSION_BUS_ID (string match -r "=(.*);" $bus_pid)[2]
    set -Ux DBUS_SESSION_BUS_WINDOWID (string match -r "=(.*);" $bus_windowid)[2]
    end

    # pgrep limited to 15 chars, so truncate `daemon`
    pgrep gnome-keyring-d > /dev/null

    if test $status -eq 1
    gnome-keyring-daemon | read --line gnome_keyring_control ssh_auth_sock

    set -Ux GNOME_KEYRING_CONTROL (string split -m 1 = $gnome_keyring_control)[2]
    set -Ux SSH_AUTH_SOCK (string split -m 1 = $ssh_auth_sock)[2]
    end