Take a screenshot of the window the user clicks on and name the file the same as the window title

2010-12-19 2 min read Bash Learning Photo

Take a screenshot of the window the user clicks on and name the file the same as the window title

  <td>
    <div class="text codecolorer">
      &nbsp;sleep 4; xwd >foo.xwd; mv foo.xwd "$(dd skip=100 if=foo.xwd bs=1 count=256 2>/dev/null | egrep -ao '^[[:print:]]+' | tr / :).xwd"
    </div>
  </td>
</tr>
1

In general, this is actually not better than the “scrot -d4” command I’m listing it as an alternative to, so please don’t vote it down for that. I’m adding this command because xwd (X window dumper) comes with X11, so it is already installed on your machine, whereas scrot probably is not. I’ve found xwd handy on boxen that I don’t want to (or am not allowed to) install packages on.

Continue reading

Make any command read line enabled (on *nix)

2010-11-25 1 min read Bash Fedora Linux

Make any command read line enabled (on *nix)

  <td>
    <div class="text codecolorer">
      rlwrap sqlite3 database.db
    </div>
  </td>
</tr>
1

Enable readline even if the command line application is not using it.

* View this command to comment, vote or add to favourites * View all commands by pykler

commandlinefu.com

by David Winterbottom (codeinthehole.com)

URL: http://feedproxy.google.com/~r/Command-line-fu/~3/mKEgYoyHCMA/make-any-command-read-line-enabled-on-nix

Enhanced by Zemanta

intercept stdout/stderr of another process or disowned process

2010-11-23 1 min read Bash Fedora Linux

The command is definately going to save your day if you have disowned the process by mistake. Only uses strace so might as well work on Solaris also, though not tried it.

intercept stdout/stderr of another process or disowned process

  <td>
    <div class="text codecolorer">
      strace -e write=1,2 -p $PID 2>&1 | sed -un "/^ |/p" | sed -ue "s/^.{9 }(.{50}).+/1/g" -e 's/ //g' | xxd -r -p
    </div>
  </td>
</tr>
1

Useful to recover a output(stdout and stderr) “disown”ed or “nohup“ep process of other instance of ssh.

Continue reading

Broadcast your shell thru port 5000

2010-11-20 1 min read Bash Fedora Linux

Broadcast your shell thru port 5000

  <td>
    <div class="text codecolorer">
      mkfifo /tmp/fifo;(nc -q0 -l 5000 < /tmp/fifo &);script -f /tmp/fifo
    </div>
  </td>
</tr>
1

run

  <td>
    <div class="text codecolorer">
      nc yourip 5000
    </div>
  </td>
</tr>
1

elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.

Continue reading

Screen enable/disable logging in all windows

2010-11-19 1 min read Bash Learning Linux

If you use screen command a lot then this is something that you will like 🙂

Screen enable/disable loggin in all windows

  <td>
    <div class="text codecolorer">
      bindkey ^l at "#" log on<br /> <br /> bindkey ^o at "#" log off
    </div>
  </td>
</tr>
1
2
3

The command when added in screenrc enables logging all open windows by using the C-l (control-l key combination) and disable by C-o . The lines need to be added in separate lines .

Continue reading

function for copy files with progress bar (using pv – pipe viewer)

2010-11-11 1 min read Bash Linux

function for copy files with progress bar (using pv – pipe viewer)

  <td>
    <div class="text codecolorer">
      &nbsp;cp_p() { if [ `echo "$2" | grep ".*/$"` ]; then pv "$1" > "$2""$1"; else pv "$1" > "$2"/"$1"; fi; }
    </div>
  </td>
</tr>
1

dont have to type new file name (it copy file under same name) and dont have to use ‘/’ in the end of destination folder (but you can if u want, its idiot proof)

Continue reading
Older posts Newer posts