Announcement

Collapse
No announcement yet.

alias - fails to refresh

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    alias - fails to refresh

    I use aliases and have done the following:

    1. modified .bashrc to look for the file .bash_aliases
    the following lines were uncommented from the original .bashrc script
    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    2. then I created the file .bash_aliases in my home directory.

    3. added several aliases such as
    alias wkend='cd $HOME/weekend'
    alias cpu='sudo cpufreq-selector -g performance'
    alias exch='cd $HOME/data/ID/mon/exch'


    PROBLEMS:
    1. when attempting to use the alias 'cpu' from the command line, I get the following message:
    nh@nh>cpu <enter>
    'You must be root'

    How can I use alias to execute the shortcut 'cpu'?

    2. when I change the 'exch' alias from the version cited above to the following:
    alias exch='cd ~/data/ID/mon'

    and save the change, why doesn't the revised alias work? In my case, changes to the .bash_aliases file don't seem to refresh.

    Is there a command that refreshes the .bashrc?
    Is there a command that refreshes alias?

    PS - On my system, there is no 'man alias'


    #2
    Re: alias - fails to refresh

    Originally posted by nhtrader
    1. when attempting to use the alias 'cpu' from the command line, I get the following message:
    nh@nh>cpu <enter>
    'You must be root'

    How can I use alias to execute the shortcut 'cpu'?
    sorry don't know this command.
    your alias seems to be set correctly.

    Originally posted by nhtrader
    2. when I change the 'exch' alias from the version cited above to the following:
    alias exch='cd ~/data/ID/mon'

    and save the change, why doesn't the revised alias work? In my case, changes to the .bash_aliases file don't seem to refresh.

    Is there a command that refreshes the .bashrc?
    Is there a command that refreshes alias?
    it's not that you have to refresh the .bashrc or the .bash_aliases.
    those are just...files.
    .bashrc is the "configuration file" for your bash command interpreter.
    so it's the bash itself that needs to be "refreshed".
    quickest/easiest way is to replace the current one with a new one:
    Code:
    exec bash
    Originally posted by nhtrader
    PS - On my system, there is no 'man alias'
    alias is a shell built-in command.
    it's the bash man page you're looking for.

    hth
    gnu/linux is not windoze

    Comment


      #3
      Re: alias - fails to refresh

      Jankushka, thanks for the reference to 'man bash' and for the command exec bash.

      As for the alias 'refresh' problem, I noticed that the system finally did refresh itself without any help from me. I was just surprised to learn that the updates to .bash_aliases weren't propagated immediately like other system files.

      I'm still wondering if there are other 'root' files that take precedent over user settings and if there are any undocumented hidden files that affect behavior like there are in X windows (such as .kde/share/config/displayconfigrc - when nvidia drivers are installed.)

      Hopefully, someone can explain the reason for the delay. I just want to make sure that this isn't a symptom of something more problematic. I don't know if this delay is normal or not.

      Comment


        #4
        Re: alias - fails to refresh

        After making changes to your .bash_alias file, you have to run (in a console) the following command:
        Code:
        source ~/.bash_aliases
        This 'reloads/refreshes' the file. I do this all the time.
        Windows no longer obstructs my view.
        Using Kubuntu Linux since March 23, 2007.
        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

        Comment


          #5
          Re: alias - fails to refresh

          no misteries.

          when a bash shell starts up it will source its configuration file(s).
          just like any applications.

          if it's a "login shell" it will look for:
          /etc/profile, ~/.bash_profile, ~/.bash_login, or ~/.profile
          and then it will look for:
          /etc/bash.bashrc first and ~/.bashrc

          if it's a normal (i.e. non login) shell it will look for:
          /etc/bash.bashrc first and ~/.bashrc

          if you change the configuration files, the currently running shells won't notice.

          you then have to tell a shell to re-source its configuration (as per snowhog suggestion)
          or start a new shell.

          hth

          ps:
          check the bash man page for exactly what files are source when.
          'cause i always get those mixed up.
          gnu/linux is not windoze

          Comment

          Working...
          X