Skip to content

Commit

Permalink
fixes and things
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeebswihart committed Mar 10, 2019
1 parent bd03fe2 commit 660ca3f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 33 deletions.
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
],
"sources": {
"https://github.com/larkery/zsh-histdb.git": "~/.zsh-histdb/",
"https://github.com/asdf-vm/asdf.git": {
"destination": "~/.asdf",
"post-install": "cd ~/.asdf && git checkout \"$(git describe --abbrev=0 --tags)\""
},
"https://github.com/tarjoilija/zgen": {
"symlinks": {
"zgen.zsh": "~/.zgen.zsh",
Expand All @@ -143,7 +147,7 @@
"launchagents/*.plist":"~/Library/LaunchAgents/",
"hammerspoon/*": "~/.hammerspoon/"
},
"after-scripts": [
"post-install": [
"brew cleanup",
"find ~/Library/LaunchAgents -name '*.plist' | xargs launchctl load"
]
Expand Down
2 changes: 1 addition & 1 deletion dots/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi
# Completions
fpath=(~/.zsh $fpath)

# load fresh-built files
# load built files
source ~/.config/zsh/config.sh

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
Expand Down
16 changes: 1 addition & 15 deletions hammerspoon/todo-scripts/com.reinvented.KeepIt.scpt
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
tell application "Keep It"
set theSelection to the selected items
if length of theSelection = 1 then
set theItem to the first item of theSelection
set itemName to name of theItem
set itemLink to "keepit://link?item=" & id of theItem
tell application "Things3" to show quick entry panel with properties {name:itemName, notes:itemLink}
else
repeat with theItem in theSelection
set itemName to name of theItem
set itemLink to link URL of theItem
tell application "Things3" to make new to do with properties {name:"Look at " & itemName, notes:itemLink}
end repeat
end if
end tell
tell application "Keep It" set theSelection to the selected items if length of theSelection = 1 then set theItem to the first item of theSelection set itemName to name of theItem set itemLink to "keepit://link?item=" & id of theItem tell application "Things3" to show quick entry panel with properties {name:itemName, notes:itemLink} else repeat with theItem in theSelection set itemName to name of theItem set itemLink to link of theItem tell application "Things3" to make new to do with properties {name:"Look at " & itemName, notes:itemLink} end repeat end ifend tell
Expand Down
35 changes: 19 additions & 16 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,24 @@ def install_sources(sources):
# TODO: handle the rest as normal
mkdir(os.path.expanduser('~/.config/zsh/repos'))
for source, config in sources.items():
print("Cloning {}".format(source))
if isinstance(config, str):
# TODO: clone directly here
config = os.path.expanduser(config)
if not os.path.isdir(config):
runcmd("git clone {} {}".format(source, config))
else:
with chdir(config):
runcmd("git pull")
else:
config = {"destination": config}
if isinstance(config, dict):
site, user, repo = getpath(source)
repo_dir = os.path.expanduser("~/.config/zsh/repos/{}/{}-{}".format(site, user, repo))
repo_dir = os.path.expanduser(config.get('destination', "~/.config/zsh/repos/{}/{}-{}".format(site, user, repo)))
if not os.path.isdir(repo_dir):
print("Cloning {}".format(source))
runcmd("git clone {} {}".format(source, repo_dir))
else:
print("Updating {}".format(source))
with chdir(repo_dir):
runcmd("git pull")
runcmd("git pull origin master")
# Add the repo dir
symlinks = {'{}/{}'.format(repo_dir, k): v for k, v in config.get('symlinks', {}).items()}
install_symlinks(symlinks)
post_install(config)
else:
raise TypeError("Invalid source block of type '{}'".format(type(config)))


def install_symlinks(config):
Expand Down Expand Up @@ -125,7 +123,7 @@ def install_brew(pkgs, tags):
to_install = set(pkgs) - already_installed
if to_install:
print('Installing {} homebrew formulae'.format(len(to_install)))
with NamedTemporaryFile() as tf:
with NamedTemporaryFile('w') as tf:
tf.write('\n'.join(to_install))
tf.flush()
runcmd('xargs <{} brew install'.format(tf.name))
Expand Down Expand Up @@ -170,6 +168,14 @@ def check_install_deps():
runcmd('brew install mas')


def post_install(config):
scripts = config.get('post-install', [])
if isinstance(scripts, str):
scripts = [scripts]
for script in scripts:
runcmd(script)


def install_from_config(config_file, tags):
with open(config_file, 'r') as f:
config = json.loads(f.read(), object_pairs_hook=collections.OrderedDict)
Expand All @@ -185,10 +191,7 @@ def install_from_config(config_file, tags):
install_mas(config.get('mas', []), tags)
install_sources(config.get('sources', {}))
install_symlinks(config.get('symlinks', {}))

for script in config.get('after-scripts', []):
runcmd(script)

post_install(config)

if __name__ == '__main__':
if len(sys.argv) < 2:
Expand Down
3 changes: 3 additions & 0 deletions zsh/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if [[ ! -z "$GOPATH" ]]; then
fi

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
test -f ~/.asdf/asdf.sh && source ~/.asdf/asdf.sh
test -f ~/.asdf/completions/asdf.bash && source ~/.asdf/completions/asdf.bash


#Setting path -- my local prefix comes first *always*
PATH="$HOME/.local/bin:$BASEPATH"
Expand Down

0 comments on commit 660ca3f

Please sign in to comment.