-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdell
executable file
·205 lines (185 loc) · 5.1 KB
/
dell
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/usr/bin/env bash
## By Davoud Arsalani
## https://github.com/davoudarsalani/scripts
## https://github.com/davoudarsalani/scripts/blob/master/dell
## https://raw.githubusercontent.com/davoudarsalani/scripts/master/dell
## https://davoudarsalani.ir
source "$HOME"/main/scripts/gb
trap 'exit 0' INT ## to avoid 255 exit code when using options that connect with x2x
title="${0##*/}"
function display_help {
source "$HOME"/main/scripts/.help
dell_help
}
function upload {
scp -r "$name" nnnn@dell-"$bed":"$HOME"/main/downloads && \
accomplished
}
function download {
scp -r nnnn@dell-"$bed":"$name" "$HOME"/main/downloads && \
accomplished
}
function connect {
ssh -Y nnnn@dell-"$bed" && \
accomplished
}
function connect_plus_x2x {
ssh -Y nnnn@dell-"$bed" 'x2x -west -to :0'
}
function rsync_ {
## NOTE remove trailing slash
source_dir="${source_dir%/}"
dest_dir="${source_dir%/*}" ## a/b/c/d -> a/b/c
rsync --archive --progress --delete "$source_dir" nnnn@dell-"$bed":"$dest_dir"
}
function prompt {
for _ in "$@"; {
case "$1" in
-n ) name="${name:-"$(get_input 'directory/file name')"}" ;;
esac
shift
}
}
function get_opt {
local options
options="$(getopt --longoptions 'help,name:' --options 'hn:' --alternative -- "$@")"
eval set -- "$options"
while true; do
case "$1" in
-h|--help )
display_help ;;
-n|--name )
shift
name="$1" ;;
-- )
break ;;
esac
shift
done
}
get_opt "$@"
heading "$title"
main_items=(
'ethernet connect + x2x'
'ethernet connect'
'ethernet download'
'ethernet upload'
'ethernet rsync ~/main/eterna'
'ethernet rsync ~/main/ariel'
'ethernet rsync ~/main/rcc'
'ethernet rsync ~/main/journal'
'ethernet rsync ~/main/linux'
'ethernet rsync ~/main/scripts'
'ethernet rsync ~/main/website'
'ethernet rsync ~/main/globaldaily'
'wifi connect + x2x'
'wifi connect'
'wifi download'
'wifi upload'
'wifi rsync ~/main/eterna'
'wifi rsync ~/main/ariel'
'wifi rsync ~/main/rcc'
'wifi rsync ~/main/journal'
'wifi rsync ~/main/linux'
'wifi rsync ~/main/scripts'
'wifi rsync ~/main/website'
'wifi rsync ~/main/globaldaily'
'help'
)
main_item="$(pipe_to_fzf "${main_items[@]}")" && wrap_fzf_choice "$main_item" || exit 37
case "$main_item" in
'ethernet connect + x2x' )
bed='ethernet'
connect_plus_x2x ;;
'ethernet connect' )
bed='ethernet'
connect ;;
'ethernet download' )
prompt -n
bed='ethernet'
download "$name" ;;
'ethernet upload' )
prompt -n
bed='ethernet'
upload "$name" ;;
'ethernet rsync ~/main/eterna' )
bed='ethernet'
source_dir="$HOME"/main/eterna ## NOTE JUMP_1 no trailing slash
rsync_ ;;
'ethernet rsync ~/main/ariel' )
bed='ethernet'
source_dir="$HOME"/main/ariel ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/rcc' )
bed='ethernet'
source_dir="$HOME"/main/rcc ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/journal' )
bed='ethernet'
source_dir="$HOME"/main/journal ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/linux' )
bed='ethernet'
source_dir="$HOME"/main/linux ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/scripts' )
bed='ethernet'
source_dir="$HOME"/main/scripts ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/website' )
bed='ethernet'
source_dir="$HOME"/main/website ## JUMP_1
rsync_ ;;
'ethernet rsync ~/main/globaldaily' )
bed='ethernet'
source_dir="$HOME"/main/globaldaily ## JUMP_1
rsync_ ;;
'wifi connect + x2x' )
bed='wifi'
connect_plus_x2x ;;
'wifi connect' )
bed='wifi'
connect ;;
'wifi download' )
prompt -n
bed='wifi'
download "$name" ;;
'wifi upload' )
prompt -n
bed='wifi'
upload "$name" ;;
'wifi rsync ~/main/eterna' )
bed='wifi'
source_dir="$HOME"/main/eterna ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/ariel' )
bed='wifi'
source_dir="$HOME"/main/ariel ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/rcc' )
bed='wifi'
source_dir="$HOME"/main/rcc ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/journal' )
bed='wifi'
source_dir="$HOME"/main/journal ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/linux' )
bed='wifi'
source_dir="$HOME"/main/linux ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/scripts' )
bed='wifi'
source_dir="$HOME"/main/scripts ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/website' )
bed='wifi'
source_dir="$HOME"/main/website ## JUMP_1
rsync_ ;;
'wifi rsync ~/main/globaldaily' )
bed='wifi'
source_dir="$HOME"/main/globaldaily ## JUMP_1
rsync_ ;;
help )
display_help ;;
esac