0

Suppose I have command like cd abc/def, So I want to create own command like 'a'.

If I run 'a' command it ,should run command cd abc/def

optiplex-3020:~$ a

So could it be possible and I want to use python as scripting language

  • Do you want to change the working dir in the parent process (the shell) from within your program? That's (generally) not possible. –  Nov 03 '18 at 10:15
  • 1
    @mrc02_kr this question may be a duplicate, but not of the one you're pointing to. –  Nov 03 '18 at 10:17

2 Answers2

2

cd is a built-in command and cannot be run by an external program, so you must use your shell:

alias a='cd abc/def'

If you want this to be permanent, put it in your ~/.bashrc or ~/.zshrc depending on your shell.

iBug
  • 3,508
0

You can just use aliases in linux it does exactly what you want. Other option is to create alias that points to the python script, but i see no point using python when you have it integrated in linux.

AsenM
  • 568