this post was submitted on 03 Nov 2023
39 points (100.0% liked)

Programming

13376 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

I accidentally discovered that both "cd ..." and "..." work, and moreover, I can add more dots to go back further! I'm using zsh on iTerm2 on macOS. I'm pretty sure this isn't a cd feature. Is this specific to zsh or iTerm2? Are there other cool features I just never knew existed??

I'm so excited about an extra dot right now.

you are viewing a single comment's thread
view the rest of the comments
[–] thelastknowngod@lemm.ee 3 points 1 year ago* (last edited 1 year ago)

I have a function called up. I do up X where X is the number of directories I want to go up.

up() {
  if [[ $# -eq 0 ]]; then
    cd ..
    return 0
  fi
  local path i
  for (( i=0; i < $1; i++ )); do
    path+=../
  done
  cd "$path"
}

EDIT: Don't know if it's just me but if you see < it should be the less than character.