Live data from Hacker News

Scripts I wrote that I use all the time

evanhahn.com

321–330 of 408 posts

Re: Scripts I wrote that I use all the time

#322
post #55

I have a bunch of little scripts and aliases I've written over the years, but none are used more than these... alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' alias .......='cd ../../../../../..'

In fish, I have an abbreviation that automatically expands double dots into ../ so that you can just spam double dots and visually see how far you're going.

  # Modified from
  # https://github.com/fish-shell/fish-shell/issues/1891#issuecomment-451961517
  function append-slash-to-double-dot -d 'expand .. to ../'
   # Get commandline up to cursor
   set -l cmd (commandline --cut-at-cursor)
  
   # Match last line
   switch $cmd[-1]
   case '*.'
    commandline --insert './'
   case '*'
    commandline --insert '.'
   end
  end

Re: Scripts I wrote that I use all the time

#323

My fav script to unpack anything, found a few years ago somewhere # ex - archive extractor # usage: ex function ex() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' can…

`tar xf` autodetects compressed files now. You can replace any of your instances of tar with that.

Honestly, it doesn't need any updates, it works so great without any pain, I'm just happy with it

Re: Scripts I wrote that I use all the time

#324

My fav script to unpack anything, found a few years ago somewhere # ex - archive extractor # usage: ex function ex() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' can…

That's brilliant. Now I need its compressing counterpart.

For compression, I have one for .tar.gz. But it's not that popular in my system. I need something a bit easier than 'pack file file file archive.tar.gz'

Re: Scripts I wrote that I use all the time

#326

Earlier quoted context omitted.

Yes, flagging mechanism on HN is evil.

I have showdead on, and almost every single flagged post I've seen definitely deserves it. Every time it wasn't "deserved", the person simply took an overly aggressive tone for no real reason. In short, I've never seen somebody flagged simply for having the wrong opinion. Even controversial opinions tend to stay unflagged, unless they're incredibly dangerous or unhinged.

I've seen a few dead posts where there was an innocent misunderstanding or wrong assumption. In those cases it would have been beneficial to keep the post visible and post a response, so that readers with similarly mistaken assumptions could have seen a correction. Small minority of dead posts though. They can be vouched for actually but of course this is unlikely to happen.

I agree that most dead posts would be a distraction and good to have been kept out.

Re: Scripts I wrote that I use all the time

#328
post #237

Earlier quoted context omitted.

It's interesting because there's a significant chance one wastes more time tinkering around with custom scripts than saving in the long run. See https://xkcd.com/1205/ For example. The "saves 5 seconds task that I do once a month" from the blog post. Hopefully the author did not spend more than 5 minutes writing said script and maintaining it, or they're losing time in the long run.

One thing which is often ignored in these discussions is the experience you gain. The time you “wasted” on your previous scripts by taking longer to write them compounds in time saved in the future because you can now write more complex tasks faster.

The problem is, to really internalize that benefit, one would need to have an open mind to trying things out, and many folks seem to resist that. Oh well, more brain connections for me I suppose.

Re: Scripts I wrote that I use all the time

#329

It's weird how the circle of life progresses for a developer or whatever. - When I was a fresh engineer I used a pretty vanilla shell environment - When I got a year or two of experience, I wrote tons of scripts and bash aliases and had a 1k+ line .bashrc the same as OP - Now, as a more tenured engineer (15 years of experience), I basically just want a vanilla shell with zero distractions, aliases or scripts and use…

I am going through a phase of working with younger engineers who have many dotfiles, and I just think "Oh, yeh, I remember having lots of dotfiles. What a hassle that was." Nowadays I just try to be quite selective with my tooling and learn to change with it - "like water", so to speak. (I say this with no shade to those who like maintaining their dotfiles - it takes all sorts :))

I've been programming 30 years and I really don't find it a hassle:

- if you commit them to git, they last your entire career

- improving your setup is basically compound interest

- with a new laptop, my setup script might cause me 15 minutes of fixing a few things

- the more you do it, the less any individual hassle becomes, and the easier it looks to make changes – no more "i don't have time" mindset

Re: Scripts I wrote that I use all the time

#330

It's weird how the circle of life progresses for a developer or whatever. - When I was a fresh engineer I used a pretty vanilla shell environment - When I got a year or two of experience, I wrote tons of scripts and bash aliases and had a 1k+ line .bashrc the same as OP - Now, as a more tenured engineer (15 years of experience), I basically just want a vanilla shell with zero distractions, aliases or scripts and use…

I can't say I relate at all (5 years of experience). They'll have to pry my 1000-line .zshrc from my cold, dead hands. For example, zsh-autosuggestions improves my quality of life so ridiculously much it's not even funny.

[deleted]
Post reply on HN