4 ms·
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. "s
by nicbou 6y ago
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".
- banana_giraffe 6y agoFor 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.
- samstave 6y agoAlso, "notepad FILENAME" will open the file in notepad... etc.
- manjana 6y agoAlso, "vim FILENAME", where Vim is an alias set in $PROFILE that point to the vim executeable.
- RealStickman_ 6y agoNote that you don't have to specify an alias for it, if the vim executable is located in your $PATH.
- dgfitz 6y agoOh, I always used: explorer.exe . I didn't know open was aliased to that.
- banana_giraffe 6y agoFor 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)
- kergonath 6y ago> 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.
- jvinet 6y agoI 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 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 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.
- maweki 6y ago> 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.
- chrisshroba 6y agoA 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.
- Zutano 6y agoIf 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
- paxswill 6y agoNot 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`
- punnerud 6y agoI 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-command-line https://code-maven.com/display-notification-from-the-mac-com...
- nicbou 6y agoI stopped using "say" because it made me jump in my chair too many times.
- swiley 6y agoMost 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.)
- deleted 6y ago[deleted]
- justinlilly 6y agoThe linux (ubuntu?) version of `open .` is `xdg-open .`