diff --git a/Morskie Oko.jpg b/background-image.jpg similarity index 100% rename from Morskie Oko.jpg rename to background-image.jpg diff --git a/home.nix b/home.nix index cda5a84..4d15b73 100644 --- a/home.nix +++ b/home.nix @@ -57,5 +57,6 @@ executable = true; source = "${./git-identity.sh}"; }; + home.file.".background-image".source = "${./background-image.jpg}"; }; } \ No newline at end of file diff --git a/platforms/linux/home.nix b/platforms/linux/home.nix index 297ba45..c8a228b 100644 --- a/platforms/linux/home.nix +++ b/platforms/linux/home.nix @@ -32,6 +32,7 @@ wl-clipboard zotero signal-desktop + freetube ]; dconf.settings = { @@ -84,6 +85,4 @@ "picture-uri" = "${config.home.homeDirectory}/.background-image"; }; }; - - home.file.".background-image".source = "${./.}/Morskie Oko.jpg"; } \ No newline at end of file diff --git a/programs/bash.nix b/programs/bash.nix index 66bad34..4aa1325 100644 --- a/programs/bash.nix +++ b/programs/bash.nix @@ -1,33 +1,41 @@ {config, lib, pkgs, inputs, os, ...} : { programs.bash.enable = true; - programs.bash.bashrcExtra = '' - if [ -n "$PS1" ]; then - NEW_PROMPT_COMMAND=' - MY_PWD="$PWD" - [[ "$MY_PWD" =~ ^"$HOME"(/|$) ]] && MY_PWD="~''${MY_PWD#$HOME}" - TRIMMED_PWD=''${MY_PWD: -40}; - TRIMMED_PWD=''${TRIMMED_PWD:-$MY_PWD} - [[ "''${#MY_PWD}" -ge 41 ]] && TRIMMED_PWD="…$TRIMMED_PWD" + programs.bash.bashrcExtra = lib.concatStrings [ + '' + if [ -n "$PS1" ]; then + NEW_PROMPT_COMMAND=' + MY_PWD="$PWD" + [[ "$MY_PWD" =~ ^"$HOME"(/|$) ]] && MY_PWD="~''${MY_PWD#$HOME}" + TRIMMED_PWD=''${MY_PWD: -40}; + TRIMMED_PWD=''${TRIMMED_PWD:-$MY_PWD} + [[ "''${#MY_PWD}" -ge 41 ]] && TRIMMED_PWD="…$TRIMMED_PWD" - SHELL_PREFIX="" - [[ -n "$IN_NIX_SHELL" ]] && SHELL_PREFIX="$SHELL_PREFIX " - [[ -n "$AWS_VAULT" ]] && SHELL_PREFIX="$SHELL_PREFIX 🔓︎" - [[ -n "$FLUTTER_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ✌︎" - [[ -n "$REACTNATIVE_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ⚛" - ' - if [ -n "''${PROMPT_COMMAND// /}" ]; then - PROMPT_COMMAND="$PROMPT_COMMAND -$NEW_PROMPT_COMMAND" - else - PROMPT_COMMAND="$NEW_PROMPT_COMMAND" - fi - unset NEW_PROMPT_COMMAND + SHELL_PREFIX="" + [[ -n "$IN_NIX_SHELL" ]] && SHELL_PREFIX="$SHELL_PREFIX " + [[ -n "$AWS_VAULT" ]] && SHELL_PREFIX="$SHELL_PREFIX 🔓︎" + [[ -n "$FLUTTER_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ✌︎" + [[ -n "$REACTNATIVE_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ⚛" + ' + if [ -n "''${PROMPT_COMMAND// /}" ]; then + PROMPT_COMMAND="$PROMPT_COMMAND + $NEW_PROMPT_COMMAND" + else + PROMPT_COMMAND="$NEW_PROMPT_COMMAND" + fi + unset NEW_PROMPT_COMMAND - export PS1="[\t \[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]]"'$SHELL_PREFIX'" \[\e[36m\]"'$TRIMMED_PWD'"\[\e[m\] \$ " - fi + export PS1="[\t \[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]]"'$SHELL_PREFIX'" \[\e[36m\]"'$TRIMMED_PWD'"\[\e[m\] \$ " + fi + '' + + # On mac we have to import brew + (if (os == "darwin") then '' + eval "$(/opt/homebrew/bin/brew shellenv)" + '' else '' + + '') + ]; - eval "$(/opt/homebrew/bin/brew shellenv)" - ''; programs.bash.shellAliases = { chmod = "chmod --preserve-root"; chown = "chown --preserve-root"; diff --git a/programs/helix.nix b/programs/helix.nix index 20ea994..8a72ee6 100644 --- a/programs/helix.nix +++ b/programs/helix.nix @@ -28,4 +28,40 @@ } ; } ; }; + + home.packages = let + edit = (pkgs.writeShellApplication { + name = "edit"; + text = '' + CMND=$(cat <<'END' + BUFFER_NAME=''$(echo -n "''$PWD" | xxd -ps -c 200 | tr -d '\n' | shasum | head -c -4) + + tmux -L "$BUFFER_NAME" has-session -t "$BUFFER_NAME" || { + tmux -L "$BUFFER_NAME" new-session -d -s "$BUFFER_NAME" "BUFFER_NAME=$BUFFER_NAME EDITOR=wraphx lf" + tmux -L "$BUFFER_NAME" set -g status off + tmux -L "$BUFFER_NAME" set -g pane-border-style fg=#0c0c0c + tmux -L "$BUFFER_NAME" set -g pane-active-border-style "bg=default fg=#0c0c0c" + } + + tmux -L "$BUFFER_NAME" attach -t "$BUFFER_NAME" + END + ) + + if [ -f "shell.nix" ] && [ -z ''${IN_NIX_SHELL+x} ]; then + nix-shell --command "$CMND" + else + eval "$CMND" + fi + ''; + }); + wraphx = (pkgs.writeShellApplication { + name = "wraphx"; + text = '' + test "$(tmux -L "$BUFFER_NAME" list-panes | wc -l)" -eq 1 && { + tmux -L "$BUFFER_NAME" split-window -h hx "$1" + } + ''; + }); + in [ edit wraphx ]; + } \ No newline at end of file diff --git a/programs/kakoune.nix b/programs/kakoune.nix index ba9be1e..29ba8f5 100644 --- a/programs/kakoune.nix +++ b/programs/kakoune.nix @@ -189,7 +189,7 @@ let }); }); kak-wrap = (writeShellApplication { - name = "edit"; + name = "edit-kak"; runtimeInputs = [ myKakoune ]; text = '' CMND=$(cat <<'END'