Skip to content

Instantly share code, notes, and snippets.

@sparkydogX
Last active March 12, 2019 05:03
Show Gist options
  • Save sparkydogX/53dfc7ad252f0ee08ab5a190883ab06e to your computer and use it in GitHub Desktop.
Save sparkydogX/53dfc7ad252f0ee08ab5a190883ab06e to your computer and use it in GitHub Desktop.
通过打开firefox标签初始化gitment
import sys
import os
import subprocess
ROOTDIR = '<you path>/hexo/public'
YEAR = ['2017','2018','2019']
URLList = []
BEGIN = 0
NUM = 10
if __name__ == '__main__':
for year in YEAR:
months = os.listdir(os.path.join(ROOTDIR,year))
for month in months:
dates = os.listdir(os.path.join(ROOTDIR,year,month))
for date in dates:
pages = os.listdir(os.path.join(ROOTDIR,year,month,date))
for page in pages:
url = "<your site>/" + os.path.join(year,month,date,page)
URLList.append(url)
for i in range(BEGIN,min(BEGIN+NUM,len(URLList))):
url = URLList[i]
cmd = "open -a firefox " + url # macOS
# cmd = "firefox " + url # Ubuntu
current_git_branch = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment