Commands by zed (11)

  • Change the value of p to match the path where you wish to create the profile. To run it again in the future, use the parameter --user-data-dir (which gets echoed to you when run): chromium-browser --user-data-dir=/path/to/your/ Quick Functions: # create a new chromium profile new-chromium-profile() { p=~/.config/chromium/$1; cp -r ~/.config/chromium/Default $p && echo "chromium-browser --user-data-dir=$p" && chromium-browser --user-data-dir=$p; } # runs a chromium profile run-chromium-profile() { chromium-browser --user-data-dir=~/.config/chromium/$1; } Show Sample Output

    p=~/.config/chromium/zed; cp -r ~/.config/chromium/Default $p && echo "chromium-browser --user-data-dir=$p" && chromium-browser --user-data-dir=$p;
    zed · 2010-11-08 02:45:29 0
  • Create a progress dialog with custom title and text using zenity. Show Sample Output

    for i in $(seq 0 5 100); do echo $i; sleep 1; done | zenity --progress --title "Installing Foobar" --text "Pleae wait until process has finished."
    zed · 2010-10-08 04:08:33 0
  • using seq inside a subshell instead of a bash sequence to create increments. Show Sample Output

    for i in $(seq 0 5 100); do echo $i; sleep 1; done | dialog --gauge "Install..." 6 40
    zed · 2010-10-08 04:08:17 0
  • A more robust password creation utility # Create passwords in batch makepasswd --char=32 --count=10 # To learn more about the options you can use man makepasswd Show Sample Output

    makepasswd --char=32
    zed · 2010-09-29 06:01:32 0
  • Changes your desktop background image in gnome. Update the directory to wherever you keep your wallpapers. I like to create a sub-directory in my Wallpaper folder called "cycle" that I use to define the wallpapers I wish to loop in cron. ex: gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find ~/Wallpapers/cycle -type f | shuf -n1)" Show Sample Output

    gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find ~/Wallpapers -type f | shuf -n1)"
    zed · 2010-09-21 04:01:55 0
  • Take a screenshot of the focused window with a 4 second countdown # shorten by adding to your .bashrc: alias sss='scrot -ucd4 && eog $(ls -tr | tail -n1)' echo -e "\nalias sss='scrot -ucd4 && eog $(ls -tr | tail -n1)'" >> ~/.bashrc -d 4 second delay -c display countdown -u focused window man scrot for more flags Show Sample Output

    scrot -ucd4 -e 'eog $f'
    zed · 2010-09-15 03:31:06 4
  • requires "youtube-dl" -- sure you can do this with wget and some more obscurity but why waste your time when this great tool is available? the guts consist of mplayer converting a video to a gif -- study this command and read the man page for more information mplayer video.flv -ss 00:23 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound generates a 6 second gif starting at 23 seconds of play time at 5 fps and a scale of 400x300 start time (-ss)/end time (-endpos) formats: 00:00:00.000 end time should be relative to start time, not absolute. i.e. -endpos 5 == seconds after 0:42 = 0:47 end point play with fps and scale for lower gif sizes the subshell is a solution for the -b flag on youtube-dl which downloads the best quality video, sometimes, which can be various video formats $(ls ${url##*=}*| tail -n1) Show Sample Output

    url=; youtube-dl -b $url; mplayer $(ls ${url##*=}*| tail -n1) -ss 00:57 -endpos 10 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound
    zed · 2010-07-18 02:11:39 1
  • The above is an example of grabbing only the first column. You can define the start and end points specifically by chacater position using the following command: while read l; do echo ${l:10:40}; done < three-column-list.txt > column-c10-c40.txt Of course, it doesn't have to be a column, or extraction, it can be replacement while read l; do echo ${l/foo/bar}; done < list-with-foo.txt > list-with-bar.txt Read more about parameter expansion here: Think of this as an alternative to awk or sed for file operations

    while read l; do echo ${l%% *}; done < three-column-list.txt > only-first-column.txt
    zed · 2010-07-09 03:42:56 0
  • The above is just a prove of concept based around the nested bash substitution. This could be useful in situations where you're in a directory with many filetypes but you only want to convert a few. for f in *.bmp *.jpg *.tga; do convert $f ${f%.*}.png; done or you can use ls | egrep to get more specific... but be warned, files with spaces will cause a ruckus with expansion but the bash for loop uses a space delimited list. for f in $(ls | egrep "bmp$|jpg$|tga$"); do convert $f ${f%.*}.png; done I'm guessing some people will still prefer doing it the sed way but I thought the concept of this one was pretty neat. It will help me remember bash substitutions a little better :-P Show Sample Output

    for f in t1.bmp t2.jpg t3.tga; do echo ${f%.*}.png; done
    zed · 2010-07-09 00:38:53 0
  • You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder). you can add it to your .bashrc file to have it great you with something interesting every time you start a new session. Show Sample Output

    fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
    zed · 2010-07-08 02:57:52 2
  • This will be seen through your system's visual notification system, notify-osd, notification-daemon, etc. --- sleep accepts s,m,h,d and floats (date; sleep .25m; date) --- notify-send (-t is in milliseconds && -u low / normal / critical) man notify-send for more information --- notification-daemon can use b/i/u/a HTML

    sleep 6s && notify-send -t 10000 -u critical "remember to think" &
    zed · 2010-07-01 02:17:24 3

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

find the longest command in your history

summarize a list of IP addresses, verifying IP address and giving counts for each IP found
Working with lists of IP addresses it is sometimes useful to summarize a count of how many times an IP address appears in the file. This example, summarizeIP, uses another function "verifyIP" previously defined in to ensure only valid IP addresses get counted. The summary list is presented in count order starting with highest count.

Adding leading zeros to a filename (1.jpg -> 001.jpg)

Convert encoding from cp1252 (MS Windows) to UTF-8 on source code files

Install pip with Proxy
Installs pip packages defining a proxy

Download free e-books
Mask the user agent as firefox, recursively download 2 levels deep from a span host with a maximum of 1 redirection, use random wait time and dump all pdf files to myBooksFolder without creating any other directories. Host will have no way of knowing that this is a grabber script.

Using Git, stage all manually deleted files.
-u tells git to automatically stage all changes to files in the index (eg. deleted and modified files). See:

Clear mistyped passwords from password prompt
Type ^u at password prompt to clear a mistyped password.

paste one file at a time instead of in parallel
paste one file at a time instead of in parallel

List all files in current dir and subdirs sorted by size
or $ tree -ifsF --noreport .|sort -n -k2|grep -v '/$' (rows presenting directory names become hidden)

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: