Thursday, 24 February 2022

Re: Bash Command "mkcd"

Hello all,
 
maybe can defining by a simple bash function and things get easier.
 
add .bashrc
 
function mkcd () {
     mkdir "$1" && cd "$1"
 }
 
$ source /home/user/.bashrc
$ mkcd test
$ pwd
/home/user/test
 
and please read:
Happy Hacking!
 
Ozgur
 
24.02.2022, 18:32, "Oliver Rath" <rath@mglug.de>:

Hi Pixi,

Am 23.02.22 um 15:39 schrieb Pixelbog Pixi:
Dear Ubuntu-Team,
 
I have a question:
Is it possible to add the command ​mkcd​?
It stands for make & change directory and I think it will be super usefull.
 
It happened already way too often that I typed "mk foo && cd foo" and
with mkcd it will save 8 keystrokes for the example "foo".

The most easy way for you is function in you .bashrc (in the homedir)

Just include

mkcd() {
    #do things with parameters like $1 such as
    make $1          
    cd $1        
}
 

Then you can use this command.

Hth!

Oliver

 

,--
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel