From 73a55130911dcde9d43ceb3be713d88fe50f8769 Mon Sep 17 00:00:00 2001 From: johannst Date: Fri, 6 Apr 2018 16:45:15 +0900 Subject: bashrc added save/restore functions --- bashrc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bashrc b/bashrc index ca583ec..f1987d0 100644 --- a/bashrc +++ b/bashrc @@ -166,3 +166,28 @@ function perr() { } #}}} +#{{{ save/restore settings + +function save_bash_options() { + local backup_file=$1 + set +o >> $backup_file +} + +function save_bash_exports() { + local backup_file=$1 + export -p >> $backup_file +} + +function save_bash() { + local backup=${1:-~/.saved_bash_env} + :> $backup + save_bash_options $backup + save_bash_exports $backup +} + +function restore_bash() { + local backup=${1:-~/.saved_bash_env} + source $backup +} + +#}}} -- cgit v1.2.3