Loading .bash_completion.d/nc-mount 0 → 100644 +24 −0 Original line number Diff line number Diff line # vim: ft=bash _nc_mount () { local cur prev words cword opts _init_completion || return opts='-a --all -h --help -l --list' if [[ $cur == -* ]] then COMPREPLY=($(compgen -W "$opts" -- "$cur")) else local IFS=$'\n' declare -a candidates candidates=($(compgen -W "$(nc-mount -l)" -- "$cur")) if [ ${#candidates[*]} -eq 0 ] then COMPREPLY=() else COMPREPLY=($(printf '%q\n' "${candidates[@]}")) fi fi } complete -F _nc_mount nc-mount Documents/bin/nc-mount 0 → 100755 +39 −0 Original line number Diff line number Diff line #!/bin/sh set -eu command -v rclone >/dev/null || { echo 'rclone not found.' >&2; exit 1; } usage () { echo "$0: [-a|--all] [-l|--list] [FOLDER]" >&2 exit 1 } _mount () { folder="$1" mkfolder -p "$HOME/$folder" rclone mount \ --allow-non-empty \ --daemon \ --gid "$(id -g)" \ --vfs-cache-mode full \ --uid "$(id -u)" \ "nextcloud:$folder" \ "$HOME/$folder" } [ "$#" -eq 1 ] || usage folders="$(rclone lsd nextcloud: | cut -c 44- | grep -vx 'System information')" case "$1" in -h|--help) usage;; -l|--list) echo "$folders";; -a|--all) echo "$folders" | xargs -I % "$0" "%";; *) if echo "$folders" | grep -qx "$1" then _mount "$1" else echo "Folder $1 not found in Nextcloud." >&2 exit 1 fi;; esac Loading
.bash_completion.d/nc-mount 0 → 100644 +24 −0 Original line number Diff line number Diff line # vim: ft=bash _nc_mount () { local cur prev words cword opts _init_completion || return opts='-a --all -h --help -l --list' if [[ $cur == -* ]] then COMPREPLY=($(compgen -W "$opts" -- "$cur")) else local IFS=$'\n' declare -a candidates candidates=($(compgen -W "$(nc-mount -l)" -- "$cur")) if [ ${#candidates[*]} -eq 0 ] then COMPREPLY=() else COMPREPLY=($(printf '%q\n' "${candidates[@]}")) fi fi } complete -F _nc_mount nc-mount
Documents/bin/nc-mount 0 → 100755 +39 −0 Original line number Diff line number Diff line #!/bin/sh set -eu command -v rclone >/dev/null || { echo 'rclone not found.' >&2; exit 1; } usage () { echo "$0: [-a|--all] [-l|--list] [FOLDER]" >&2 exit 1 } _mount () { folder="$1" mkfolder -p "$HOME/$folder" rclone mount \ --allow-non-empty \ --daemon \ --gid "$(id -g)" \ --vfs-cache-mode full \ --uid "$(id -u)" \ "nextcloud:$folder" \ "$HOME/$folder" } [ "$#" -eq 1 ] || usage folders="$(rclone lsd nextcloud: | cut -c 44- | grep -vx 'System information')" case "$1" in -h|--help) usage;; -l|--list) echo "$folders";; -a|--all) echo "$folders" | xargs -I % "$0" "%";; *) if echo "$folders" | grep -qx "$1" then _mount "$1" else echo "Folder $1 not found in Nextcloud." >&2 exit 1 fi;; esac