'cap' func to temporarily replace system files

* to replace: cap bin/ruby /usr/bin/ruby
* to restore: cap /usr/bin/ruby
This commit is contained in:
2013-03-19 01:19:51 +03:00
parent 9e091e326f
commit 890c5870a4
+12
View File
@@ -145,6 +145,18 @@ function cdls() {
ls "$@"
}
function cap() {
local bakdir="$HOME/.cap-stash"
mkdir -p "$bakdir"
local bakfile="$bakdir/${1//\//%}"
if [ "$#" -gt 1 ]; then
cp -p "$1" "$bakfile"
sudo mv "$2" "$1"
else
sudo mv "$bakfile" "$1"
fi
}
function fin() {
local filename="$1"
[ $# -gt 1 ] && shift