Announcement

Collapse
No announcement yet.

Can I assign an alias to a environment variable?

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

    [SOLVED] Can I assign an alias to a environment variable?

    I have discovered the simplicity of the command line for rotating my monitors. It' s a lot faster than going through the GUI. BUT...

    I hate typing out the monitor names, e.g. "DP-2-3"

    Is there a safe way to assign an alias to that environment variable?

    Could I safely do something like

    Code:
    mon2=$DP-2-3
    maybe in .bashrc or .bash_profile?

    This is one of those areas where I have just enough understanding to get myself into a fix, which I'd rather avoid.

    #2
    Yes, there's many ways to do this.

    I would just define aliases for the complete commands, f. ex.
    Code:
    alias d2='foo dp-2'
    but if you really want to use an environment variable, say BAR,
    Code:
    alias d2='foo $BAR'
    the file .bash_aliases is the conventional place; it gets sourced by .bashrc by default, if it exists.
    Regards, John Little

    Comment


      #3
      Thanks for the idea jlittle!

      Turns out it doesn't work if you put the "$" in.

      This is what I ended up doing:

      in .bash_aliases
      Code:
      #Samsung 23"
      alias mon2="xrandr --output DP-2-2 --rotate"
      
      #HP 19"
      alias mon3="xrandr --output DP-2-3 --rotate"
      now rotate my display in terminal

      Code:
      mon3 normal
      or

      Code:
      mon3 left

      Comment

      Working...
      X