I create saome variables to makea shotcut to some directories I go frequently (so, I then I type, e.g. cd $P_DIR). Of Course before that I put a valid value into P_DIR variabe.
Also, alias, as
alias cls=clear
So, I type cls, and is the same as the commando clear (but shorter)
What I want to do is that those variables as aliases stay in the computer when I reboot or turn off and turn on.
So, I put “somewhere” (this is the place(s) maybe one for variables, and other for aliases, turn of the computer, and when I turn on, the aliases and variables are still there.
Even better still, you use a text editor to enter those alias commands and variable assignments into a file that is read by bash when it is started up and they will be available when you run bash. One such file is .alias in your home directory (note the . in front). For example you put lines like:
alias h=history
export CVS_RSH=ssh
and so forth in it and next time you login or start a bash shell, they will be available.
PS: ~/.alias is not a file that’s documented as read by bash if you are wondering, but the default .bashrc (which is normally read by bash) on openSUSE has this line at the end:
What exactly did you do? Do you understand that you can’t “save” your current settings, but you write them down so that they are read in by each shell? So you have to put all the assignments you made into that file. Any new ones you make during a session are not “saved”.
You would have to dump the variable assignments to a file and then arrange to read them in again later. This is a scripting problem. There are no ready made commands for this because usually people put what they want to be “permanent” in .bashrc or .aliases and don’t want to carry over the assignments from a previous session. But the tools are there to do this.
There no such ready made scripts, you will have to write them. If you don’t know shell scripting, you will have to learn. Here are some hints:
The shell builtin command “set” will print out all variable and function assignments, and the output can be directed to a file. Similarly the command “alias” prints out all aliases. Those assignments can be read in again from a file with the “source” command. However you want to be selective with what you read in again. You could easily lock yourself out of the computer if you get your shell to automatically read everything in, including assignments that are mistakes.
On 12/01/2015 03:36 PM, speedytux wrote:
>
> You can test this.
> create a .alias file in your home directory
> add some aliases like
>
> Code:
> --------------------
> alias zy=“sudo zypper”
> --------------------
>
> then save and exit
>
> Code:
> --------------------
> chmod +x .alias
This step is not necessary just use:
… .alias
to have the file re-sourced.
–
Ken
linux since 1994
S.u.S.E./openSUSE since 1996