forked from kurokirasama/nushell_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdef_app.nu
More file actions
94 lines (80 loc) · 2.32 KB
/
def_app.nu
File metadata and controls
94 lines (80 loc) · 2.32 KB
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
#get phone number from google contacts
export def get-phone-number [search:string] {
goobook dquery $search
| from ssv
| rename results
| where results like '(?P<plus>\+)(?P<nums>\d+)'
}
#open mcomix
export def mcx [file?] {
let file = get-input $in $file
job spawn {mcomix $file} | ignore
}
#jdownloader downloads info
export def jd [
--ubb(-b) #check ubb jdownloader
--desktop(-d) #check ubb desktop
] {
match [$ubb,$desktop] {
[true,false] => {jdown -b 1},
[false,true] => {jdown -b 2},
[false,false] => {jdown},
[true,true] => {return-error "please specify only one option"}
}
| from json
}
#maestral status
export def "dpx status" [] {
maestral status | lines | parse "{item} {status}" | str trim | drop nth 0
}
#run matlab in cli
export def matlab-cli [
--background(-b) #send process to the background, select input m-file from list
--input(-i):string #input m-file to run in background mode, must be in the same directory
--output(-o):string #output file for log without extension
--log_file(-l):string = "log24" #log file in foreground mode
--kill(-k) #kill current matlab processes
] {
if $kill {
ps -l
| find -i matlab
| find local & MATLAB
| find -v 'MATLAB-language-server' & 'bin/nu' & 'yandex-disk'
| each {|row|
kill -f $row.pid
}
return
}
if not $background {
matlab -nosplash -nodesktop -sd ($env.PWD) -logfile ("~/Dropbox/matlab" | path join $"($log_file).txt" | path expand) -r "setenv('SHELL', '/bin/bash');"
return
}
let log = (date now | format date "%Y.%m.%d_%H.%M.%S") + "_log.txt"
let input = (
if ($input | is-empty) {
ls *.m
| get name
| path parse
| get stem
| input list -f (echo-g "m-file to run: ")
} else {
$input | path parse | get stem
}
)
let output = if ($output | is-empty) {$log} else {$output + ".txt"}
job spawn {matlab -batch ("setenv('SHELL', '/bin/bash'); " + $input) | save -f $output} | ignore
}
# Return the flag emoji for a given two-digit country code
export def country-flag [
country_code: string # The two-digit country code (e.g., "US", "de")
] {
let base_offset = 127397
$country_code
| str upcase
| split chars
| each {|c|
($c | into binary | into int) + $base_offset
| char --integer $in
}
| str join
}