Skip to content

Commit 26a8b00

Browse files
committed
let mv instead rm
1 parent 815af03 commit 26a8b00

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

rmtomv.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
###重定义rm命令###
2+
3+
#定义回收站目录
4+
trash_path=’~/.trash’
5+
6+
#判断$trash_path 定义的文件是否存在,如果不存在,那么就创建$trash_path.
7+
if [ ! -d $trash_path ]; then
8+
mkdir -p $trash_path
9+
fi
10+
11+
#定义别名:使用rm就调用trash
12+
alias rm=trash
13+
14+
#使用rl就调用’ls ~/.trash’ 如果更改上面的回收站目录这里的目录也需要修改
15+
alias rl=’ls ~/.trash’
16+
17+
#使用unrm就调用restorefile
18+
alias unrm=restorefile
19+
20+
#使用rmtrash就调用claearteash
21+
alias rmtrash=cleartrash
22+
23+
#恢复文件的函数
24+
restorefile()
25+
{
26+
mv -i ~/.trash/$@ ./
27+
}
28+
29+
#删除文件的函数
30+
trash()
31+
{
32+
mv $@ ~/.trash/
33+
}
34+
35+
#清空回收站的函数
36+
cleartrash()
37+
{
38+
read -p “确定要清空回收站吗?[y/n]” confirm
39+
[ $confirm == ‘y’ ] || [ $confirm == ‘Y’ ] && /bin/rm -rf ~/.trash/*
40+
}

0 commit comments

Comments
 (0)