GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 08:58:29 JST Miakoda Miakoda

    I wish there was a command in Linux to make a directory and change to that directory in a single command and I have a sneaking suspicion that somebody will reply with said command that I should have known about already.

    In conversation about 8 months ago from pdx.social permalink
    • Embed this notice
      Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 09:18:34 JST Miakoda Miakoda
      in reply to
      • tuban_muzuru

      @tuban_muzuru Fuck yeah! Thank you! I'll try this rn.

      In conversation about 8 months ago permalink
    • Embed this notice
      tuban_muzuru (tuban_muzuru@beige.party)'s status on Sunday, 14-Dec-2025 09:18:35 JST tuban_muzuru tuban_muzuru
      in reply to

      @hellomiakoda

      edit your shell config file
      nano ~/.bashrc

      Add the following lines

      mkcd () {
      mkdir "$1" && cd "$1"
      }

      save the file and run source ~/.bashrc ( or the shell config file )

      Now you can

      mkcd new_project_folder

      In conversation about 8 months ago permalink
    • Embed this notice
      Khalid ⚡ (khalidabuhakmeh@mastodon.social)'s status on Sunday, 14-Dec-2025 09:19:05 JST Khalid ⚡ Khalid ⚡
      in reply to

      @hellomiakoda the command is "take" in zsh

      In conversation about 8 months ago permalink
    • Embed this notice
      Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 09:19:05 JST Miakoda Miakoda
      in reply to
      • Khalid ⚡

      @khalidabuhakmeh like
      $ take Folder\ Name
      ?

      In conversation about 8 months ago permalink
    • Embed this notice
      Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 09:24:19 JST Miakoda Miakoda
      in reply to
      • tuban_muzuru

      @tuban_muzuru Works precisely how I wanted. Thank you!

      In conversation about 8 months ago permalink
    • Embed this notice
      Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 10:20:35 JST Miakoda Miakoda
      in reply to
      • tuban_muzuru

      @tuban_muzuru Does $1 work the same in an alias? Cause if it does... that's the missing piece to some aliases I've been wanting to do.

      In conversation about 8 months ago permalink
    • Embed this notice
      tuban_muzuru (tuban_muzuru@beige.party)'s status on Sunday, 14-Dec-2025 10:20:38 JST tuban_muzuru tuban_muzuru
      in reply to

      @hellomiakoda

      y/w . Linux people are wired up to help others. Comes with the territory, heh.

      In conversation about 8 months ago permalink
    • Embed this notice
      Miakoda (hellomiakoda@pdx.social)'s status on Sunday, 14-Dec-2025 15:11:11 JST Miakoda Miakoda
      in reply to
      • tuban_muzuru

      @tuban_muzuru So... that could that be used to hold the big string of yt-dlp options I use, so I could like yt-dlp-low $1
      with $1 being the URL?

      In conversation about 8 months ago permalink
    • Embed this notice
      tuban_muzuru (tuban_muzuru@beige.party)'s status on Sunday, 14-Dec-2025 15:11:12 JST tuban_muzuru tuban_muzuru
      in reply to

      @hellomiakoda

      For standard shell aliases in Bash and Zsh (which are the most common shells), the short answer is No, $1 does not work as you might expect.

      The positional parameters like $1 (for the first argument), $2, etc., and $@ (for all arguments) are typically expanded when the alias is defined, not when you use it. When you define an alias like alias foo='bar $1', the shell substitutes $1 right away. Since you're not passing arguments when you define the alias, $1 usually expands to nothing.

      The recommended and reliable way to create a shortcut that takes arguments is to define a shell function. Functions are simple to write and are handled correctly by the shell when you execute them, allowing you to use $1, $2, and $@ just like in a script.

      Example Function (Bash/Zsh)Let's say you want to create a command mkcd that makes a directory and then immediately changes into it, and it needs the directory name as an argument.

      Instead of trying this (which won't work):
      alias mkcd='mkdir -p $1 && cd $1'

      Do this instead (which works):
      mkcd() { mkdir -p "$1" && cd "$1"; }

      P.S. : there is the concept of an anonymous function in bash, but it is bullshit. Use a proper function.

      In conversation about 8 months ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.