Skip to content

Instantly share code, notes, and snippets.

@kennedyj
Created August 6, 2013 17:34
Show Gist options
  • Save kennedyj/6166655 to your computer and use it in GitHub Desktop.
Save kennedyj/6166655 to your computer and use it in GitHub Desktop.
Change wallet database for acrylic apps wallet on mac. http://www.acrylicapps.com/wallet/mac/
#!/bin/bash
# setup path to the applications expected path
export wallet_db="/Users/$(whoami)/Library/Containers/com.acrylic.Wallet/Data/Library/Application Support/Wallet/Database.wallet"
# configure any wallets to be used. each item in the list must also have a variable that matches
# ie: personal wallet_personal_db
export wallet_db_list=( personal group other )
export wallet_personal_db="/Users/$(whoami)/Wallets/Personal.wallet"
export wallet_group_db="/Users/$(whoami)/Wallets/Group Database.wallet"
export wallet_other_db="/Users/$(whoami)/Documents/Other Database.wallet"
wallet_use() {
if [ "$wallet_current_name" == "$1" ]
then
echo "already using that wallet"
else
export wallet_current_name=$1
name="wallet_$1_db"
eval target=\${$name}
ln -f "$target" "$wallet_db"
echo "Switched to $1"
fi
}
wallet_current() {
do_echo=$1
if [ -z "$do_echo" ]
then
do_echo=true
fi
# clear the current name
unset wallet_current_name
# prep some variables
_wallet_prefix="wallet_"
_wallet_suffix="_db"
# get the inode for the current wallet
wallet_db_inode=$(ls -il "$wallet_db" | awk '{print $1'})
for name in ${wallet_db_list[@]}
do
eval _wallet_target=\${"$_wallet_prefix$name$_wallet_suffix"}
# get inode for wallet
wallet_name_inode=$(ls -il "$_wallet_target" | awk '{print $1'})
if [ "$wallet_db_inode" == "$wallet_name_inode" ]
then
export wallet_current_name=$name
break
fi
done
if [ $do_echo == true ]
then
if [ -z "$wallet_current_name" ]
then
echo "Current wallet doesn't match a configured one"
else
echo "Using '$wallet_current_name'"
fi
fi
}
# set the current name variable without echo
wallet_current false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment