
Show HN: Teleport: Simple command line app tutorial written in Haskell - bollu
http://bollu.github.io/teleport/
======
harel
Very nice. I use a set of bash functions to do the same thing, with tab-
autocompletion (not my own development, I picked it up from the web somewhere
long ago). Put this in your .bashrc:

    
    
        # mark/jump support + completion
        # un/mark name : bookmark a directory or remove one (unmark)
        # jump name : jump to directory
        # marks : show all bookmarks
        export MARKPATH=$HOME/.marks
        function jump {
            cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
        }
        function mark {
            mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
        }
        function unmark {
            rm -i $MARKPATH/$1
        }
        function marks {
            ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
        }
        _completemarks() {
          local curw=${COMP_WORDS[COMP_CWORD]}
          local wordlist=$(find $MARKPATH -type l -printf "%f\n")
          COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
          return 0
        }
    
        complete -F _completemarks jump unmark

~~~
ihowlatthemoon
This is brilliant. Added immediately. It's something I never realized I needed
until I found out about it. Thank you.

~~~
harel
That's exactly what I said when i found out about it. Its just one of those
things....

------
jastanton
A trick I commonly use is:

    
    
        cd -
    

Which goes back to the previous directly I was just on. They have the same
thing for git as well:

    
    
        git checkout -
    
    

it's quite handy for switching back and forth between branches or directories!

~~~
gbersac
Thanks for gi checkout -. I am currently using git checkout @{-1} which does
the same thing...in a more verbose way.

~~~
epidemian
I recently learned that this trick also works with merge. `git merge -` merges
the last branch you were on onto the current one. So far i've found it very
useful :)

------
iamdave
What's the advantage of this over pushd/popd?

~~~
mbel
I think the point of the linked page is to show how to implement a command
line app in Haskell. Teleport is just an example, as such it doesn't really
have to be a great tool for everyday usage.

On the other hand, teleport seems to actually provide a much better UX than
pushd/popd:

1\. it's a hash-table not a stack (directories are named), so it allows random
access to memorized directories.

2\. it is possible to display the current state.

3\. remembered directories are persistent between shell sessions.

~~~
taeric
Naming directories seems like an odd choice. Sounds like aliases?

Regardless, pushd/popd/dirs is a tough experience. Seems capable of a lot, but
I only use it for bouncing between two directories, typically.

The tool I like, but can't remember the name of is basically 'cd
${PWD:src/tst}'. Only, a little more terse.

Haven't used it in a while either, since I've primarily switched to eshell.

~~~
iamdave
_Naming directories seems like an odd choice. Sounds like aliases?_

I definitely use aliases for multiple frequently accessed directories.

`kdev` takes me to my work dev folder, `wpdev` takes me to my wordpress
folder, etc.

But I definitely see the points parent comment to yours made.

~~~
taeric
Yeah, I was not intending my post as a counter. Just more discussion.

------
LeanderK
i am not yet convinced on literate Haskell besides tutorials. It makes the
source-code hard to read and understand, too much noise for this little amount
of source-code.

------
andrewfromx
I can do this with aliases in .bash_profile right?

~~~
mbel
Of course you can. Inside .bashrc you have access to aliases (a facility to
name things) and to a Touring-complete programming language (a tool to make
things). There is little you can't do in .bashrc

~~~
andrewfromx
right so why do I need teleport?

~~~
bollu
because 1\. it's a nicer UI that does the same thing.

2\. the goal of the tool was to be minimal, useful, and a way to show off
Haskell's ability to be able to write real world code that beginners can
understand.

3\. (personal opinion) Haskell is way more maintainable than bash is, any day
of the week.

------
andrewfromx
also your prompt with "Name's MacBook Pro" is way too long. Shorter that
thing!

------
imaginenore
You might want to reconsider the name. There's already software named
Teleport.

[http://www.tenmax.com/teleport/pro/home.htm](http://www.tenmax.com/teleport/pro/home.htm)

~~~
ullarah
The product you linked is called 'Teleport Pro' which allows you to do website
mirroring for offline browsing.

The link that has been originally posted is a CLI based tool which has nothing
to do with website mirroring.

~~~
imaginenore
That's not how copyright / trademarks work. Try and name your software
Photoshop Kids or Photoshop Palette. Adobe's lawyers will rip you a new one
quite quickly if you attempt to tell them "it has nothing to do with editing
images".

~~~
mikekchar
Intellectual property law is complex and trying to sum it up in a sentence or
two is going to give people the wrong impression. However, as much as I'm not
a lawyer, I will try to help you dispel a few notions.

First, this is a clearly a trademark issue, not a copyright issue. You can't
copyright a name. In fact there are many, many, many things that you can't
copyright. It often happens that people conflate the 3 main areas of
intellectual property law: copyright, trademarks and patents, but it is quite
important that you distinguish between them precisely.

WRT to trademarks, having a similar name is not enough to cause a trademark
infringement. It also needs to create confusion in the marketplace. In this
case, a tutorial on how to make a command line Haskell app and some kind of
web service is really unlikely to cause any confusion.

The problem with trademarks is that, unlike copyright, if you have a trademark
you have to defend it or lose it. So if you sue someone over a trademark
infringement, the other side can say, "Well, they didn't say anything about
this other guy doing the same thing even though they knew about it". This can
cause you to lose the trademark.

Because of this, many lawyers err on the side of caution and send out spammy
"You are infringing on our trademark" notices to everyone. If you send a quick
note back saying, "I don't think there is any possibility of confusion in the
market place" (such as this situation), the lawyers will often back off --
unless they truly believe that there is a problem.

Clearly your advice of trying to avoid trademark infringement is good advice.
In this case, though, here is pretty clearly no infringement, so it's
misplaced. In the very unlikely even that a lawyer asks about it, replying
back with the response, "There is no chance for confusion in the market place"
will likely be enough (Note: this is not legal advice, and I am not a lawyer).

Interesting side track: The World Wrestling Federation (WWF) became World
Wrestling Enterprises (WWE) due to a trademark dispute with the World Wildlife
Foundation (WWF). You could reasonably think that there is no way of confusion
in the market place, but the World Wildlife Foundation showed that people were
hesitant to contribute to them because they actually thought that they were
associated with the World Wrestling Federation. That is the key issue, not
just the similarity in the name.

