Nix : Make nix_shell multi-module.
This commit is contained in:
parent
f56cf5c84c
commit
ad0cbb12f3
|
@ -63,14 +63,13 @@ function nix_clean() {
|
||||||
[[ "${UID}" = 0 ]] && nix-store --gc
|
[[ "${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() {
|
function nix_shell() {
|
||||||
nix-shell ~/.config/linux/Shell.nix
|
local name="${1,,}"
|
||||||
}
|
[[ "${name}" = "" ]] && name="main"
|
||||||
|
|
||||||
# Spawn temporary shell.
|
nix_shell="${name}" nix-shell ~/.config/linux/shell/"${name^}".nix
|
||||||
function shell() {
|
|
||||||
nix-shell -p "${@}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Autocomplete with available hosts.
|
# Autocomplete with available hosts.
|
||||||
|
@ -81,4 +80,14 @@ function _comp_hosts() {
|
||||||
_autocomplete_first ${targets[@]}
|
_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_hosts nix_update nix_upgrade
|
||||||
|
complete -F _comp_shells nix_shell
|
||||||
|
|
|
@ -72,6 +72,11 @@ function __prompt_command() {
|
||||||
PS1+="\n"
|
PS1+="\n"
|
||||||
PS1+="\[${color_default}\]"
|
PS1+="\[${color_default}\]"
|
||||||
|
|
||||||
|
# Show nix shell name.
|
||||||
|
if [ -n "${nix_shell}" ]; then
|
||||||
|
PS1+="${color_white}${nix_shell}${color_default} "
|
||||||
|
fi
|
||||||
|
|
||||||
# Show remote connections.
|
# Show remote connections.
|
||||||
if [ -n "${SSH_TTY}" ]; then
|
if [ -n "${SSH_TTY}" ]; then
|
||||||
PS1+=">"
|
PS1+=">"
|
||||||
|
|
11
.doc/Bash.md
11
.doc/Bash.md
|
@ -46,6 +46,7 @@ Command|Description
|
||||||
`bootstrap_ffmpeg`|Install ffmpeg.
|
`bootstrap_ffmpeg`|Install ffmpeg.
|
||||||
`bootstrap_editorconfig`|Install Editorconfig file (with tabs) in current directory.
|
`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_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.
|
## Cd.
|
||||||
|
|
||||||
|
@ -113,6 +114,13 @@ Command|Description
|
||||||
`dconf_load`|Load Gnome settings.
|
`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`.
|
`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.
|
## Docker.
|
||||||
|
|
||||||
Command|Description
|
Command|Description
|
||||||
|
@ -271,8 +279,7 @@ Command|Description
|
||||||
`nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname.
|
`nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname.
|
||||||
`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname.
|
`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname.
|
||||||
`nix_clean`|Free up root space.
|
`nix_clean`|Free up root space.
|
||||||
`nix_shell`|Spawn shell with nix environment, like LD support.
|
`nix_shell [NAME]`|Spawn shell with specified nix environment. `Main` is default.
|
||||||
`shell`|Spawn temporary shell.
|
|
||||||
|
|
||||||
## Notify.
|
## Notify.
|
||||||
|
|
||||||
|
|
Reference in a new issue