From 3000da50139ff3b044c5742140bc1ede8e3f4ad6 Mon Sep 17 00:00:00 2001 From: Mike Vink <59492084+ivi-vink@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:19:59 +0100 Subject: fix git and nushell --- mut/bin/desktop-open-pipe | 18 ++++------ mut/bin/xdg-open | 2 +- mut/git/config | 25 +++++++++++++ mut/git/github | 2 ++ mut/git/ignore | 6 ++++ mut/nushell/config.nu | 10 +++--- mut/nushell/env.nu | 91 +++++++++++++++++++++++++++++++++++++++-------- 7 files changed, 122 insertions(+), 32 deletions(-) create mode 100644 mut/git/config create mode 100644 mut/git/github create mode 100644 mut/git/ignore (limited to 'mut') diff --git a/mut/bin/desktop-open-pipe b/mut/bin/desktop-open-pipe index 0ef1901..796bc5b 100755 --- a/mut/bin/desktop-open-pipe +++ b/mut/bin/desktop-open-pipe @@ -1,13 +1,7 @@ -#!/usr/bin/env bash -name="$HOME/.cache/desktop-open.pipe" -while true; do - { - /nix/store/zcw13r2mmpzlnv2yvfl13mcpky3hivq1-system-path/bin/xdg-open "$(cat "$name")" -} >/dev/null 2>&1 -done - -finish () { - rm -vf "$name" +#!/usr/bin/env nu +echo listening for open commands +loop { + let line = nc -l 127.0.0.1 1994 + echo $line | save --append /tmp/debuglogs + ^open $line } - -trap finish EXIT diff --git a/mut/bin/xdg-open b/mut/bin/xdg-open index 6a5d254..ca18836 100755 --- a/mut/bin/xdg-open +++ b/mut/bin/xdg-open @@ -1,2 +1,2 @@ #!/bin/bash -echo "$@" | tee "$HOME/.cache/desktop-open.pipe" +nu --commands "^echo $1 | nc 127.0.0.1 1994 | echo" diff --git a/mut/git/config b/mut/git/config new file mode 100644 index 0000000..9d9b277 --- /dev/null +++ b/mut/git/config @@ -0,0 +1,25 @@ +[commit] + gpgsign = false + +[gpg] + format = "ssh" + +[merge] + tool = "fugitive" + +[mergetool "fugitive"] + cmd = "vim -f -c \"Gdiff\" \"$MERGED\"" + +[user] + email = "ivi@vinkies.net" + name = "Mike Vink" + signingKey = "/Users/ivi/.ssh/id_ed25519_sk.pub" + +[worktree] + guessRemote = true + +[includeIf "hasconfig:remote.*.url:git@github.com:**/**"] + path = "/nix-config/mut/git/github" + +[includeIf "hasconfig:remote.*.url:https://github.com/**/**"] + path = "/nix-config/mut/git/github" diff --git a/mut/git/github b/mut/git/github new file mode 100644 index 0000000..421194d --- /dev/null +++ b/mut/git/github @@ -0,0 +1,2 @@ +[user] + email = "59492084+ivi-vink@users.noreply.github.com" diff --git a/mut/git/ignore b/mut/git/ignore new file mode 100644 index 0000000..1ea4fc3 --- /dev/null +++ b/mut/git/ignore @@ -0,0 +1,6 @@ +/.direnv/ +/.envrc +/.env +.vimsession.vim +tfplan +plan diff --git a/mut/nushell/config.nu b/mut/nushell/config.nu index 38decfd..d47f885 100644 --- a/mut/nushell/config.nu +++ b/mut/nushell/config.nu @@ -900,10 +900,10 @@ $env.config = { ] } -if ($"($env.HOME)/.cache/wal/sequences" | path exists) { ^cat ~/.cache/wal/sequences } +if ("~/.cache/wal/sequences" | path exists) { ^cat ~/.cache/wal/sequences } source ~/.cache/zoxide.nu -if ($"($env.HOME)/.cache/starship.nu" | path exists) { source ~/.cache/starship.nu } -if ($"($env.HOME)/.cache/carapace.nu" | path exists) { source ~/.cache/carapace.nu } +if ("~/.cache/starship.nu" | path exists) { source ~/.cache/starship.nu } +if ("~/.cache/carapace.nu" | path exists) { source ~/.cache/carapace.nu } $env.K9S_DEFAULT_PF_ADDRESS = "0.0.0.0" $env.config.show_banner = false @@ -913,7 +913,7 @@ alias k = kubectl alias d = docker alias t = terraform -let pistarchio_dir = $"($env.HOME)/Programming/Pionative/pistarchio" +let pistarchio_dir = "~/Programming/Pionative/pistarchio" | path expand $env.PISTARCHIO_STACKS_DIR = $pistarchio_dir + "/stacks" $env.PISTARCHIO_LIBRARY_DIR = $pistarchio_dir + "/library" -$env.PISTARCHIO_VENDOR_DESTINATION_DIR = $pistarchio_dir + "/../clients" +$env.PISTARCHIO_VENDOR_DESTINATION_DIR = ($pistarchio_dir + "/../clients") | path expand diff --git a/mut/nushell/env.nu b/mut/nushell/env.nu index ac0ac47..435a090 100644 --- a/mut/nushell/env.nu +++ b/mut/nushell/env.nu @@ -86,6 +86,70 @@ $env.NU_PLUGIN_DIRS = [ ($nu.default-config-dir | path join 'plugins') # add /plugins ] +# To load from a custom file you can use: +# source ($nu.default-config-dir | path join 'custom.nu') + +let darwin: bool = (uname | get operating-system) == "Darwin" +let nix: bool = "/nix" | path exists + +if $darwin and $nix { + $env.__NIX_DARWIN_SET_ENVIRONMENT_DONE = 1 + + $env.PATH = [ + $"($env.HOME)/.nix-profile/bin" + $"/etc/profiles/per-user/($env.USER)/bin" + "/run/current-system/sw/bin" + "/nix/var/nix/profiles/default/bin" + "/usr/local/bin" + "/usr/bin" + "/usr/sbin" + "/bin" + "/sbin" + ] + $env.EDITOR = "VIM" + $env.NIX_PATH = [ + $"darwin-config=($env.HOME)/.nixpkgs/darwin-configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" + ] + $env.NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt" + $env.PAGER = "less -R" + $env.TERMINFO_DIRS = [ + $"($env.HOME)/.nix-profile/share/terminfo" + $"/etc/profiles/per-user/($env.USER)/share/terminfo" + "/run/current-system/sw/share/terminfo" + "/nix/var/nix/profiles/default/share/terminfo" + "/usr/share/terminfo" + ] + $env.XDG_CONFIG_DIRS = [ + $"($env.HOME)/.nix-profile/etc/xdg" + $"/etc/profiles/per-user/($env.USER)/etc/xdg" + "/run/current-system/sw/etc/xdg" + "/nix/var/nix/profiles/default/etc/xdg" + ] + $env.XDG_DATA_DIRS = [ + $"($env.HOME)/.nix-profile/share" + $"/etc/profiles/per-user/($env.USER)/share" + "/run/current-system/sw/share" + "/nix/var/nix/profiles/default/share" + ] + $env.TERM = $env.TERM + $env.NIX_USER_PROFILE_DIR = $"/nix/var/nix/profiles/per-user/($env.USER)" + $env.NIX_PROFILES = [ + "/nix/var/nix/profiles/default" + "/run/current-system/sw" + $"/etc/profiles/per-user/($env.USER)" + $"($env.HOME)/.nix-profile" + ] + + if ($"($env.HOME)/.nix-defexpr/channels" | path exists) { + $env.NIX_PATH = ($env.PATH | split row (char esep) | append $"($env.HOME)/.nix-defexpr/channels") + } + + if (false in (ls -l `/nix/var/nix`| where type == dir | where name == "/nix/var/nix/db" | get mode | str contains "w")) { + $env.NIX_REMOTE = "daemon" + } +} + # To add entries to PATH (on Windows you might use Path), you can use the following pattern: # $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') # An alternate way to add entries to $env.PATH is to use the custom command `path add` @@ -95,33 +159,32 @@ use std "path add" # path add /some/path # path add ($env.CARGO_HOME | path join "bin") try { - if (uname | get "operating-system") == "Darwin" { + if $darwin { $env.PATH = ["/opt/homebrew/bin" "/opt/X11/bin" "/opt/local/bin" "/opt/local/sbin"] ++ $env.PATH } } path add ($env.HOME | path join ".local" "bin") $env.PATH = ($env.PATH | uniq) -# To load from a custom file you can use: -# source ($nu.default-config-dir | path join 'custom.nu') +$env.XDG_CACHE_HOME = "~/.cache" | path expand +$env.XDG_DATA_HOME = "~/.local/share" | path expand +$env.XDG_CONFIG_HOME = "~/.config" | path expand if (which carapace | is-not-empty) { - $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # optional - mkdir ~/.cache/carapace - carapace _carapace nushell | save --force ~/.cache/carapace.nu + $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # optional + carapace _carapace nushell | save --force ~/.cache/carapace.nu +} +if (which zoxide | is-not-empty) { + zoxide init nushell --cmd=cd | save --force ~/.cache/zoxide.nu +} +if (which starship | is-not-empty) { + starship init nu | save --force ~/.cache/starship.nu } -mkdir ~/.cache/zoxide -zoxide init nushell --cmd=cd | save --force ~/.cache/zoxide.nu -starship init nu | save --force ~/.cache/starship.nu -if (not ("/var/run/docker.sock" | path exists)) and (not ((uname | get operating-system) == "Darwin")) { +if (not ("/var/run/docker.sock" | path exists)) and (not darwin) { $env.DOCKER_HOST = $"unix://($env | default $"/run/($env.USER)" XDG_RUNTIME_DIR | get XDG_RUNTIME_DIR)/docker.sock" } -$env.XDG_CACHE_HOME = $"($env.HOME)/.cache" -$env.XDG_DATA_HOME = $"($env.HOME)/.local/share" -$env.XDG_CONFIG_HOME = $"($env.HOME)/.config" - # if not ("/.dockerenv" | path exists) { # do --env { # let ssh_agent_file = ( -- cgit v1.2.3