diff --git a/.config/bash/module/Nix.sh b/.config/bash/module/Nix.sh index f0c9f65..648a9b8 100644 --- a/.config/bash/module/Nix.sh +++ b/.config/bash/module/Nix.sh @@ -63,14 +63,13 @@ function nix_clean() { [[ "${UID}" = 0 ]] && nix-store --gc } -# Spawn shell with nix environment, like LD support. +# Spawn shell with specified nix environment. `Main` is default. +# Usage: nix_shell [NAME] function nix_shell() { - nix-shell ~/.config/linux/Shell.nix -} + local name="${1,,}" + [[ "${name}" = "" ]] && name="main" -# Spawn temporary shell. -function shell() { - nix-shell -p "${@}" + nix_shell="${name}" nix-shell ~/.config/linux/shell/"${name^}".nix } # Autocomplete with available hosts. @@ -81,4 +80,14 @@ function _comp_hosts() { _autocomplete_first ${targets[@]} } +# Autocomplete with available shells. +function _comp_shells() { + local IFS=$'\n' + local targets=($(ls ~/.config/linux/shell/ | sed -e "s/.nix$//" | tr '[:upper:]' '[:lower:]')) + + _autocomplete_first ${targets[@]} + +} + complete -F _comp_hosts nix_update nix_upgrade +complete -F _comp_shells nix_shell diff --git a/.config/bash/module/Ps1.sh b/.config/bash/module/Ps1.sh index 160bce0..6959c90 100644 --- a/.config/bash/module/Ps1.sh +++ b/.config/bash/module/Ps1.sh @@ -72,6 +72,11 @@ function __prompt_command() { PS1+="\n" PS1+="\[${color_default}\]" + # Show nix shell name. + if [ -n "${nix_shell}" ]; then + PS1+="${color_white}${nix_shell}${color_default} " + fi + # Show remote connections. if [ -n "${SSH_TTY}" ]; then PS1+=">" diff --git a/.config/linux/Shell.nix b/.config/linux/shell/Main.nix similarity index 100% rename from .config/linux/Shell.nix rename to .config/linux/shell/Main.nix diff --git a/.doc/Bash.md b/.doc/Bash.md index 8a96acd..4c47d26 100644 --- a/.doc/Bash.md +++ b/.doc/Bash.md @@ -46,6 +46,7 @@ Command|Description `bootstrap_ffmpeg`|Install ffmpeg. `bootstrap_editorconfig`|Install Editorconfig file (with tabs) in current directory. `bootstrap_editorconfig_space [AMOUNT]`|Install Editorconfig file (with specified spaces, 8 by default) in current directory. +`bootstrap_flatpak`|Setup all the flatpak apps on the machine. ## Cd. @@ -113,6 +114,13 @@ Command|Description `dconf_load`|Load Gnome settings. `dconf_save [FILE]`|Dump Gnome settings into the file. Default name is `gnome.dconf`. Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`. +## Disk. + +Command|Description +---|--- +`df`|Show only physical drives info. +`du [DIRS]`|Show combined size in SI. Current dir by default. + ## Docker. Command|Description @@ -271,8 +279,7 @@ Command|Description `nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname. `nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname. `nix_clean`|Free up root space. -`nix_shell`|Spawn shell with nix environment, like LD support. -`shell`|Spawn temporary shell. +`nix_shell [NAME]`|Spawn shell with specified nix environment. `Main` is default. ## Notify.