浏览代码

Update share-link for wayland

Bryan Roessler 3 年之前
父节点
当前提交
279976c130
共有 1 个文件被更改,包括 18 次插入22 次删除
  1. 18 22
      share-link

+ 18 - 22
share-link

@@ -4,27 +4,23 @@ ssh_server="bryanroessler.com"
 ssh_files_path="/var/www/repos.bryanroessler.com/files"
 www_files_path="https://repos.bryanroessler.com/files"
 
-share-link () {
-    if [[ "$#" -lt 1 ]]; then
-    	echo "You must provide at least one argument"
-    	exit 1
-    else
-    	local -a links_array
-    	for file in "$@"; do
-    		local ext="${file#*.}"
-    		local random32
-            random32=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1)
-    		local random_fname="${random32}.${ext}"
-    		scp "${file}" "${ssh_server}:${ssh_files_path}/${random_fname}"
-    		links_array+=("$www_files_path/$random_fname")
-    	done
-    	if [[ "${#links_array[@]}" == 1 ]]; then
-    		printf '%s' "${links_array[@]}" | xclip -sel c
-    	else
-    		printf '%s\n' "${links_array[@]}" | xclip -sel c
-    	fi
-    fi
-}
+if [[ "$#" -lt 1 ]]; then
+	echo "You must provide at least one argument"
+	exit 1
+fi
+
+for file in "$@"; do
+    fname="${file##*/}"
+    random32=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1)
+	rsync -a "${file}" "${ssh_server}:${ssh_files_path}/${random32}/"
+	links_array+=("$www_files_path/${random32}/$fname")
+done
+
+if [[ "${#links_array[@]}" == 1 ]]; then
+	printf '%s' "${links_array[@]}" | wl-copy
+else
+	printf '%s\n' "${links_array[@]}" | wl-copy
+fi
 
-share-link "$@"
 exit $?
+