mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-17 09:20:28 +03:00
cwdhist: remove sqlite3 dependency (#661)
- empty-sqlite: dump pre-created empty sqlite database - rebind open_command_editor - typo: system-pune-all Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
parent
77f7b40828
commit
27ffa41815
@ -48,6 +48,16 @@ def __cwdhist_keybinding [] {
|
||||
}
|
||||
}
|
||||
|
||||
def __cwdhist_editing [] {
|
||||
{
|
||||
name: open_command_editor
|
||||
modifier: alt
|
||||
keycode: char_e
|
||||
mode: [emacs, vi_normal, vi_insert]
|
||||
event: { send: openeditor }
|
||||
}
|
||||
}
|
||||
|
||||
def __cwdhist_switching [] {
|
||||
{
|
||||
name: cwdhist_switching
|
||||
@ -60,18 +70,23 @@ def __cwdhist_switching [] {
|
||||
}
|
||||
}
|
||||
|
||||
export def empty-sqlite [] {
|
||||
# pre-created empty sqlite database
|
||||
'H4sIAAAAAAAAA+3LQQpAYBiE4fn+bMURvhPYuIAD2MgJLChKSv9BrZ1GSrHD/n1qmtlM29Rj7H1Y1rmLXiqXmSp3SeERuzrRzfQuqJi29Fy5lO0fHgAAAAAAAAAAAAAA4LcDzTELuwAgAAA='
|
||||
| decode base64 --binary | gzip -d
|
||||
}
|
||||
|
||||
export-env {
|
||||
$env.cwd_history_full = false
|
||||
$env.cwd_history_file = '~/.cache/nu_cwd_history.sqlite'
|
||||
|
||||
if not ($env.cwd_history_file | path exists) {
|
||||
"create table if not exists cwd_history (
|
||||
empty-sqlite | save -f $env.cwd_history_file
|
||||
open $env.cwd_history_file | query db "create table if not exists cwd_history (
|
||||
cwd text primary key,
|
||||
count int default 1,
|
||||
recent datetime default (datetime('now', 'localtime'))
|
||||
);"
|
||||
| sqlite3 ~/.cache/nu_cwd_history.sqlite
|
||||
}
|
||||
|
||||
let __cwdhist_hook = {|_, dir|
|
||||
@ -97,6 +112,6 @@ export-env {
|
||||
|
||||
$env.config = ($env.config
|
||||
| upsert menus ($env.config.menus | append (__cwdhist_menu))
|
||||
| upsert keybindings ($env.config.keybindings | append [(__cwdhist_keybinding) (__cwdhist_switching)])
|
||||
| upsert keybindings ($env.config.keybindings | append [(__cwdhist_keybinding) (__cwdhist_editing) (__cwdhist_switching)])
|
||||
)
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ export def system-prune [-n: string@"nu-complete docker ns"] {
|
||||
}
|
||||
|
||||
# system prune all
|
||||
export def system-pune-all [-n: string@"nu-complete docker ns"] {
|
||||
export def system-prune-all [-n: string@"nu-complete docker ns"] {
|
||||
^$env.docker-cli (spr [-n $n]) system prune --all --force --volumes
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user