forked from Sketch98/shfm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shfm-remove-trash.diff
140 lines (133 loc) · 5.55 KB
/
shfm-remove-trash.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
diff --git a/README b/README
index 9deb7d7..0999641 100644
--- a/README
+++ b/README
@@ -44,8 +44,7 @@ ________________________________________________________________________________
space - select (or deselect) current item
p - copy selected items to current folder
v - move selected items to current folder
- x - trash selected items (permanently delete if in trash directory)
- t - go to trash
+ x - permanently delete selected items
r - bulk rename
a - select all
A - invert selection
@@ -61,7 +60,7 @@ right arrow - open file or directory
backspace - go up level
enter - open file or directory
-delete - trash selected items (permanently delete if in trash directory)
+delete - permanently delete selected items
home - go to top
end - go to bottom
pg up - go up one screen
diff --git a/shfm b/shfm
index 02ef04e..0460086 100755
--- a/shfm
+++ b/shfm
@@ -528,6 +528,7 @@ others_op() {
case $1 in
p) msg_line 'Copying Files' ;;
v) msg_line 'Moving Files' ;;
+ r) msg_line 'Deleting Files' ;;
esac
IFS=/
set -f
@@ -545,7 +546,9 @@ others_op() {
fi
;;
- v) mv -- "$cwd/$fn" "$2"
+ v) mv -- "$cwd/$fn" "$2" ;;
+
+ r) rm -rf -- "$cwd/$fn"
esac
fi
unset cwd fn
@@ -614,9 +617,7 @@ main() {
*) cd -- "${1:-"$PWD"}"
esac
- trash="${XDG_DATA_HOME:=$HOME/.local/share}/shfm/trash"
cache="${XDG_CACHE_HOME:=$HOME/.cache}/shfm"
- [ -e "$trash" ] || mkdir -p "$trash"
[ -e "$cache" ] || mkdir -p "$cache"
rename_file="$cache/bulk_rename$$"
exit_file="$cache/exit"
@@ -664,8 +665,7 @@ main() {
'space - select (or deselect) current item' \
' p - copy selected items to current folder' \
' v - move selected items to current folder' \
- ' x - trash selected items (permanently delete if in trash)' \
- ' t - go to trash' \
+ ' x - permanently delete selected items' \
' r - bulk rename' \
' a - select all' \
' A - invert selection' \
@@ -846,53 +846,38 @@ main() {
state=0
[ "$ltype" = keybinds ] || [ $# -eq 0 ] && continue
- del=
- [ -z "$ltype$others" ] && [ "$PWD" = "$trash" ] && del=true
if [ -z "$selected$others" ]; then
key=c
elif check_selected "$cur"; then
key=s
else
- [ -z $del ] && msg="trash 's'elected 'c'ur" || msg="permanently delete 's'elected 'c'ur"
- yes_no "$msg" $# || :
+ yes_no "permanently delete 's'elected 'c'ur" $# || :
fi
case $key in
s)
- [ -z $del ] && msg="send selected to trash? y/n" || msg="permanently delete selected? y/n"
- yes_no "$msg" $# || continue
+ yes_no "permanently delete selected? y/n" $# || continue
if [ -n "$selected" ]; then
y=1 y2=1 IFS=/
set -f
# globbing disabled and word splitting intentional
# shellcheck disable=2086
- if [ -z $del ]; then
- msg_line 'Trashing Files'
- mv -- $selected "$trash"
- else
- msg_line 'Deleting Files'
- rm -rf -- $selected
- fi
+ msg_line 'Deleting Files'
+ rm -rf -- $selected
set +f
unset IFS selected
num_sel=0
fi
- [ -n "$others" ] && others_op v "$trash"
+ [ -n "$others" ] && others_op r
;;
c)
- [ -z $del ] && msg="send $cur to trash? y/n" || msg="permanently delete $cur? y/n"
# false positive, behavior intentional
# shellcheck disable=2015
- [ -e "$cur" ] && yes_no "$msg" $# || continue
+ [ -e "$cur" ] && yes_no "permanently delete $cur? y/n" $# || continue
remove_selected "$cur" || :
- if [ -z $del ]; then
- msg_line 'Trashing File'
- mv -- "$cur" "$trash"
- else
- msg_line 'Deleting File'
- rm -rf -- "$cur"
- fi
+ msg_line 'Deleting File'
+ rm -rf -- "$cur"
[ $y -eq $# ] && y=$((y - 1))
[ $y2 -eq $# ] && y2=$((y2 - 1))
[ $y -eq 0 ] && y=1
@@ -911,11 +896,6 @@ main() {
y=1 y2=1
;;
- t?)
- switch_dir "$trash" || continue
- set_type=normal y=1 y2=1 ltype=
- ;;
-
r?)
[ -n "$ltype" ] || [ $# -lt 1 ] && continue
for w; do