mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
change cwdhist_menu layout to list
(#657)
Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
parent
e4ae994200
commit
df2556b993
1 changed files with 16 additions and 22 deletions
|
@ -4,8 +4,8 @@ def __cwdhist_menu [] {
|
||||||
only_buffer_difference: false
|
only_buffer_difference: false
|
||||||
marker: "| "
|
marker: "| "
|
||||||
type: {
|
type: {
|
||||||
layout: columnar
|
layout: list
|
||||||
page_size: 20
|
page_size: 10
|
||||||
}
|
}
|
||||||
style: {
|
style: {
|
||||||
text: green
|
text: green
|
||||||
|
@ -14,30 +14,24 @@ def __cwdhist_menu [] {
|
||||||
}
|
}
|
||||||
source: { |buffer, position|
|
source: { |buffer, position|
|
||||||
#$"[($position)]($buffer);(char newline)" | save -a ~/.cache/cwdhist.log
|
#$"[($position)]($buffer);(char newline)" | save -a ~/.cache/cwdhist.log
|
||||||
let cwd = if ($buffer | is-empty) {
|
|
||||||
""
|
|
||||||
} else {
|
|
||||||
$buffer
|
|
||||||
}
|
|
||||||
if 'cwd_history_full' in $env {
|
if 'cwd_history_full' in $env {
|
||||||
open $nu.history-path | query db $"
|
open $nu.history-path | query db $"
|
||||||
select cwd as value, count\(*) as description
|
select cwd as value, count\(*) as cnt
|
||||||
from history
|
from history
|
||||||
where cwd like '%($cwd)%'
|
where cwd like '%($buffer)%'
|
||||||
group by cwd
|
group by cwd
|
||||||
order by description desc
|
order by cnt desc
|
||||||
limit 20
|
limit 50
|
||||||
;"
|
;"
|
||||||
} else {
|
} else {
|
||||||
open $env.cwd_history_file | query db $"
|
open $env.cwd_history_file | query db $"
|
||||||
select cwd as value, count as description
|
select cwd as value, count
|
||||||
from cwd_history
|
from cwd_history
|
||||||
where cwd like '%($cwd)%'
|
where cwd like '%($buffer)%'
|
||||||
order by count desc
|
order by count desc
|
||||||
limit 20
|
limit 50
|
||||||
;"
|
;"
|
||||||
}
|
}
|
||||||
| append { value: '~' }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,10 +66,10 @@ export-env {
|
||||||
|
|
||||||
if not ($env.cwd_history_file | path exists) {
|
if not ($env.cwd_history_file | path exists) {
|
||||||
"create table if not exists cwd_history (
|
"create table if not exists cwd_history (
|
||||||
cwd text primary key,
|
cwd text primary key,
|
||||||
count int default 1,
|
count int default 1,
|
||||||
recent datetime default (datetime('now', 'localtime'))
|
recent datetime default (datetime('now', 'localtime'))
|
||||||
);"
|
);"
|
||||||
| sqlite3 ~/.cache/nu_cwd_history.sqlite
|
| sqlite3 ~/.cache/nu_cwd_history.sqlite
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,11 +84,11 @@ export-env {
|
||||||
open $env.cwd_history_file
|
open $env.cwd_history_file
|
||||||
| query db $"
|
| query db $"
|
||||||
insert into cwd_history\(cwd)
|
insert into cwd_history\(cwd)
|
||||||
values \('($path)')
|
values \('($path)')
|
||||||
on conflict\(cwd)
|
on conflict\(cwd)
|
||||||
do update set
|
do update set
|
||||||
count = count + 1,
|
count = count + 1,
|
||||||
recent = datetime\('now', 'localtime');"
|
recent = datetime\('now', 'localtime');"
|
||||||
}
|
}
|
||||||
|
|
||||||
$env.config = ($env.config
|
$env.config = ($env.config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue