Commands tagged css (5)

  • Ever compress a file for the web by replacing all newline characters with nothing so it makes one nice big blob? It is a great idea, however what about when you want to edit that file? ...Serious pain in the butt. I ran into this today in that my only copy of a CSS file was "compressed" with no newlines. I whipped this up and it converted back into nice human readable CSS :-) It could be nicer, but it does the job.


    1
    cat somefile.css | awk '{gsub(/{|}|;/,"&\n"); print}' >> uncompressed.css
    lrvick · 2009-06-02 15:51:51 37
  • This searches through all CSS files in the current directory and sub-directories, matches the content between "url(...)", and prints a list of all the URLs. If you prefer to see the file the URL came from, remove the -h and --nogroup params. Show Sample Output


    0
    ack -o -h --nogroup --css 'url\((.*)\)' --output "\$1"
    calvinf · 2011-06-08 01:07:31 6
  • This will extract the differing CSS entries of two files. I've left the initial character (plus or space) in output to show the real differing line, remove the initial character to get a working CSS file. The output CSS file is usable by either adding it in a below the to original.css, or by only using the output but adding @import url("original.css"); in the beginning. This is very useful for converting Wordpress theme copies into real Wordpress child themes. Could exclude common lines within entries too, I guess, but that might not be worth the complexity. Show Sample Output


    0
    diff -U99999 original.css modified.css | awk '/^-/{next} {f=f"\n"$0} /^\+.*[^ ]/{yes=1} /}/ {if(yes){print f} f="";yes=0}'
    unhammer · 2012-01-12 07:57:22 4
  • With code, the only way to have spaces parsed correctly in any kind of portable way is to use ... but then long lines will not wrap. That's kinda important for low-res screens or smaller windows. Ideally, code blocks would be wrapped to the screen width, with line numbers and syntax hilighted, so that if someone does "view source", they'd see the unadulterated code for cutting and pasting. Then have all formatting done by CSS and javascript, such that: - if someone copies the text as displayed in any browser, they'll get properly formatted code in their clipboard, without wrapping - it fails gracefully so that it looks at least reasonable in all browsers, even those that don't know CSS/JS and can't do colours (eg lynx, screen readers) If anyone knows a way, that would make me happy. Until then, I am stuck with the above as the best I can do. For example, in LiveJournal, something like this: <div width="100%" style="(the code above)"><pre>Code goes here</pre> ... will look considerably better and more readable than the default <blockquote><pre></pre></blockquote>. It's not perfect, of course. If you have enough control to create your own css file, you should definitely do that instead.


    0
    overflow:auto;padding:5px;border-style:double;font-weight:bold;color:#00ff00;background-color:0;"><pre style="white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;_white-space:pre;
    DewiMorgan · 2012-02-28 04:14:11 8
  • Count the number of unique colors there are in a websites css folder (136 is way too many imho time to get people stick to a color scheme) Show Sample Output


    0
    grep -r -h -o 'color: #.*' css/*|sort|uniq -c|sort -n|wc -l
    thoth · 2015-12-29 07:22:44 10

What's this?

commandlinefu.com 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

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh 127.0.0.1 -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.

Find the package that installed a command

Mac osx friendly version of this terminal typing command at 200ms per key

Chmod all directories (excluding files)
+ at the end means that many filenames will be passed to every chmod call, thus making it faster. And find own {} makes sure that it will work with spaces and other characters in filenames.

renames multiple files that match the pattern
Useful when you want to quickly rename a bunch of files.

kill all process that belongs to you
This will probably kill any user sessions and/or ssh connections to other servers you might have active.

Binary clock
Like 7171, but fixed typo, uses fewer variables, and even more cryptic!

Show UDID of iPhone
Display the serial of the iPhone (aka UDID).

grep -v with multiple patterns.
If you wanted to do all in one command, you could go w/ sed instead

Pass TAB as field separator to sort, join, cut, etc.
Use this BASH trick to create a variable containing the TAB character and pass it as the argument to sort, join, cut and other commands which don't understand the \t notation. $ sort -t $'\t' ... $ join -t $'\t' ... $ cut -d $'\t' ...


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: