razputnik: (Default)
[personal profile] razputnik
I noticed a few people making posts about editing their shell history with vi - so I thought I'd contribute this little trick that someone may or may not have mentioned already:

If you add "set -o vi" to the end of your .bashrc, it changes your command line editing mode to vi keybindings, meaning you can use hjkl to navigate through your history and edit lines using vi oldies but goldies like cw and c$. It's a bit of a pain to get used to at first, but it's good if you're the type who keeps typing cw when you want to change an argument and then get annoyed when it just inserts that as text.

pauamma: Cartooney crab holding drink (Default)
[personal profile] pauamma
Context was someone asking why
print "Hello, world!\n" && die;
doesn't output anything. Someone replied with a nifty trick to help figure this out:
perl -MO=Deparse -e 'print "Hello, world!\n" && die;'
perl -MO=Deparse,-p -e 'print "Hello, world!\n" && die;'
(go ahead and try it).

Note: -p won't make a difference here, but it helps if you suspect perl's notion of operator priorities is different from yours.

(crossposted from http://dw-dev-training.dreamwidth.org/23661.html at pne's suggestion)
jadelennox: Senora Sabasa Garcia, by Goya (Default)
[personal profile] jadelennox
I've been a tcsh user now for... well, for a very long time, and a csh user before that. Understandably, that means that I'm at least a low-level tcsh power user. However, because I do anything that requires a complex control flow in bash, I've been thinking about switching to bash for my everyday commandline needs.

But it's scary, because I don't want to switch out of a shell where I am a power user. Does anybody have any links to good resources for switching from tcsh to bash? Handholding, tips, or the like?
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)
[personal profile] sophie
A quick tip for bash users that I use all the time:

If you have a command in your history that you want to re-execute or edit, but don't want to keep tapping the up key, hit Ctrl-R and then start typing part of the line. bash will find the last line matching your input on the fly. If it's not the one you want, either keep typing until it is, or hit Ctrl-R and bash will show you the next match.

Once you've got it, you have two options: to execute, you can then just press RETURN; to edit, use a movement key (left/right arrows, Home/End, etc) and bash will drop you back to a standard command line with the line you just found.

This trick also works if you know the middle of the line but not the beginning, since bash searches the entire line.

[edited to add: BTW, Fey, do you realise that nobody can add new tags to posts in this community? The only tags in here are ones first used by you. :)]
pixel: Adam Lambert looking up with a smile. (glambert: adam OHHAI)
[personal profile] pixel
This is one I've been on the lookout for.
Pianobar plays your pandora.com stations from the command line. BYE BYE FLASH :D

There are some vague directions for various flavors of linux on the home page.
Here's how I installed on Ubuntu 10.4 )
Screenshot of pianobar running, lots of options... )
brownbetty: Tim gazes upon Dick's manly chest.  "Wow!" (Wow)
[personal profile] brownbetty
[personal profile] pixel's post below reminded me that I have meant to post this for a while: Screen! Screen seems sort of like the secret weapon of command-line users; somehow it takes one ages to discover it, and if one is not far enough along in one's command-line usage, it just ends up seeming sort of mean-spirited and baffling. It's documented, but it's such a swiss-army knife that it's easy to get lost in the maze of documentation. However, at a certain level of usage, it suddenly becomes the most useful program ever.

So I wanted to ask people their favourite things to do with screen, and to share their .screenrc files, where they've modified them in interesting ways.

My favourite thing to do with screen )

from my .screenrc )
pixel: (txt: talknerdy)
[personal profile] pixel
Three very nifty tools come together to make my (and your!) life easier. Or use them separately, it's all the same to me...

Guake is a 'dropdown' terminal in the style of Quake chat (for GNOME.) I'm not even a gamer and I love it. It's always there, ready for me with one keystroke. I tried Tilda as well but Tilda kept eating screen so that was a no-go. There are similar programs if you're running KDE but I'm not sure about XFCE.

There are tabs available in Guake itself but I can't make it NOT look clunky, so I buckled down and started re-learning screen. If you're a command line fan, give it a try, so many things available at a keystroke. The real magic is that I can disconnect and reconnect to screens on a whim. For example I cribbed and modified a script that launches a bunch of useful programs for RoR development in screen, so I have one project running in an instance of screen. I could launch another project in another instance of screen and flip back and forth. I could open up another terminal app and reconnect to my session there. I could go downstairs with my netbook, ssh in and reconnect to my screen there.

Finally the newest shiniest kid on the block: Taskwarrior (task) a super easy to use, flexible, feature rich command line todo list. This is the todo list I've been waiting for my whole life. See a basic demo on youtube. That's an older version (1.0, latest is 1.9.2) so there are a bunch more new features in more recent versions and it's still in active development.

So on any given day, I've got a screen session open for taskwarrior connected in Guake. My todo list is right there, and I can get to it anywhere with my netbook. I'm playing with getting tasks to show up on conky, if anyone is interested in that, I can let you know what I come up with. Now to tweak it and make it available off my home network....
sigflup: (Default)
[personal profile] sigflup
Soon to be released, my terminal-emulator called "Hack The Planet TERM". It's coming real close to becoming beta and I'll release it in the next Uber Leet Hacker Force RADIO show. Here's a video of it:

youtube link

If you're like me and don't use flash I suggest using the command-line youtube downloader, "youtube-dl"

This video was shot some while ago. While I don't have access to a camera now I can at least show you a screen-shot of what it currently looks like:

I'm currently looking for testers. I'm developing on openbsd and have a 32-bit ia linux lappy here. If anyone has a 64-bit machine and/or freebsd machines email pantsbutt@gmail.com and I'll give you the alpha if you help me getting it to work properly on your system.
tonybaldwin: tony baldwin (Default)
[personal profile] tonybaldwin
I often have to quick math on the fly while generating estimates for clients and doing other off the cuff calculations.
Previously, while using openbox or fluxbox, I had a keybinding bring up a calculator and did the math and then killed the calculator with ctrl+q.
But, I’m all about efficiency, and lately have been learning more and more of the powerful tools in bash to do various things, from navigating the file system to handling files and manipulating text. In wmii, I always have at least one bash terminal open (my preferred terminal emulator currently being roxterm).
So, I figured there had to be an efficient means of doing math without bringing up a gui calculator, too, but bash doesn’t like floating point numbers so well.
Now, with expr or echo or let one can do some basic math (ie. expr 220+34, or echo $((220+34))), but not with floating point numbers (with decimal points), which I need.
But bc can do it. One would have to type in something like:
echo ‘5467 * 0.09′ | bc
bc -l <<< 5467*0.09

to get the result....
Not really quick-n-dirty...
So, I scripted it:

# do math with bc
echo “Enter your equation:”
read e
echo “The result is:”
bc -l <<< $e

I called the script ‘M’ (for ‘Math’), and stuck it in /usr/local/bin.
Now, I just type
$ M
and I see:

Enter your equation:
(enter equation here)
The result is:
(result appears)
all done.
I type 1 letter (two keys, shift+m), and my equation.

tony@deathstar:~$ M
Enter your equation:
The result is:


posted with Xpostulate


Apr. 17th, 2010 02:53 pm
damned_colonial: A Babbage machine, and the words "Difference engine" (difference engine)
[personal profile] damned_colonial
One of my favourite random unix command line things:

skud@Watson:~$ cal 05 1891
      May 1891
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

skud@Watson:~$ cal 04 1891
     April 1891
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

I use this all the time when writing fic in historical fandoms! (It also works for the future, even beyond 2038.)

I've never yet written anything set in September of 1752, but this is interesting:

skud@Watson:~$ cal 09 1752
   September 1752
Su Mo Tu We Th Fr Sa
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

I'm not sure if it's locale aware, though... 1752 was the British (and colonies) switchover to the Gregorian calendar, but Russia didn't switch til 1918, and Greece til 1923. Anyone know?
jadelennox: Demonic Tutor, Jadelennox: my Magic card (demonic tutor)
[personal profile] jadelennox
I consider myself a vi power user, but after all these years there is still a ton I have to learn. Introducing the blog The Daily Vim, syndicated at [syndicated profile] dailyvim_feed. It's not even remotely daily (which is good -- it means I have time to learn its various tricks between posts) but it is handy for all kinds of editing and command line tricks. For example Easier command line editing teaches us this bash trick:

Start typing on the command line and then type Ctrl-x Ctrl-e, it should drop you into your system's default editor (hopefully Vim) and allow you to edit the command line from there. Once finished, save the command line, and bash will run the command.

Doesn't help me, because I'm a tcsh user, but I'm contemplating making the big switch back to bash.
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
cron is a time based job scheduler in *nix systems that lets you run a given command at specified times. I just had to compose a chron entry, and found this Cron Sandbox that lets me enter in the values I'm trying to use for specifying the times to run the command (every fifteen minutes turned out to be 0,15,30,45 * * * *). It was really helpful, because I'm not very experienced with cron as I've only had to ever use it a couple of times. Once you set it up, it just keeps chugging along without needing much maintenance!
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
We were talking about vi/[community profile] emacs in #dw and avid emacs user [personal profile] mocker reluctantly mentioned vimtutor to me, and so I'm mentioning it to you all here, in case some of you wanted to start learning vim. You should be able to use it just by typing vimtutor on the command line of a system that has vim installed.
brownbetty: (Default)
[personal profile] brownbetty
OMG, a community for the command line, my favourite!blither )

For those who, like me, don't like to use their mouse more than they have to, xsel can be very useful. It's a command-line interface to the X cut-buffer, and can empty, access, or change the contents. (If you go to the programmer's page, he in fact says it does something much more complicated, but if you're willing to settle for simple and inaccurate, that's what it does.)

examples )
chebe: (South Park)
[personal profile] chebe
Hey all, [personal profile] foxfirefey swung by my journal and let me know about this community. I think it's a fantastic idea, so I present to you my humble offering:

Ever wanted to make all that source code in your report/webpage much more readable by adding syntax highlighting, and specified formatting? Well, before you reach for the snapshot tool, try vim.


Produces a html formatted version of your file, syntax highlighted the way vim does things. Just save it, open in a browser, and copy-paste into your text processor. Voilá!

P.S. I haven't tried vi, anyone know if it works there too?
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
My roommate [personal profile] bucko just taught me this command! It's kind of fun to use in a casual way:

say Moo

But one nifty thing you can do with it, possibly, is have the computer translate a text file into a sound file (say, the first chapter of Alice in Wonderland:

say -o "alice.aiff" -f alice.txt -v "Alex"

It's not the best vocalization, but if you want to have your iPod dictate something to you on the bus, it could be useful. You'll probably want to convert the file to an MP3, though, to save space. The -v option specifies which voice to use -- you can find a useful list someone compiled here or see the list in the Speech Text-To-Voice system preference panel.
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
There is something imminently satisfying about using find and xargs to accomplish tasks on files in the folder tree:

find . -name "*.orig" | xargs rm

I use it to delete certain leftover files from editors or version control systems, or to change the permissions on all of a certain kind of file. I also use it to recursively grep in certain instances:

find . -name "*.pl" | xargs grep -i "OpenID"

Here are a couple of articles for those interested in learning more about this awesome combo:

Advanced techniques for using the find command
Unix Xargs Piping Toolkit Utility
foxfirefey: Fox stealing an egg. (Default)
[personal profile] foxfirefey
So, vi(m) is a great command line editor if you've started to outgrow nano. But, if you are copy pasting chunks of things into it, sometimes it does some...creative reformatting. You can stop this if you use this command before you do your i (insert letter) and paste:

:set paste
foxfirefey: Fox stealing an egg. (Default)
[personal profile] foxfirefey
I learned this one recently from a coworker:

cd -

This will allow you to switch to your previous current working directory. So:

# Go into first directory
cd ~/path/to/first/dir
# Go into second directory
cd ~/path/to/second/dir
# This takes us back to the first directory
cd -
# This takes us back to the second directory
cd -

This is really useful if you have two main directories you're currently working in.
Page generated Sep. 20th, 2017 09:45 pm
Powered by Dreamwidth Studios