aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rwxr-xr-xsel2
-rwxr-xr-xvirename25
3 files changed, 28 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 19780cc..b20a5b6 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,7 @@ SCRIPTS = addressgrep \
34 translate \ 34 translate \
35 trash \ 35 trash \
36 urlgrep \ 36 urlgrep \
37 virename \
37 volume \ 38 volume \
38 websearch \ 39 websearch \
39 xedit \ 40 xedit \
diff --git a/sel b/sel
index 8d8b549..f5fa058 100755
--- a/sel
+++ b/sel
@@ -17,6 +17,8 @@
17# TODO: add possibility of specifying file. 17# TODO: add possibility of specifying file.
18# TODO 2: 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
21# itself gives an error and rm is not run.
20 22
21file="$XDG_DATA_HOME/selectedfiles" 23file="$XDG_DATA_HOME/selectedfiles"
22menu=${MENU:-dmenu} 24menu=${MENU:-dmenu}
diff --git a/virename b/virename
new file mode 100755
index 0000000..e0d23bd
--- /dev/null
+++ b/virename
@@ -0,0 +1,25 @@
1#!/bin/sh
2
3# Rename all files in the current directory with a visual editor.
4# Similar to sel add all && sel mv, but it actually works.
5
6file=$(mktemp)
7file2=$(mktemp)
8editor=${EDITOR:-vi}
9
10ls | tee "$file" > "$file2"
11$editor "$file2"
12
13if [ "$(wc -l $file | awk '{print $1}')" != \
14 "$(wc -l $file2 | awk '{print $1}')" ]; then
15 echo "Error reading new file names"
16else
17 paste "$file" "$file2" | while read f; do
18 fold=$(echo "$f" | sed 's/\t.*//')
19 fnew=$(echo "$f" | sed 's/.*\t//')
20 if [ "$fold" != "$fnew" ]; then
21 mv "$fold" "$fnew" \
22 || echo "Error renaming $fold to $fnew"
23 fi
24 done
25fi

Generated with cgit - Back to sebastiano.tronto.net