you are viewing a single comment's thread
view the rest of the comments
[–] 6 points 10 months ago (2 children)

Maybe "alias u=cd .." or "alias mkcd=mkdir -p $1 && cd $1"

  • source
  • hideshow 2 child comments
  • [–] 2 points 10 months ago

    I like mkcd! I have the same thing. Although what I use more is a function I pair with it that specifically creates a temporary directory, and cds to it. It's useful for temporary work, like extracting from a zip file.

    These are my Nushell implementations:

    # Create a directory, and immediately cd into it.
    # The --env flag propagates the PWD environment variable to the caller, which is
    # necessary to make the directory change stick.
    def --env dir [dirname: string] {
      mkdir $dirname
      cd $dirname
    }
    
    # Create a temporary directory, and cd into it.
    def --env tmp [
      dirname?: string # the name of the directory - if omitted the directory is named randomly
    ] {
      if ($dirname != null) {
        dir $"/tmp/($dirname)"
      } else {
        cd (mktemp -d)
      }
    }
    
  • source
  • parent