Skip to content

Commit

Permalink
Fix zsh sqlite history
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeebswihart committed May 27, 2020
2 parents c59b509 + 1b50fc8 commit c71edc7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
10 changes: 1 addition & 9 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,23 @@
"global",
"gnu-sed",
"httpie",
"imagemagick",
"jam",
"jq",
"leiningen",
"libnotify",
"librsvg",
"libssh2",
"libxml2",
"neovim",
"osquery",
"parallel",
"pkg-config",
"ripgrep",
"stubby",
"tag",
"terminal-notifier",
"texinfo",
"the_silver_searcher",
"tmux",
"unbound",
"vim",
"watchman",
"wget",
"xsv",
"yarn",
"youtube-dl",
"z3",
"zsh"
],
Expand Down
22 changes: 11 additions & 11 deletions config/karabiner/karabiner.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,16 @@
},
"ignore": false,
"manipulate_caps_lock_led": true,
"simple_modifications": []
"simple_modifications": [
{
"from": {
"key_code": "caps_lock"
},
"to": {
"key_code": "left_control"
}
}
]
}
],
"fn_function_keys": [
Expand Down Expand Up @@ -378,16 +387,7 @@
"delay_milliseconds_before_open_device": 1000
},
"selected": true,
"simple_modifications": [
{
"from": {
"key_code": "caps_lock"
},
"to": {
"key_code": "left_control"
}
}
],
"simple_modifications": [],
"virtual_hid_keyboard": {
"country_code": 0,
"mouse_key_xy_scale": 100
Expand Down
2 changes: 2 additions & 0 deletions dots/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ if [ -d "$HOME/.bash_it" ]; then
source $BASH_IT/bash_it.sh
fi
export ORGHOME='/Users/timods/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/org'

complete -C /usr/local/bin/nomad nomad
13 changes: 13 additions & 0 deletions hammerspoon/reload.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function reloadConfig(files)
doReload = false
for _,file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
end
end
myWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
hs.alert.show("Config loaded")
30 changes: 17 additions & 13 deletions hammerspoon/usb.lua
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
-- ~/.hammerspoon/usb.lua
local module = {}

local evtAdd = "added"
local evtRemove = "removed"
local fiion = "FiiO USB DAC-E17"
local bluen = "Blue Snowball "
local smodi = "Schiit Modi 3"
module.watcher = nil

function usbDeviceCallback(data)
-- TODO set audio output to the FiiO DAC
-- TODO set audio input to the blue snowball
pn = data["productName"]
evt = data["eventType"]
if pn == blue then
if evt == evtAdd then
hs.findDeviceByName(blue):setDefaultInputDevice()
end
elseif pn == fiio then
if evt == evtAdd then
hs.findDeviceByName(fiio):setDefaultOutputDevice()
end
if (pn == smodi) then
if evt == evtAdd then
dac = hs.audiodevice.findOutputByName(pn)
if dac ~= nil then
dac:setDefaultOutputDevice()
end
end
elseif (pn == bluen) then
if evt == evtAdd then
mic = hs.audiodevice.findAudioDeviceByName(pn)
if mic ~= nil then
mic:setDefaultInputDevice()
end
end
end

end

module.watcher = hs.usb.watcher.new(usbDeviceCallback)
module.watcher:start()

return module
1 change: 0 additions & 1 deletion hammerspoon/wifi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ end

module.watcher = hs.wifi.watcher.new(ssidChangedCallback)
module.watcher:start()

return module
15 changes: 12 additions & 3 deletions zsh/history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ if test -d "$HOME/.zsh/zsh-autosuggestions"; then
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
fi

source ~/.zsh-histdb/histdb-interactive.zsh
bindkey '^r' _histdb-isearch

if test -d "$HOME/.zsh/zsh-autosuggestions"; then
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
fi

if test -d "$HOME/.zsh-histdb"; then
source "$HOME/.zsh-histdb/sqlite-history.zsh"
export HISTDB_FILE="$HOME/.zsh-history.db"
autoload -Uz add-zsh-hook
add-zsh-hook precmd histdb-update-outcome
alias h=histdb

_zsh_autosuggest_strategy_histdb_top_here() {
local query="select commands.argv from
history left join commands on history.command_id = commands.rowid
Expand All @@ -27,6 +36,6 @@ and commands.argv LIKE '$(sql_escape $1)%'
group by commands.argv order by count(*) desc limit 1"
suggestion=$(_histdb_query "$query")
}

export ZSH_AUTOSUGGEST_STRATEGY=histdb_top_here
export ZSH_AUTOSUGGEST_STRATEGY=(histdb_top_here)
fi

0 comments on commit c71edc7

Please sign in to comment.