diff --git a/hm/scripts/.bsh/bashrc_unsortable b/hm/scripts/.bsh/bashrc_unsortable index 8ae2abe..d00f8a7 100644 --- a/hm/scripts/.bsh/bashrc_unsortable +++ b/hm/scripts/.bsh/bashrc_unsortable @@ -23,3 +23,13 @@ else col=33; fi export PS1="\[\e]2;\u@\H \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]\h \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[0m\] " + +# Replace the content of a symlinked file +# Useful for ad-hoc replacing of Nix config files +subl() { + [ -f "$1" ] || return 3 + [ -h "$1" ] || return 4 + src="$(readlink -f "$1")" + rm "$1" + cat "$src" > "$1" +} diff --git a/hm/shell/zshrc.sh b/hm/shell/zshrc.sh index 5130f51..d000078 100644 --- a/hm/shell/zshrc.sh +++ b/hm/shell/zshrc.sh @@ -110,3 +110,12 @@ setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording en unsetopt HIST_VERIFY # Don't execute immediately upon history expansion. unsetopt HIST_BEEP # Beep when accessing nonexistent history. +# Replace the content of a symlinked file +# Useful for ad-hoc replacing of Nix config files +subl() { + [ -f "$1" ] || return 3 + [ -h "$1" ] || return 4 + src="$(readlink -f "$1")" + rm "$1" + < "$src" > "$1" +}