Scripts I wrote that I use all the time
321–330 of 408 posts
Re: Scripts I wrote that I use all the time
#322I 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 ../../../../../..'
# 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
endRe: Scripts I wrote that I use all the time
#323My 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.
Re: Scripts I wrote that I use all the time
#324My 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.
Re: Scripts I wrote that I use all the time
#325Re: Scripts I wrote that I use all the time
#326Earlier 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 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
#327Re: Scripts I wrote that I use all the time
#328Earlier 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.
Re: Scripts I wrote that I use all the time
#329It'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 :))
- 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
#330It'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.