help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Preferred method wrapping mkdir


From: Joseph Pesco
Subject: [Help-bash] Preferred method wrapping mkdir
Date: Fri, 13 Nov 2015 08:55:17 -0800

Hello;

I've developed a passion for wrapping mkdir up in a utility function.
Is there a reason for not using either of the following two methods to
do it?  Is there a better method I've not thought of?

1.  Completely in .bashrc or some scripted sourced from .bashrc:

        alias mkdir=cfs_mkdir
        
        cfs_mkdir () {

                local MKDIR=/usr/bin/mkdir
                $MKDIR “$1”
                cd “$1”
        }

2. In a script in ~/bin that requires the following alias in .bashrc
   `alias mkdir=cfs_mkdir.sh'

        #!/bin/bash
        # Name: cfs_mkdir.sh

        script_function () {
                local MKDIR=/usr/bin/mkdir
                $MKDIR "$1"
                cd "$1"
         }

        script_function "$@"

Pleae note that cd and cp perfect candidates for the same treatment!

Thanks in advance!
Joe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]