Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # fresh-chrome
  4. #
  5. # Use this script on Linux to launch a new instance of Google Chrome
  6. # with its own empty cache, cookies, and user configuration.
  7. #
  8. # The first time you run this script, it will launch a new Google
  9. # Chrome instance with a permanent user-data directory, which you can
  10. # customize below. Perform any initial setup you want to keep on every
  11. # new Chrome instance, such as adding bookmarks and extensions. Then
  12. # quit this Chrome instance with Command-Q or by selecting "Quit" from
  13. # the "Chrome" menu. (The red "close" button is not sufficient.)
  14. #
  15. # AFTER that, every time you run this script it will launch a new
  16. # Google Chrome instance with a temporary user-data directory copied
  17. # from the one you set up the first time you ran this script. Every
  18. # new instance of Google Chrome launched by this script will be
  19. # completely isolated from the others.
  20.  
  21. # Modified to work on Linux (tested on Debian) and add optional timezone command-line argument
  22.  
  23. # Get the system default timezone to use as a fallback
  24. if [ -f /etc/timezone ]; then
  25. timezone=`cat /etc/timezone`
  26. elif [ -h /etc/localtime ]; then
  27. timezone=`readlink /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///"`
  28. else
  29. checksum=`md5sum /etc/localtime | cut -d' ' -f1`
  30. timezone=`find /usr/share/zoneinfo/ -type f -exec md5sum {} \; | grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1`
  31. fi
  32.  
  33. # Check for timezone argument
  34. if [ -z "$1" ]
  35. then
  36. echo "No timezone supplied, using system default." >&2;
  37. else
  38. timezone=$1
  39. fi
  40.  
  41. export TZ="$timezone"
  42.  
  43. # Permanent directory to store the user-data directory of your 'fresh'
  44. # Chrome configuration.
  45. fresh_dir="$HOME/.fresh-chrome"
  46.  
  47. # Temporary directory in which to create new user-data directories for
  48. # temporary Chrome instances.
  49. tmp_dir="/tmp"
  50.  
  51. ### Main script begins
  52.  
  53. set -e
  54.  
  55. timestamp=`date +%Y%m%d%H%M%S`
  56.  
  57. if [[ -e "$fresh_dir" ]]; then
  58. user_dir="$tmp_dir/chrome-$timestamp-$RANDOM"
  59. cp -r "$fresh_dir" "$user_dir"
  60. google-chrome --args "--user-data-dir=$user_dir"
  61. else
  62. google-chrome --args "--user-data-dir=$fresh_dir"
  63. fi
  64.  
  65.  
  66. # The MIT License (MIT)
  67. #
  68. # Copyright (c) 2013 Stuart Sierra
  69. #
  70. # Permission is hereby granted, free of charge, to any person
  71. # obtaining a copy of this software and associated documentation files
  72. # (the "Software"), to deal in the Software without restriction,
  73. # including without limitation the rights to use, copy, modify, merge,
  74. # publish, distribute, sublicense, and/or sell copies of the Software,
  75. # and to permit persons to whom the Software is furnished to do so,
  76. # subject to the following conditions:
  77. #
  78. # The above copyright notice and this permission notice shall be
  79. # included in all copies or substantial portions of the Software.
  80. #
  81. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  82. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  83. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  84. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  85. # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  86. # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  87. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  88. # SOFTWARE.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement