Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

add or change extension of files

add .udf to all files in working directory

for i in `ls`; do mv $i $i".udf"; done

change extensions of files to "zip".
#new extension: zip
yeniUzanti="zip"; for i in `ls`; do noktalar=`echo $i|awk -F. '{ print NF - 1 }'`; dosyaAdi=`echo $i|cut -d'.' -f1-$noktalar`; mv $i $dosyaAdi"."$yeniUzanti; done

write matrix chars to another user console for manipulation

watch the video for action :-).

#!/bin/bash -       
#title           :matrix_to_user_console.sh
#description     :This script will write matrix characters to another user console :-) .
#author          :Mehmet DEMİR
#date            :20140302
#version         :0.1    
#usage           :bash matrix_to_user_console.sh
#notes           :Will be fun!
#==============================================================================

#remove comment if target user at remote
#ssh root@10.6.181.111 

target_user="mehmet"
the_message="\n
\n
################################################\n
################################################\n
################## THE MATRIX ##################\n
################################################\n
# Your computer got involved in matrix network.#\n
# Don't touch this machine! ####################\n
################################################\n
################################################\n
\n
\n"
message_duration=10 # as second
target_tty="/dev/"`who|grep $target_user|tail -1|awk {'print $2'}`


echo -e $the_message > $target_tty
sleep $message_duration

# from https://github.com/devsnd/matrix-curses/blob/master/matrix-curses.py
MATRIX_CODE_CHARS=(ɀ Ɂ ɂ ŧ Ϣ ϣ Ϥ ϥ Ϧ ϧ Ϩ ϫ Ϭ ϭ Ϯ ϯ ϰ ϱ Ϣ ϣ Ϥ ϥ Ϧ ϧ Ϩ ϩ Ϫ ϫ Ϭ ϭ Ϯ ϯ ϰ ߃  ߄ ༣ ༤ ༥ ༦ ༧ ༩ ༪ ༫ ༬ ༭ ༮ ༯ ༰ ༱ ༲ ༳ ༶)

count=${#MATRIX_CODE_CHARS[*]}

maxcol=15

while (true);  do  

    noshow=$((RANDOM % $count))
    noshowchar[$noshow]=$noshow;

    for (( i=0; i<=$maxcol; i++ ))
    do
            if [ "${noshowchar[$i]}" == "$i" ]; then
                printf '\t%s' ' ' > $target_tty
            else
                index=$((RANDOM % $count))
                printf '\t%s' ${MATRIX_CODE_CHARS[$index]} > $target_tty          
            fi  
    done
     
     printf '\n' > $target_tty
     sleep 0.05

     noshowchar[$((RANDOM % $count))]=100;
     noshowchar[$((RANDOM % $count))]=100;
     noshowchar[$((RANDOM % $count))]=100;
     noshowchar[$((RANDOM % $count))]=100;
     noshowchar[$((RANDOM % $count))]=100;

done

exit 0


Run a command to terminal from gedit with shortcut key

Hi guys.
If you working with gedit and terminal this tool is very usefull for run  a command to in the terminal from gedit (previous window).

I wrote a script with gedit external plugin for this purpose.

How to use:
  • Select a text and press "Alt+B" key
    or
  • Locate a cursor to line and press "Alt+L" key
Watch video to see it.


Installation on Ubuntu :

install gedit plugins.
# sudo apt-get install gedit-plugins 
install xdotool.
# sudo apt-get install xdotool

Open gedit ->  Edit -> Preferences -> Enable External Tools plugin.
Open gedit -> Manage External Tools -> click +
paste the script in the below to Edit: box.
#!/bin/sh
cat - > /tmp/runprev_meh.txt
line=$(cat /tmp/runprev_meh.txt)
xdotool key alt+Tab
xdotool sleep 0.2
xdotool type "$line"
xdotool key Return
xdotool key alt+Tab

Select Shortcut Key: <ALT+L>


Click againt +, for another shortcut (run "Current selection"). <ALT+B> 
All is same except "Input: Current selection" and shortcut key.