mirror of
https://github.com/arcan1s/arcanis.me.git
synced 2025-04-24 23:37:19 +00:00
added rm func to zshrc
This commit is contained in:
parent
f098b3d612
commit
84d5d9d7ba
@ -267,8 +267,6 @@ alias du='show_which du && du -k --total --human-readable'
|
|||||||
# change less and zless to vimpager
|
# change less and zless to vimpager
|
||||||
alias less='vimpager'
|
alias less='vimpager'
|
||||||
alias zless='vimpager'
|
alias zless='vimpager'
|
||||||
# more interactive rm
|
|
||||||
alias rm='show_which rm && rm -I'
|
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<p align="justify">Here are ls aliases (see <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
|
<p align="justify">Here are ls aliases (see <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
|
||||||
@ -424,6 +422,42 @@ su () {
|
|||||||
}
|
}
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
|
<p align="justify">Function that replaces original <code>rm</code> command. If you type <code>rm</code> it will be equivalent moving to trash an you can easily restore a file:</p>
|
||||||
|
{% highlight bash %}
|
||||||
|
rm () {
|
||||||
|
# error check
|
||||||
|
[ $# -eq 0 ] && { echo "Files are not set!"; return 1 }
|
||||||
|
# set trash path
|
||||||
|
TRASHDIR="$HOME/.local/share/Trash"
|
||||||
|
TRASHFILE="${TRASHDIR}/files"
|
||||||
|
TRASHINFO="${TRASHDIR}/info"
|
||||||
|
for DIRECTORY in "${TRASHDIR}" "${TRASHFILE}" "${TRASHINFO}"; do
|
||||||
|
if [ -e "${DIRECTORY}" ]; then
|
||||||
|
[ -d "${DIRECTORY}" ] || { echo "'${DIRECTORY}' is a file"; return 1 }
|
||||||
|
else
|
||||||
|
mkdir -p -m755 "${DIRECTORY}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# confirm
|
||||||
|
CONFIRM=""
|
||||||
|
echo -n "You realy want to remove '$@'? [y/n] "; read -k1 CONFIRM; echo
|
||||||
|
[[ ! $CONFIRM =~ [yY] ]] && return 1
|
||||||
|
# move
|
||||||
|
for FILE in "$@"; do
|
||||||
|
DESTFILE="$(basename ${FILE})"
|
||||||
|
SUFFIX='';
|
||||||
|
ITER=0;
|
||||||
|
while [ -e "${TRASHFILE}/${DESTFILE}${SUFFIX}" ]; do
|
||||||
|
SUFFIX="_${ITER}";
|
||||||
|
ITER=$(expr ${ITER} + 1)
|
||||||
|
done
|
||||||
|
echo "Remove '${FILE}'"
|
||||||
|
mv "${FILE}" "${TRASHFILE}/${DESTFILE}${SUFFIX}"
|
||||||
|
echo "[Trash Info]\nPath=$(realpath ${FILE})\nDeletionDate=$(date +%Y-%m-%dT%H:%M:%S)" > "${TRASHINFO}/${DESTFILE}${SUFFIX}.trashinfo"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
<p align="justify">Functions with automatic rehash after installing/removing packages are:</p>
|
<p align="justify">Functions with automatic rehash after installing/removing packages are:</p>
|
||||||
{% highlight bash %}
|
{% highlight bash %}
|
||||||
pacman () {
|
pacman () {
|
||||||
|
@ -11,7 +11,7 @@ title: About me
|
|||||||
<h1>{{ page.title }}</h1>
|
<h1>{{ page.title }}</h1>
|
||||||
|
|
||||||
<p class="view"><a href="https://github.com/arcan1s">GitHub Profile</a><br>
|
<p class="view"><a href="https://github.com/arcan1s">GitHub Profile</a><br>
|
||||||
<a href="https://www.archlinux.org/trustedusers/#arcanis">TU Profile on <code>archlinux.org</code></a><br>
|
<a href="https://www.archlinux.org/trustedusers/#arcanis">TU Profile on archlinux.org</a><br>
|
||||||
<a href="http://istina.msu.ru/profile/arcanis">Some of my publications</a><br>
|
<a href="http://istina.msu.ru/profile/arcanis">Some of my publications</a><br>
|
||||||
PGP signature: <a href="http://pgp.mit.edu:11371/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x779CD2942629B7FA04AB8F172E89012331361F01">0x31361F01</a></p>
|
PGP signature: <a href="http://pgp.mit.edu:11371/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x779CD2942629B7FA04AB8F172E89012331361F01">0x31361F01</a></p>
|
||||||
|
|
||||||
|
@ -267,8 +267,6 @@ alias du='show_which du && du -k --total --human-readable'
|
|||||||
# замена less и zless на vimpager
|
# замена less и zless на vimpager
|
||||||
alias less='vimpager'
|
alias less='vimpager'
|
||||||
alias zless='vimpager'
|
alias zless='vimpager'
|
||||||
# более интерактивный rm
|
|
||||||
alias rm='show_which rm && rm -I'
|
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<p align="justify">ls аллиасы (смотри <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
|
<p align="justify">ls аллиасы (смотри <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
|
||||||
@ -424,6 +422,42 @@ su () {
|
|||||||
}
|
}
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
|
<p align="justify">Функция, которая заменяет оригиналькую команду <code>rm</code>. Если Вы наберете <code>rm</code>, это будет эквивалентно перемещению в корзину, также, Вы можете легко восстановить удаленный файл:</p>
|
||||||
|
{% highlight bash %}
|
||||||
|
rm () {
|
||||||
|
# error check
|
||||||
|
[ $# -eq 0 ] && { echo "Files are not set!"; return 1 }
|
||||||
|
# set trash path
|
||||||
|
TRASHDIR="$HOME/.local/share/Trash"
|
||||||
|
TRASHFILE="${TRASHDIR}/files"
|
||||||
|
TRASHINFO="${TRASHDIR}/info"
|
||||||
|
for DIRECTORY in "${TRASHDIR}" "${TRASHFILE}" "${TRASHINFO}"; do
|
||||||
|
if [ -e "${DIRECTORY}" ]; then
|
||||||
|
[ -d "${DIRECTORY}" ] || { echo "'${DIRECTORY}' is a file"; return 1 }
|
||||||
|
else
|
||||||
|
mkdir -p -m755 "${DIRECTORY}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# confirm
|
||||||
|
CONFIRM=""
|
||||||
|
echo -n "You realy want to remove '$@'? [y/n] "; read -k1 CONFIRM; echo
|
||||||
|
[[ ! $CONFIRM =~ [yY] ]] && return 1
|
||||||
|
# move
|
||||||
|
for FILE in "$@"; do
|
||||||
|
DESTFILE="$(basename ${FILE})"
|
||||||
|
SUFFIX='';
|
||||||
|
ITER=0;
|
||||||
|
while [ -e "${TRASHFILE}/${DESTFILE}${SUFFIX}" ]; do
|
||||||
|
SUFFIX="_${ITER}";
|
||||||
|
ITER=$(expr ${ITER} + 1)
|
||||||
|
done
|
||||||
|
echo "Remove '${FILE}'"
|
||||||
|
mv "${FILE}" "${TRASHFILE}/${DESTFILE}${SUFFIX}"
|
||||||
|
echo "[Trash Info]\nPath=$(realpath ${FILE})\nDeletionDate=$(date +%Y-%m-%dT%H:%M:%S)" > "${TRASHINFO}/${DESTFILE}${SUFFIX}.trashinfo"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
<p align="justify">Функция для автоматических обновлений путей после установки пакето:</p>
|
<p align="justify">Функция для автоматических обновлений путей после установки пакето:</p>
|
||||||
{% highlight bash %}
|
{% highlight bash %}
|
||||||
pacman () {
|
pacman () {
|
||||||
|
@ -12,7 +12,7 @@ title: Обо мне
|
|||||||
<h1>{{ page.title }}</h1>
|
<h1>{{ page.title }}</h1>
|
||||||
|
|
||||||
<p class="view"><a href="https://github.com/arcan1s">Профиль на GitHub</a><br>
|
<p class="view"><a href="https://github.com/arcan1s">Профиль на GitHub</a><br>
|
||||||
<a href="https://www.archlinux.org/trustedusers/#arcanis">Профиль TU на <code>archlinux.org</code></a><br>
|
<a href="https://www.archlinux.org/trustedusers/#arcanis">Профиль TU на archlinux.org</a><br>
|
||||||
<a href="http://istina.msu.ru/profile/arcanis">Некоторые из моих публикаций</a><br>
|
<a href="http://istina.msu.ru/profile/arcanis">Некоторые из моих публикаций</a><br>
|
||||||
PGP: <a href="http://pgp.mit.edu:11371/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x779CD2942629B7FA04AB8F172E89012331361F01">0x31361F01</a></p>
|
PGP: <a href="http://pgp.mit.edu:11371/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x779CD2942629B7FA04AB8F172E89012331361F01">0x31361F01</a></p>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user