-
Notifications
You must be signed in to change notification settings - Fork 2
/
backups.nu
154 lines (125 loc) · 4.32 KB
/
backups.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#backup sublime settings
export def "subl backup" [] {
cd $env.MY_ENV_VARS.linux_backup
let source_dir = "~/.config/sublime-text"
7z max sublime-Packages.7z ($source_dir | path join Packages | path expand)
7z max sublime-installedPackages.7z ($source_dir | path join "Installed Packages" | path expand)
}
#restore sublime settings
export def "subl restore" [] {
cd $env.MY_ENV_VARS.linux_backup
7z x sublime-installedPackages.7z -o/home/kira/.config/sublime-text/
7z x sublime-Packages.7z -o/home/kira/.config/sublime-text/
}
#backup nchat settings
export def "nchat backup" [] {
cd $env.MY_ENV_VARS.linux_backup
let source_dir = "~/.nchat" | path expand
7z max nchat_config.7z ($source_dir + "/*.conf")
}
#restore nchat settings
export def "nchat restore" [] {
cd $env.MY_ENV_VARS.linux_backup
7z x nchat_config.7z -o/home/kira/.nchat
}
#backup gnome extensions settings
export def "gnome-settings backup" [] {
dconf dump /org/gnome/shell/extensions/
| save -f ([$env.MY_ENV_VARS.linux_backup extensions gnome_shell_extensions_backup.txt] | path join)
}
#restore gnome extensions settings
export def "gnome-settings restore" [] {
bash -c $"dconf load /org/gnome/shell/extensions/ < ([$env.MY_ENV_VARS.linux_backup extensions/gnome_shell_extensions_backup.txt] | path join)"
}
#backup libre office settings
export def "libreoff backup" [] {
cp -r ~/.config/libreoffice/* ([$env.MY_ENV_VARS.linux_backup libreoffice] | path join)
}
#restore libre office settings
export def "libreoff restore" [] {
cp -r ($env.MY_ENV_VARS.linux_backup + "/libreoffice/*") ~/.config/libreoffice/
}
#filter commands for sublime syntax file
def filter-command [type_of_command:string] {
scope commands
| where type == $type_of_command
| get name
| each {|com|
$com | split row " " | get 0
}
| uniq
| str join " | "
}
#update nushell sublime syntax
export def "nushell-syntax-2-sublime" [
--push(-p) #push changes in submile syntax repo
] {
let builtin = filter-command built-in
let plugins = filter-command plugin
let custom = filter-command custom
let keywords = filter-command keyword
let aliases = (
scope aliases
| get name
| uniq
| str join " | "
)
let personal_external = (
$env.PATH
| find bash & nushell
| get 0
| ansi strip
| ls $in
| find -v Readme
| get name
| path parse
| get stem
| str join " | "
)
let extra_keywords = " | else | catch"
let builtin = " (?x: " + $builtin + ")"
let plugins = " (?x: " + $plugins + ")"
let custom = " (?x: " + $custom + ")"
let keywords = " (?x: " + $keywords + $extra_keywords + ")"
let aliases = " (?x: " + $aliases + ")"
let personal_external = " (?x: " + $personal_external + ")"
let operators = " (?x: and | or | mod | in | not-in | not | xor | bit-or | bit-xor | bit-and | bit-shl | bit-shr | starts-with | ends-with)"
let new_commands = [] ++ $builtin ++ $custom ++ $plugins ++ $keywords ++ $aliases ++ $personal_external ++ $operators
mut file = open ~/.config/sublime-text/Packages/User/nushell.sublime-syntax | lines
let idx = $file | indexify | find '(?x:' | get index | drop | enumerate
for i in $idx {
$file = $file | upsert $i.item ($new_commands | get $i.index)
}
$file | save -f ~/.config/sublime-text/Packages/User/nushell.sublime-syntax
cp ~/.config/sublime-text/Packages/User/nushell.sublime-syntax $env.MY_ENV_VARS.nushell_syntax_public
if $push {
cd $env.MY_ENV_VARS.nushell_syntax_public
ai git-push -G
}
}
#backup nushell history
export def "history backup" [
output?:string = "hist" #output filename
] {
open $nu.history-path | query db $"vacuum main into '($output).db'"
}
#export rclone config
export def "rclone export" [] {
cd ~/.config/rclone
nu-crypt -e -n rclone.conf
mv rclone.conf.asc $env.MY_ENV_VARS.linux_backup
}
#import rclone config
export def "rclone import" [] {
cd $env.MY_ENV_VARS.linux_backup
nu-crypt -d -n rclone.conf.asc | save -f ~/.config/rclone/rclone.conf
rclone listremotes
}
#backup guake settings
export def "guake backup" [] {
guake --save-preferences ($env.MY_ENV_VARS.linux_backup | path join guakesettings.txt)
}
#restore guake settings
export def "guake restore" [] {
guake --restore-preferences ($env.MY_ENV_VARS.linux_backup | path join guakesettings.txt)
}