diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-05-15 13:22:04 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-05-15 13:22:04 +0200 |
| commit | 3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d (patch) | |
| tree | 2de4195f5df50b876a5b037b76970414b51feb50 | |
| parent | 115ff9a06870d51702918cd926199e2271bf4f92 (diff) | |
| download | scripts-3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d.tar.gz scripts-3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d.zip | |
Some fixes
Diffstat (limited to '')
| -rw-r--r-- | TODO | 2 | ||||
| -rwxr-xr-x | sel | 65 | ||||
| -rwxr-xr-x | sfeed-browser | 18 |
3 files changed, 48 insertions, 37 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | * dmenu-bookmarks: add option for different directory | 1 | * sel: fix globbing filenames with spaces; once done, remove "addall" |
| 2 | 2 | ||
| 3 | * mblaze-extras: maybe remove script and just use aliases? | 3 | * mblaze-extras: maybe remove script and just use aliases? |
| 4 | 4 | ||
| @@ -1,10 +1,11 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Allow bulk operations on a list of selected files. | 3 | # Allow bulk operations on a list of selected files. |
| 4 | # Usage: sel [command] | 4 | # Usage: sel [-m menu] [command] |
| 5 | # If no command is specified, shows the list of selected files | 5 | # If no command is specified, shows the list of selected files |
| 6 | # Commands: | 6 | # Commands: |
| 7 | # add [files|dirs|all]: add files to selection | 7 | # add [files...]: add files to selection |
| 8 | # addall: add all files in the current folder to selection | ||
| 8 | # clear: clear selection | 9 | # clear: clear selection |
| 9 | # cp: copy to current dir, possbily after editing filenames | 10 | # cp: copy to current dir, possbily after editing filenames |
| 10 | # edit: open selection in editor | 11 | # edit: open selection in editor |
| @@ -12,44 +13,44 @@ | |||
| 12 | # open: open files using open-file | 13 | # open: open files using open-file |
| 13 | # rm: remove selected files and clear selection | 14 | # rm: remove selected files and clear selection |
| 14 | 15 | ||
| 15 | # Requires: dmenu (or similar), trashrm (optional), open-file (for open only) | 16 | # Requires: dmenu (or similar), trash (optional), open-file (for open only) |
| 16 | 17 | ||
| 17 | # TODO: add possibility of specifying file. | 18 | # TODO: The usage of paste(1) is a bit of a hack, and for example it does |
| 18 | # TODO 2: The usage of paste(1) is a bit of a hack, and for example it does | ||
| 19 | # not work if filenames contain tab characters. Fix this. | 19 | # not work if filenames contain tab characters. Fix this. |
| 20 | # Bug (probably not fixing this, use virename): moving moving a file to | 20 | |
| 21 | # Another TODO: add by filename does not work when globbing filenames with | ||
| 22 | # space. E.g. sel add "a file.txt" works, but sel add *.txt does not. | ||
| 23 | # Why does this happen? | ||
| 24 | |||
| 25 | # Bug (probably not fixing this, use virename): moving a file to | ||
| 21 | # itself gives an error and rm is not run. | 26 | # itself gives an error and rm is not run. |
| 22 | 27 | ||
| 23 | file="$XDG_DATA_HOME/selectedfiles" | 28 | file="$XDG_DATA_HOME/selectedfiles" |
| 24 | menu=${MENU:-dmenu} | 29 | menu="" # default uses dmenu-filepicker default |
| 25 | editor=${EDITOR:-vi} | 30 | editor=${EDITOR:-vi} |
| 26 | rm=trashrm # replace with rm -r if you don't use trashrm | 31 | rm="trash rm" # replace with rm -r if you don't use trash |
| 27 | 32 | ||
| 28 | add() { | 33 | while getopts "m:" opt; do |
| 29 | if [ -z "$2" ]; then | 34 | case "$opt" in |
| 30 | dmenu-filepicker >> "$file" | 35 | m) |
| 31 | else | 36 | menu="$OPTARG" |
| 32 | case "$2" in | ||
| 33 | files) | ||
| 34 | ls | while read f; do | ||
| 35 | [ -f "$f" ] && echo "$PWD/$f" >> "$file" | ||
| 36 | done | ||
| 37 | ;; | ||
| 38 | dirs) | ||
| 39 | ls | while read f; do | ||
| 40 | [ -d "$f" ] && echo "$PWD/$f" >> "$file" | ||
| 41 | done | ||
| 42 | ;; | ||
| 43 | all) | ||
| 44 | ls | while read f; do | ||
| 45 | echo "$PWD/$f" >> "$file" | ||
| 46 | done | ||
| 47 | ;; | ||
| 48 | *) | ||
| 49 | echo "$2: not a valid option" | ||
| 50 | ;; | 37 | ;; |
| 51 | esac | 38 | esac |
| 39 | done | ||
| 40 | shift `expr $OPTIND - 1` | ||
| 41 | |||
| 42 | add() { | ||
| 43 | shift 1 | ||
| 44 | if [ -z "$1" ]; then | ||
| 45 | if [ -n "$menu" ]; then | ||
| 46 | dmenu-filepicker -m "$menu" >> "$file" | ||
| 47 | else | ||
| 48 | dmenu-filepicker >> "$file" | ||
| 49 | fi | ||
| 50 | else | ||
| 51 | for i in "$@"; do realpath "$i" >> "$file"; done | ||
| 52 | fi | 52 | fi |
| 53 | sort -u -o "$file" "$file" | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | clear() { | 56 | clear() { |
| @@ -91,7 +92,9 @@ else | |||
| 91 | case "$1" in | 92 | case "$1" in |
| 92 | add) | 93 | add) |
| 93 | add $@ | 94 | add $@ |
| 94 | sort -u -o "$file" "$file" | 95 | ;; |
| 96 | addall) | ||
| 97 | add * | ||
| 95 | ;; | 98 | ;; |
| 96 | clear) | 99 | clear) |
| 97 | clear | 100 | clear |
diff --git a/sfeed-browser b/sfeed-browser index abdc898..a85b62c 100755 --- a/sfeed-browser +++ b/sfeed-browser | |||
| @@ -11,15 +11,23 @@ | |||
| 11 | # them before displaying the choice of feeds. Contact me if you are interested | 11 | # them before displaying the choice of feeds. Contact me if you are interested |
| 12 | # in using it. | 12 | # in using it. |
| 13 | 13 | ||
| 14 | # Usage: sfeed-browser [-m menu] | ||
| 14 | # Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar) | 15 | # Requires: sfeed, dmenu-file-picker (or similar), open-url (or similar) |
| 15 | 16 | ||
| 16 | filepicker="dmenu-filepicker" # Try "nnn -p -" | 17 | filepicker="dmenu-filepicker" # Try "nnn -p -" |
| 17 | menu=${MENU:-dmenu} | 18 | menu="dmenu -l 35 -i" |
| 18 | menuopts="-l 35 -i" | ||
| 19 | urlopener=open-url | 19 | urlopener=open-url |
| 20 | sfd="box/sfeed" | 20 | sfd="$HOME/box/sfeed" |
| 21 | showlast=10 | 21 | showlast=10 |
| 22 | 22 | ||
| 23 | while getopts "m:" opt; do | ||
| 24 | case "$opt" in | ||
| 25 | m) | ||
| 26 | menu="$OPTARG" | ||
| 27 | ;; | ||
| 28 | esac | ||
| 29 | done | ||
| 30 | |||
| 23 | # Might add more stuff later | 31 | # Might add more stuff later |
| 24 | fixurl() { | 32 | fixurl() { |
| 25 | sed 's/old\.reddit\.com/reddit\.com/' | 33 | sed 's/old\.reddit\.com/reddit\.com/' |
| @@ -47,7 +55,7 @@ feedmenu() { | |||
| 47 | while read line; do | 55 | while read line; do |
| 48 | feedname=$(echo "$line" | sed 's/.*\///') | 56 | feedname=$(echo "$line" | sed 's/.*\///') |
| 49 | sfeed_plain "$sfd/files/$feedname" | head -$showlast | 57 | sfeed_plain "$sfd/files/$feedname" | head -$showlast |
| 50 | done | $menu $menuopts | 58 | done | $menu |
| 51 | } | 59 | } |
| 52 | 60 | ||
| 53 | openfeeds() { | 61 | openfeeds() { |
| @@ -57,6 +65,6 @@ openfeeds() { | |||
| 57 | done | xargs $urlopener | 65 | done | xargs $urlopener |
| 58 | } | 66 | } |
| 59 | 67 | ||
| 60 | $filepicker "$sfd/urls" | dirtofeedpaths > "$sfd/last" | 68 | $filepicker "$@" "$sfd/urls" | dirtofeedpaths > "$sfd/last" |
| 61 | pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" | 69 | pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" |
| 62 | sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds | 70 | sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds |
