Emacs ansi-term tricks

December 26, 2008 at 11:30 AM | categories: emacs | View Comments

Being on vacation is soo nice. With some of my free time I'm planning on revamping my emacs environment, so hopefully that means a few more articles showing up here on that topic.

I read some great tips on ansi-term. Ansi-term is a terminal emulator written in emacs lisp that is as close to a real terminal as possible. That means you can run virtually all command line programs, even the ones that use ncurses like top or screen, all within emacs. You can still switch between line and char modes which means you can still edit the buffer as you could in a regular (emacs) shell too.

F2 Keybinding

In the above mentioned article Joseph wrote a nice little bit of elisp to get to a running ansi-term efficiently, by hitting F2. The nice thing about it is that it does what I mean:

  1. If I'm already in an ansi-term, but it's called "*ansi-term*" rename it.
  2. If I'm already in an ansi-term, but it's called something else, start a new ansi-term called "*ansi-term*"
  3. If I'm in another non-terminal buffer, switch to a buffer called "*ansi-term*" or create a new one if it doesn't exist

There's one more catch though, as Joseph explains, an ansi-term can be considered "stopped" such that it is no longer running but the buffer still exists. In that case I don't want the third rule to switch me to a defunct terminal, so instead I want it to kill the buffer and create a new ansi-term. Here is my enhanced elisp:

(require 'term)
(defun visit-ansi-term ()
  "If the current buffer is:
     1) a running ansi-term named *ansi-term*, rename it.
     2) a stopped ansi-term, kill it and create a new one.
     3) a non ansi-term, go to an already running ansi-term
        or start a new one while killing a defunt one"
  (interactive)
  (let ((is-term (string= "term-mode" major-mode))
        (is-running (term-check-proc (buffer-name)))
        (term-cmd "/bin/bash")
        (anon-term (get-buffer "*ansi-term*")))
    (if is-term
        (if is-running
            (if (string= "*ansi-term*" (buffer-name))
                (call-interactively 'rename-buffer)
              (if anon-term
                  (switch-to-buffer "*ansi-term*")
                (ansi-term term-cmd)))
          (kill-buffer (buffer-name))
          (ansi-term term-cmd))
      (if anon-term
          (if (term-check-proc "*ansi-term*")
              (switch-to-buffer "*ansi-term*")
            (kill-buffer "*ansi-term*")
            (ansi-term term-cmd))
        (ansi-term term-cmd)))))
(global-set-key (kbd "<f2>") 'visit-ansi-term)

TRAMP Integration

This is cool.

Put the following inside of your .bash_profile on any computer that you ssh into frequently:

#Emacs ansi-term directory tracking
# track directory, username, and cwd for remote logons
if [ $TERM = eterm-color ]; then
    function eterm-set-cwd {
        $@
        echo -e "\033AnSiTc" $(pwd)
    }
    
    # set hostname, user, and cwd
    function eterm-reset {
        echo -e "\033AnSiTu" $(whoami)
        echo -e "\033AnSiTc" $(pwd)
        echo -e "\033AnSiTh" $(hostname)
    }
    
    for temp in cd pushd popd; do
        alias $temp="eterm-set-cwd $temp"
    done
    
    # set hostname, user, and cwd now
    eterm-reset
fi

Now when you ssh into a machine from within ansi-term and open a file with C-x C-f you'll be loading a file via TRAMP from the current working directory on the remote machine. Amazingly cool.

Read and Post Comments

Ubuntu: coping with a height restricted display

December 10, 2008 at 01:06 PM | categories: linux | View Comments

I'm eagerly awaiting my new Samsung NC10 to be shipped from Amazon. It's a nice little netbook that I can use when traveling and when going to social occasions. I'm specifically buying this laptop because of its small size, but I know that one thing specifically will bother me: the screen resolution, at 1024x600 is wide enough for most tasks, but not very tall at all.

So while I'm waiting, I'm playing around with Ubuntu 8.10 inside a VirtualBox instance. I've got the window resized to 1024x600 and am playing around with different settings to make maximum use of the screen. Here are my tweaks:

Gnome Panel (the toolbar):

Open gconf-editor (Alt-F2 'gconf-editor') and navigate to apps -> panel -> toplevels -> top_panel_screen0 and change the following:

  • auto_hide: checked -- makes the main toolbar panel autohide
  • auto_hide_size: 0 -- makes the toolbar completely hide instead of leaving a few pixels visible
  • enable_animations: unchecked -- make the hiding/unhiding as fast as possible
  • hide_delay: 500 -- makes the toolbar stay on screen for half a second after using it
  • unhide_delay: 0 -- makes the toolbar immediately popup when your mouse goes to the very top (or bottom) of the screen

Gnome Terminal:

Open the default profile properties, right click in the window and click "Edit Current Profile"

  • Turn off the menu bar: on the General tab uncheck "Show menubar by default in new terminals"
  • Turn off the scrollbar: on the Scrolling tab select "Scrollbar is: Disabled"

Oversized windows:

Uncheck the following key in gconf-editor:

/apps/compiz/plugins/move/allscreens/options/constrain_y

Now you can Alt-left-click any window and drag it around even above the top of the screen.

Firefox:

  • Move the bookmarks bar up to the file menu bar and get rid of the bookmarks bar:
    • Right click on the Home button and click customize.
    • Your bookmarklets should now disappear and read "Bookmarks Toolbar items."
    • Drag "Bookmarks Toolbar items" along the right hand side of the File .. Edit .... Help menus.
    • Click "Done."
    • Right click on the now empty bookmarks toolbar and uncheck "Bookmarks Toolbar."
  • Get rid of the status bar: Go to View -> uncheck "Status Bar."
  • Install a theme that uses smaller buttons and text: I like Classic Compact.
  • Remember that Firefox has a nice fullscreen option : F11.
  • Check out Tree Style Tabs. It puts the tabs vertically on the left side of the browser and visually keeps track of what sites you were at that prompted you to open a new tab, all in a tree like fashion.

Here is the desktop with gnome panel completely hidden and one terminal with menu bar hidden (click to see native size):

Here is firefox maximised with two tabs open (click to see native size):

Here is firefox in fullscreen (click to see native size):

Firefox maximized with Tree Style Tabs:

Read and Post Comments

In Pursuit of the Aggressor

December 05, 2008 at 12:08 PM | categories: free state project, pissed off | View Comments

I've been feeling pretty good lately, I have a decent job, a wonderful wife, awesome friends, and a new-found purpose in life: liberty activism in New Hampshire. In a world as messed up as ours, its been a profound comfort to have found such peace and purpose. But I've also been a bit startled recently including having feelings of helplessness, distrust, and insecurity.

My truck got broken into.

I had just gotten home from work and not 10 minutes transpired before I heard a loud crash and some rustling outside. As I rushed out the door, I saw someone had broken the window of my truck and was diving inside to grab my video camera. Before I knew it, I was several blocks away from my house, running full speed 10 feet behind the guy who was also running like hell. I kept chasing him, never quite closing the gap between him and myself until I ran out of energy. He turned the corner and I followed a bit more slowly. Knowing he was hiding, I looked closely in the darkness for him and I finally saw the guy dash from his hiding spot and continue running away. I said a few more unkind words in his direction as he fled, but there was nothing more for me to do. Out of breath, dejected, and quite frustrated, I walked back home. Kellie was already outside at this point wondering what had happened, we assessed the damage and confirmed that he had destroyed the passenger side window of my truck and managed to steal my video camera.

My Landlord had already called the cops and they showed up about 10 minutes later. Since they were there anyway, I gave them my take on what happened, although I had never really gotten a good look at the guy. I really didn't have much hope that the police would ever do anything (and in an ideal world we wouldn't have such agents of force). Kellie left to do her own reconnaissance at the corner store and surprised me when she told me that she saw the same cops doing actual detective work, questioning the store manager. Although I'm almost sure that these same men have violated the rights of peaceful individuals before, and will most likely continue to do so in their roles as agents of the state, I'm glad that they take their jobs seriously enough to want to protect peace when they can.

I don't really leave anything that valuable in my truck. The camera is a somewhat cheap Samsung SC-MX10, I had it mounted to my dash with a Modifry camera mount (The mount got ripped out with the camera), this setup was supposed to record the cops if I ever got pulled over. Sadly, I never got to try that out. I'm sure that the way I had it mounted made it stand out as an easy target for a thief.

I called up my insurance rep as well as an auto glass shop and got things taken care of pretty quickly, the auto glass shop was even willing to drive out to my house the next day and repair it right there even while I went to work that day. I love how market competition makes this so easy.

In total, I'm out $200 for the camera, $25 for the mount, and $163.15 for the glass. Yea, $388 is kind of a lot. However I was much more irritated with the inconvenience of it all, as well as the knowledge that there are people right in my neighborhood that have no reservations in actively destroying their society. The reason I'm here in NH is to work towards creating a civil and voluntary society. Its one thing to disagree with my ideas, I'm used to that. Its quite another to find that you live in a community where some percentage of the people do the exact opposite; creating a society of violence and distrust.

I'm left with a renewed sense of the importance of security, including responsible firearms ownership and carrying whenever possible. I don't actually think that a gun would have been useful in this situation, especially after the incident was carried onto the open street at 12 mph, but knowing first hand that desperation has led people to such forceful actions, it makes me much more cautious.

Read and Post Comments

Is Ryan going to jail?

November 14, 2008 at 03:56 PM | categories: liberty rants, pissed off | View Comments

I've come to the realization that I will be going to jail in the near future. Not for hurting anyone, but because the oppressive and unconstitutional powers-that-be see me as an Enemy of the State and an affront to their illegitimate power.

Two friends of mine have recently been thrown in jail. Neither of them have harmed, had any intention of harming, nor even inconvenienced, anyone. Their "crimes" are for having "contempt" for the state-funded thugs that wish to bully them into compliance with their procedures. Their only "crime" is that they had some questions, questions that the state did not want to hear.

Lauren Canario, who was invited to the federal court building to retrieve her camera (that the feds stole from her), walked through a metal detector checkpoint at a time when the guards weren't looking. She was ordered to go back through the checkpoint and was subsequently arrested when she asked why she was required to do so. She'll be in federal prison for 30 days.

Ian Freeman, of Free Talk Live, today was arrested over a couch. You can read the backstory of his case where his tenants have an old couch in his yard that the city of Keene wants removed. Ian is very willing to remove the couch, but simply wants to talk to the person who made the original complaint. Instead of hiding behind the force of government, the original complainant should speak to Ian in a friendly, neighborly way just as civilized communities ought to behave.

Instead, Ian was compelled to go to court today. He went there having every intention of complying with the request to remove the couch. He has also made this very clear to the court on previous occasions. He simply wanted to demand that he be confronted by his accuser, as is his constitutional right. However, within 45 seconds of entering the court room, he was railroaded into being found in contempt of court and was immediately arrested. The court removed the public observers from the room and only allowed them to view Ian on camera (without audio) to monitor the proceedings. The judge found him guilty, despite not being shown his accuser, and he has been sentenced to three days in prison for the matter of the couch and 90 days for being in contempt of the court's proceedings.

The Keene city court has today shown that it is a court that does not recognize the right to be confronted with one's accusers, a court that does not recognize the right to have a public trial, and a court which has gone way beyond simply upholding the "rule of law". What country is this exactly?!? The Keene city court has decided that it has a personal vendetta against all local liberty activists. Accordingly, the prospect of me going to prison is a virtual forgone conclusion. I will refuse to back down from asserting my rights when the time comes. My line in the sand was crossed quite some time ago.

The state thinks it can quell liberty simply by flexing its muscles. On the contrary, an equal, and very much opposite reaction is about to occur.

Read and Post Comments

Why I'm not voting

November 04, 2008 at 11:47 AM | categories: free state project, liberty rants | View Comments

I've been a registered voter ever since I was 18 and a dues paying member of the Libertarian party for most of that time. I've always felt it was important to vote, especially according to ones conscience. I've always taken voting very seriously and have strived to always choose the best candidate -- the one who would do the least amount of harm -- the one who would stand up in defense of liberty.

Frequent visitors to this site will know that I have talked a lot about politics over the years. I've mentioned names of politicians that I've supported: Michael Badnarik, and Ron Paul. I've even dropped names of politicians I don't support: Mitt Romney. Recently I dropped out of the Libertarian party, but I remained sure that I could find a new political home, one that would respect my desires to have a principled approach to living in this democratic-republic of "ours".

Specifically, I wanted that new political home to be the Free State of New Hampshire.

New Hampshire has the most active group of liberty activists on the planet. There are a multitude of freedom oriented media, powerful voting blocs, as well as free market activists.

When I got here I wanted to get involved with everything. One problem the Free State has ... is that you can't do that. You HAVE to choose what you're going to do, simply because there is so much activism going on here that you cannot be in two places at the same time. The first thing I got involved with was the NH Liberty Alliance delivering literature on the most freedom friendly candidates running in NH. Being very disgruntled with the state of national politics, I sincerely wanted to get involved with NH local politics, believing that I could do two things:

  • Keep my principles of the non-initiation of force
  • Actually get people, that actually represent my desires, elected

This was a prospect that gave me immense hope. I wanted to come to NH and change things. Instead, NH changed me.

I began helping one of the NHLA endorsed candidates, Jason Bedrick, in his campaign for the state legislature. I asked him, will you sign the small government pledge? I thought this was a very reasonable thing for him to do, I had heard that NH was one of the freest states in the country and has the largest legislature in the country (meaning a low citizen to representative ratio) and that the NHLA was endorsing the best liberty-friendly candidates they could find, to top that off Jason Bedrick was the NHLA top pick with a rating of A++ on their scorecard. Certainly, I had to have been dealing with the most liberty friendly candidate in the country.

He would not sign the pledge. Instead he would continue to vote for increased taxes, albeit minimally, and that he would pledge to limit "the budget increase to inflation plus population growth." In other words, he could not find one single government program that he could cut in order to decrease the states budget. Later, I would find that Jason endorsed Mike Huckabee for president. Is this seriously the best that the NHLA could find?!? Helping Jason was the last political action I've taken in NH.

Instead, I have been involved with alternative forms of activism. I have been to the federal court in support of the peaceful civil disobedience of Kat Kanning and Lauren Canario who were both jailed for peacefully and silently protesting tax funded torture in an IRS office. I have engaged in civil disobedience of breaking curfew laws in Manchester city park. I have participated in open-carry litter pickups. I have sold hot dogs in violation of police orders to vacate a plot of land. I have supported a friend in peaceful protest and burning of the US Flag. Granted, none of this may seem like much, but I feel that I have been able to demonstrate my spirit of liberty with more people than I ever could by shoving junk mail in someones door or by voting.

But why am I not voting? Certainly it wouldn't take much of my time to go mark a check by someones name that could possibly make our society ever-so-slightly more free? Right?

I have been frustrated recently because I cannot find a candidate that I can support, but I didn't understand until very recently why it so hard for me to find such a candidate -- my principle that it is wrong to initiate force against another is antithetical to the very idea of voting. When I vote, I cannot vote for the lesser of evils; a lesser evil is still evil. Even from a purely defensive argument, I cannot vote for the person that will do less harm to me because that vote is seen as a mandate. It is an endorsement from me to the candidate that he should follow his preestablished platform, one that I vehemently oppose, but one that I ultimately voted for. It is a vicious cycle of buck passing. It's also not good enough that I vote for a candidate that actually will increase liberty. Sure, he may promise to decrease government, and he may actually accomplish it. But what about all that he fails to do? There may be a candidate that will abolish 15 different government agencies, but there is no candidate out there that will ever abolish them all. Even if there was, he surely would be unwilling to do it all at once. By voting, I am supporting, and ultimately condemning, everyone in this country to serve the state in the meantime. And here's the rub, while I want liberty, especially from government, I have no right to take what I consider oppression away from someone that actually wants that oppression.

What I have discovered is that it is actually impossible for someone to represent me. Therefore, it is my responsibility to assert my own liberty in my own life. I cannot rely on anyone else to fight for my liberty, nor even if I could, no democratically elected politician could ever do so without violating another persons rights. I pledge to pursue a life full of voluntary interactions with my fellow human beings, never forcing my view point on them, unless they agress against me first.

Ron Paul, you're an admirable man. I sent you hundreds of dollars in hopes that you would inspire this country towards the ideals of liberty. You did not fail me. However, I cannot vote for you ... and I won't.

Voting is the method for obtaining legal power to coerce others. --Robert LeFevre
Read and Post Comments

« Previous Page -- Next Page »