Hacker News new | past | comments | ask | show | jobs | submit login

Great post idea!

"python3 -m http.server" is really useful when building simple JavaScript pages, or when you need a simple static file server for testing.

"ss -p" is great, but if you just want to see what's hogging your bandwidth, iftop and nethogs are much better.

My favourite one-liner is "open .", to open the current directory in Finder. The open command can also open URLs and other files.

I also have an alias for "osascript -e 'display notification "'"$1"'"'", which will display the text you choose in a MacOS notification. It's useful when you need to be notified at the end of a long-running task. "printf '\a'" is also useful if you need the terminal to "ding".




For those that don't know "start ." is the Windows version of "open .", opening Explorer in the current folder.

Speaking of Windows, "pushd \\servername\sharename" is a simple way to mount a share in Windows, if you have the login creds cached, and set the new drive letter as your active drive. Useful if you need to bounce around a bunch of shares.


Oh, I always used: explorer.exe . I didn't know open was aliased to that.


For what it's worth:

It's not "start" is an alias to "explorer", it's that "start" runs the args through "ShellExecute".

I mention this only because it has some other uses. For instance, Windows apps can install run handlers so that something like Start->Run->Excel will launch Excel. Just running "excel" on a command prompt won't work, but "start excel" will work, since that kicks off the right path.

You can also use something like "start /w filename.txt" to start an instance of your editor, and wait for it to close (well, mostly, some apps do weird things and break this)


Also, "notepad FILENAME" will open the file in notepad... etc.


Also, "vim FILENAME", where Vim is an alias set in $PROFILE that point to the vim executeable.


Note that you don't have to specify an alias for it, if the vim executable is located in your $PATH.


> My favourite one-liner is "open .", to open the current directory in Finder.

For linux one can use `xdg-open .` to use the associated application. Works with pdf, image files, videos, etc.

I have the alias x=xdg-open in my .bashrc, so that I use `x somefile` to open files.


Thank you, thank you, thank you! "open ." is post-it note worthy.


Also «open somefile.txt» can open, well, any file or directory, just as if you double clicked it. It works on multiple files, too. And possibly URLs, but I don’t have a mac anymore to check.


A slightly upgraded bash/zsh function for displaying a notification:

  noti() {
    osascript -e \
      'on run argv
        display notification (item 1 of argv) with title "Notification"
       end run' \
      $1
  }

  # Example:
  noti 'Hello world!'
This fixes any escaping issues by passing the notification string to osascript as an argument instead of embedding it in the text of the program (which makes things like quotation marks not work correctly).

Sticking it in your .bashrc or .zshrc will make it available at any time in your shell.


I often like alert better (osascript -e 'display alert "'"$1"'"'"), this way the message don't go away before you click ok.

Can also combine with a vocal message: sleep 2; osascript -e 'say "Hello World!"'; osascript -e 'display alert "hello world"'

The last one copied from https://code-maven.com/display-notification-from-the-mac-com...


I stopped using "say" because it made me jump in my chair too many times.


Most Linux based OSes will probably have busybox installed which includes its own web server. This can be nice if you don't have python (or if you think its overkill.)


Not a one-liner by itself, but sticking pbcopy/pbpaste into a pipeline is great for quick text processing. Wish you had regency support in a text field? `pbpaste | sed s/needle/NEEDLE/g | pbcopy`


> I also have an alias for "osascript -e 'display notification "'"$1"'"'", which will display the text you choose in a MacOS notification

This one is great. Very, very useful.


I use something similar, but it leans on at(1) to popup reminders at predefined intervals. I tend to forget things once I'm buried in my Vim window.

https://github.com/jvinet/dotfiles/blob/master/bin/rin

Examples:

  $ rin +30 Check the turkey
  $ rin '14:30 tomorrow' Watch baseball
I currently have it setup so it pops up a modal dialog using Zenity. As well, it uses my cheap-and-cheerful bespoke notification doohickey that I have running in waybar, another script called notify: https://github.com/jvinet/dotfiles/blob/master/bin/notify

This way, I have a nagging badge/icon in my waybar system tray until I finally do check that turkey and watch that baseball.


If you use WSL, you can get the same functionality as "open ." with

  explorer.exe $(wslpath -w "$PWD")
It's a bit lengthy so this is always aliased in my .bashrc when using WSL


explorer.exe . Has always worked for me from inside wsl


It might not be on PATH, so I have an alias and use "open":

   alias open="/mnt/c/Windows/explorer.exe"
Edit: Added formatting


The linux (ubuntu?) version of `open .` is `xdg-open .`




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: