aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2022-05-15 13:22:04 +0200
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2022-05-15 13:22:04 +0200
commit3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d (patch)
tree2de4195f5df50b876a5b037b76970414b51feb50
parent115ff9a06870d51702918cd926199e2271bf4f92 (diff)
downloadscripts-3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d.tar.gz
scripts-3fca4f50b5fb25b8dfebd34d46a6a607b49eab0d.zip
Some fixes
Diffstat (limited to '')
-rw-r--r--TODO2
-rwxr-xr-xsel65
-rwxr-xr-xsfeed-browser18
3 files changed, 48 insertions, 37 deletions
diff --git a/TODO b/TODO
index 317a569..7523a93 100644
--- a/TODO
+++ b/TODO
@@ -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
diff --git a/sel b/sel
index f5fa058..5d057e8 100755
--- a/sel
+++ b/sel
@@ -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
23file="$XDG_DATA_HOME/selectedfiles" 28file="$XDG_DATA_HOME/selectedfiles"
24menu=${MENU:-dmenu} 29menu="" # default uses dmenu-filepicker default
25editor=${EDITOR:-vi} 30editor=${EDITOR:-vi}
26rm=trashrm # replace with rm -r if you don't use trashrm 31rm="trash rm" # replace with rm -r if you don't use trash
27 32
28add() { 33while 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
39done
40shift `expr $OPTIND - 1`
41
42add() {
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
55clear() { 56clear() {
@@ -91,7 +92,9 @@ else
91case "$1" in 92case "$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
16filepicker="dmenu-filepicker" # Try "nnn -p -" 17filepicker="dmenu-filepicker" # Try "nnn -p -"
17menu=${MENU:-dmenu} 18menu="dmenu -l 35 -i"
18menuopts="-l 35 -i"
19urlopener=open-url 19urlopener=open-url
20sfd="box/sfeed" 20sfd="$HOME/box/sfeed"
21showlast=10 21showlast=10
22 22
23while getopts "m:" opt; do
24 case "$opt" in
25 m)
26 menu="$OPTARG"
27 ;;
28 esac
29done
30
23# Might add more stuff later 31# Might add more stuff later
24fixurl() { 32fixurl() {
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
53openfeeds() { 61openfeeds() {
@@ -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"
61pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc" 69pathstosfeedrc < "$sfd/last" > "$sfd/sfeedrc"
62sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds 70sfeed_update "$sfd/sfeedrc" && feedmenu < "$sfd/last" | openfeeds

Generated with cgit - Back to sebastiano.tronto.net