diff --git a/src/user/modules/bash/config/bashrc.nix b/src/user/modules/bash/config/bashrc.nix index 2ebcc48..2ea1694 100644 --- a/src/user/modules/bash/config/bashrc.nix +++ b/src/user/modules/bash/config/bashrc.nix @@ -1,30 +1,6 @@ '' export DIRENV_LOG_FORMAT= -function cdg() { - if [[ $1 == "--help" ]]; then - echo "A simple utility for navigating to the root of a git repo" - return 0 - fi - - # Check for invalid command - if [[ -n "$1" ]]; then - echo "Invalid command: $1. Try 'cdg --help'." - return 1 - fi - - local root_dir - root_dir=$(git rev-parse --show-toplevel 2>/dev/null) - local git_status=$? - - if [ $git_status -ne 0 ]; then - echo "Error: Not a git repo." - return 1 - fi - - cd "$root_dir" -} - function penpot() { case "$1" in run) diff --git a/src/user/modules/bash/config/prompt.nix b/src/user/modules/bash/config/prompt.nix index 9d10389..63eaa49 100644 --- a/src/user/modules/bash/config/prompt.nix +++ b/src/user/modules/bash/config/prompt.nix @@ -12,7 +12,6 @@ check_ssh() { return 0 fi } - ${optionalString git.enable '' add_icon() { local icon=$1 @@ -91,7 +90,6 @@ check_project() { fi } ''} - function set_prompt() { local green_arrow="\[\033[01;32m\]>> " local white_text="\[\033[00m\]" @@ -107,7 +105,7 @@ function set_prompt() { check_project ''} - PS1="$ssh_PS1\n$working_dir$green_arrow$white_text" + PS1="$ssh_PS1\n$working_dir\n$green_arrow$white_text" ${optionalString git.enable '' PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text" diff --git a/src/user/modules/git/config/cdg.nix b/src/user/modules/git/config/cdg.nix new file mode 100644 index 0000000..37f806c --- /dev/null +++ b/src/user/modules/git/config/cdg.nix @@ -0,0 +1,25 @@ +'' +function cdg() { + if [[ $1 == "--help" ]]; then + echo "A simple utility for navigating to the root of a git repo" + return 0 + fi + + # Check for invalid command + if [[ -n "$1" ]]; then + echo "Invalid command: $1. Try 'cdg --help'." + return 1 + fi + + local root_dir + root_dir=$(git rev-parse --show-toplevel 2>/dev/null) + local git_status=$? + + if [ $git_status -ne 0 ]; then + echo "Error: Not a git repo." + return 1 + fi + + cd "$root_dir" +} +'' diff --git a/src/user/modules/git/default.nix b/src/user/modules/git/default.nix index 54e4328..863dde9 100644 --- a/src/user/modules/git/default.nix +++ b/src/user/modules/git/default.nix @@ -1,7 +1,9 @@ { lib, pkgs, config, ... }: with lib; - let cfg = config.modules.user.git; +let + cfg = config.modules.user.git; + bash = config.modules.user.bash; in { options.modules.user.git = { enable = mkEnableOption "user.git"; }; @@ -19,5 +21,9 @@ in home.packages = with pkgs; [ git-crypt ]; + + programs.bash.initExtra = mkAfter '' + ${import ./config/cdg.nix} + ''; }; }