Updated for nushell v0.83 and some changes in doom emacs config
Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
|
||||
let filename = (date now | date format "%s")
|
||||
while 1 == 1 {
|
||||
(sudo tlp-stat -b | grep Charge | split column '=' | str trim ) | insert a (date now | date format "%s") | reject column1 | rename Charge Timestamp | to csv -n | str replace " \\[%\\]" "" |save -a $"$filename".csv;
|
||||
(sudo tlp-stat -b | grep Charge | split column '=' | str trim ) | insert a (date now | date format "%s") | reject column1 | rename Charge Timestamp | to csv -n | str replace " \\[%\\]" "" | save -a $"($filename).csv";
|
||||
sleep 50ms;
|
||||
}
|
||||
|
||||
17
config/.scripts/clean-nushell-db.nu
Normal file
17
config/.scripts/clean-nushell-db.nu
Normal file
@@ -0,0 +1,17 @@
|
||||
# clean-nushell-db
|
||||
|
||||
#!/usr/bin/env nu
|
||||
let db = "~/dotfiles/nushell/.config/nushell/history.sqlite3"
|
||||
|
||||
def get_current_row [] {
|
||||
let current_row = (^sqlite3 $db "SELECT COUNT(*) FROM history h")
|
||||
echo $"current rows: ($current_row)"
|
||||
}
|
||||
|
||||
get_current_row
|
||||
# Remove failed commands
|
||||
sqlite3 $db "DELETE FROM history WHERE exit_status != 0"
|
||||
# Remove duplicates. But keep one.
|
||||
# https://stackoverflow.com/a/53693544/6000005
|
||||
sqlite3 $db "DELETE FROM history WHERE id NOT IN (SELECT MIN(id) FROM history h GROUP BY command_line);"
|
||||
get_current_row
|
||||
Reference in New Issue
Block a user