summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchadsearch2
-rwxr-xr-xinpath44
-rwxr-xr-xlogrm17
-rwxr-xr-xnewscript18
-rwxr-xr-xsaferm39
5 files changed, 114 insertions, 6 deletions
diff --git a/chadsearch b/chadsearch
index eae954f..824ca87 100755
--- a/chadsearch
+++ b/chadsearch
@@ -2,7 +2,7 @@
chadsearch ()
{
- librewolf --search "$1"
+ librewolf --new-window --search "$1"
}
chadsearch $1
diff --git a/inpath b/inpath
new file mode 100755
index 0000000..f625b17
--- /dev/null
+++ b/inpath
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+in_path () {
+ local cmd=$1 path=$2 res=1
+ local IFS=":"
+
+ for dir in $path;
+ do
+ if [ -x "$dir/$cmd" ]; then
+ res=0
+ break
+ fi
+ done
+
+ return $res
+}
+
+cmd_in_path () {
+ var=$1
+
+ if [ -n "$var" ]; then
+ if [ $(echo "$var" | cut -c 1) = "/" ]; then
+ if [ ! -x $var ]; then
+ return 1
+ fi
+ elif ! in_path $var "$PATH"; then
+ return 2
+ fi
+ fi
+}
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 <command>" >&2
+ exit 1
+fi
+
+cmd_in_path "$1"
+case $? in
+ 0 ) echo "$1 found in PATH" ;;
+ 1 ) echo "$1 not found or not executable" ;;
+ 2 ) echo "$1 not found in PATH" ;;
+esac
+
+exit 0
diff --git a/logrm b/logrm
new file mode 100755
index 0000000..7ba296a
--- /dev/null
+++ b/logrm
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+removelog="/var/log/remove.log"
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $0 [-s] list of files or directories" >&2
+ exit 1
+fi
+
+if [ "$1" = "-s" ]; then
+ shift
+else
+ echo "$(date): ${USER}: $@" >> $removelog
+fi
+
+rm -i "$@"
+exit 0
diff --git a/newscript b/newscript
index 709d592..ef450a5 100755
--- a/newscript
+++ b/newscript
@@ -2,12 +2,20 @@
newscript ()
{
- if [ -z "$1" ]; then
- echo "Usage: newscript <script-name>"
- return 1
- fi
local name=$1
- cd ~/.scripts && touch "$name" && printf "#!/bin/sh\n\n" > "$name" && vim +2 "$name" && chmod +x "$name" && cd -
+ cd ~/.scripts && touch "$name" && printf "#!/bin/sh\n\n" > "$name" && vim +2 "$name"
+ local linecount=$(wc -l < $HOME/.scripts/$name)
+ if [ "$linecount" -lt 2 ]; then
+ rm -f "$HOME/.scripts/$name"
+ else
+ chmod +x "$name" && cd -
+ fi
}
+if [ $# -ne 1 ]; then
+ echo "Usage: newscript <script-name>"
+ exit 1
+fi
+
newscript $1
+exit 0
diff --git a/saferm b/saferm
new file mode 100755
index 0000000..9a455fa
--- /dev/null
+++ b/saferm
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+archive="$HOME/.deleted"
+realrm="$(which rm)"
+copy="$(which cp) -R"
+
+if [ $# -eq 0 ]; then
+ exec $realrm
+fi
+
+flags=""
+
+while getopts "dfiPRrvW" opt
+do
+ case $opt in
+ f ) exec $realrm "$@" ;;
+ * ) flags="$flags -$opt" ;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+if [ ! -d $archive ]; then
+ if [ ! -w $HOME ]; then
+ echo "$0 failed: can't create $archive in $HOME" >&2
+ exit 1
+ fi
+ mkdir $archive
+ chmod 700 $archive
+fi
+
+for arg
+do
+ newname="$archive/$(date "+%S.%M.%H.%d.%m").$(basename "$arg")"
+ if [ -f "$arg" -o -d "$arg" ]; then
+ $copy "$arg" "$newname"
+ fi
+done
+
+exec $realrm $flags "$@"