tag:blogger.com,1999:blog-19214560962863910562023-11-15T09:42:57.985-08:00Bits & Pieces Of Useful Linux ScriptsAnonymoushttp://www.blogger.com/profile/17917637021468872599noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1921456096286391056.post-23596448556005270722013-12-01T09:07:00.000-08:002013-12-01T09:07:08.294-08:00Bash PS1 prompt with exit status<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Just add the following code to your '~/.bashrc' file,<br />
<br /></div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
export PS1='\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[01;37m\]>\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[01;33m\]\w\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[$(((($?>0))*31))m\]\$\[\e[0m\] '
</code></pre>
<br />
And then run the following command to apply changes,<br />
<br /></div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
source .bashrc
</code></pre>
<br />
For screenshots and more information read my post here,<br />
<br />
<a href="http://hakerdefo.blogspot.in/2013/12/a-nice-looking-and-useful-bash-ps1.html#more" target="_blank">A nice looking and useful bash PS1 prompt</a><br />
<br />
Cheers.</div>
Anonymoushttp://www.blogger.com/profile/17917637021468872599noreply@blogger.com0tag:blogger.com,1999:blog-1921456096286391056.post-48878689243351687902013-08-09T11:09:00.000-07:002013-08-09T11:11:09.821-07:00Linux File Backup Script<div dir="ltr" style="text-align: left;" trbidi="on">
I've already written a detailed article on my blog <a href="http://hakerdefo.blogspot.com/" target="_blank">Looking at Linux through the Windows of Life</a> explaining this file backup script. So this post is going to be really short. Visit the following link to read more about this bash based file backup script for Linux.<br />
<br />
<a href="http://hakerdefo.blogspot.in/2013/05/hakbak-ultimate-file-backup-tool-for.html" target="_blank">Linux file backup script</a><br />
<br />
Cheers!!!</div>
Anonymoushttp://www.blogger.com/profile/17917637021468872599noreply@blogger.com0tag:blogger.com,1999:blog-1921456096286391056.post-28353425411340121552013-07-28T03:03:00.000-07:002013-07-30T02:40:18.979-07:00Linux Screen Capture Script<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
This bash script uses scrot as back-end so you will need <a href="http://freecode.com/projects/scrot" target="_blank">scrot</a> installed on your system. scrot is available in repository of almost every distribution.<br />
Why not use scrot directly you might ask?<br />
<br />
<a name='more'></a>You can use scrot on it's own but you will need to remember and type all the options in order to harness the power of scrot. This simple script makes it easy for everyone to capture entire screen, Window in focus or any part of desktop or window according to need without remembering scrot options.<br />
<br />
What's more it saves all the captured images in '~/Pictures/Screenshots' directory. It will create this directory if it doesn't exist. It will name the screenshot according to the time it was captured on. This time stamping makes it easy to sort screenshots later-on.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://imgur.com/ZXxEvxQ" style="margin-left: 1em; margin-right: 1em;"><img src="http://i.imgur.com/ZXxEvxQ.png" height="216" title="Hosted by imgur.com" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://imgur.com/yH1Qip1" style="margin-left: 1em; margin-right: 1em;"><img src="http://i.imgur.com/yH1Qip1.png" height="240" title="Hosted by imgur.com" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://imgur.com/ARuXSTk" style="margin-left: 1em; margin-right: 1em;"><img src="http://i.imgur.com/ARuXSTk.png" height="216" title="Hosted by imgur.com" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://imgur.com/vEVjqkf" style="margin-left: 1em; margin-right: 1em;"><img src="http://i.imgur.com/vEVjqkf.png" height="216" title="Hosted by imgur.com" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://imgur.com/E2FyzxW" style="margin-left: 1em; margin-right: 1em;"><img src="http://i.imgur.com/E2FyzxW.png" height="216" title="Hosted by imgur.com" width="320" /></a></div>
<br />
So without further delay here's the script. Save it somewhere in path and make it executable. Using it is pretty self-explanatory.<br />
<br /></div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
#!/bin/bash
DIR="${HOME}/Pictures/Screenshots"
DATE="$(date +%d%m%y-%H%M%S)"
SHORT_NAME="Shot-${DATE}.png"
NAME="${DIR}/${SHORT_NAME}"
clear
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi
echo -e '\E[1;36m'"***** HAKERDEFO'S SCREEN SHOOTER *****";
echo -e '\E[1;32m'"*****^^^^^^^^^^^*^^^*^^^^*^^^^^^^*****";
echo -e '\E[1;36m'"Select one of the following options: ";
echo -e '\E[1;32m'"*****^^^^^^^^^^^*^^^*^^^^*^^^^^^^*****";
echo -e '\E[1;32m'"Press"'\E[1;36m' "[E]" '\E[1;32m'"To Take The Screenshot Of The Entire Screen.";
echo -e '\E[1;32m'"Press"'\E[1;36m' "[W]" '\E[1;32m'"To Take The Screenshot Of Window In Focus.";
echo -e '\E[1;32m'"Press"'\E[1;36m' "[A]" '\E[1;32m'"To Take The Screenshot Of Area Selected By Mouse.";
read option
case "$option" in
"E" | "e" )
clear
echo -e '\E[1;33m'"Minimize Terminal To Avoid It From Being Captured...";
scrot -d15 -c "${NAME}"
clear
echo -e '\E[1;36m'"$SHORT_NAME Saved in '$DIR'.";
;;
"W" | "w" )
clear
echo -e '\E[1;33m'"Minimize Terminal And Bring The Window To Be Captured In Focus...";
scrot -u -d15 -c "${NAME}"
clear
echo -e '\E[1;36m'"$SHORT_NAME Saved in '$DIR'.";
;;
"A" | "a" )
clear
echo -e '\E[1;33m'"Draw A Rectangle On The Screen And Area Inside It Will Be Captured...";
scrot -s "${NAME}"
clear
echo -e '\E[1;36m'"$SHORT_NAME Saved in '$DIR'.";
;;
* )
clear
echo -e '\E[1;36m'"Incorrect Option Selected. Bye... Bye...";
sleep 1
echo -e "\033[0m"
clear
;;
esac
echo -en '\e[0m';
exit 0
</code></pre>
<br />
Suggestions, ideas are welcome!!!<br />
Cheers!!!</div>
Anonymoushttp://www.blogger.com/profile/17917637021468872599noreply@blogger.com0