Escape ~ correctly