Show user in vim status line2019 Community Moderator ElectionHow to replace a character by a newline in Vim?Duplicate a whole line in VimHow do I move to end of line in Vim?Indent multiple lines quickly in viVim clear last search highlightingWhat is your most productive shortcut with Vim?What's a quick way to comment/uncomment lines in Vim?How to do case insensitive search in VimHow does the vim “write with sudo” trick work?How to exit the Vim editor?

How do I hide Chekhov's Gun?

"of which" is correct here?

Happy pi day, everyone!

How do I change two letters closest to a string and one letter immediately after a string using Notepad++?

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

Tikz picture of two mathematical functions

Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?

PTIJ: Who should I vote for? (21st Knesset Edition)

I am confused as to how the inverse of a certain function is found.

Why no Iridium-level flares from other satellites?

Can I use USB data pins as power source

Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible

Counting models satisfying a boolean formula

Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)

What options are left, if Britain cannot decide?

What is a ^ b and (a & b) << 1?

How to make healing in an exploration game interesting

Meme-controlled people

Shortcut for setting origin to vertex

A diagram about partial derivatives of f(x,y)

How to pronounce "I ♥ Huckabees"?

New passport but visa is in old (lost) passport

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?



Show user in vim status line



2019 Community Moderator ElectionHow to replace a character by a newline in Vim?Duplicate a whole line in VimHow do I move to end of line in Vim?Indent multiple lines quickly in viVim clear last search highlightingWhat is your most productive shortcut with Vim?What's a quick way to comment/uncomment lines in Vim?How to do case insensitive search in VimHow does the vim “write with sudo” trick work?How to exit the Vim editor?










0















I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc



" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file


Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.



The ability to have one user (production server) in red would be a great plus :D










share|improve this question



















  • 1





    set statusline+=%$USER

    – phd
    Mar 7 at 16:11















0















I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc



" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file


Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.



The ability to have one user (production server) in red would be a great plus :D










share|improve this question



















  • 1





    set statusline+=%$USER

    – phd
    Mar 7 at 16:11













0












0








0








I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc



" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file


Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.



The ability to have one user (production server) in red would be a great plus :D










share|improve this question
















I already have set in vim a permanent status line which is quite nice, with the following config in my .vimrc



" Status line config
set statusline=
set statusline+=%< " cut at start
set statusline+=%2*[%n%H%M%R%W]%* " flags and buf no
set statusline+=%-40f " path
set statusline+=%=%1*%y%*%* " file type
set statusline+=%10((%l,%c)%) " line and column
set statusline+=%P " percentage of file


Now, as I often switch from testing to production environments, I'd like vim to show the current user, as set up by ISPconfig, in the status line.



The ability to have one user (production server) in red would be a great plus :D







vim server gnu-screen






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 15:52







Joel.O

















asked Mar 7 at 15:13









Joel.OJoel.O

7772921




7772921







  • 1





    set statusline+=%$USER

    – phd
    Mar 7 at 16:11












  • 1





    set statusline+=%$USER

    – phd
    Mar 7 at 16:11







1




1





set statusline+=%$USER

– phd
Mar 7 at 16:11





set statusline+=%$USER

– phd
Mar 7 at 16:11












1 Answer
1






active

oldest

votes


















0














OK, I spent some time learning vimscript as it is well worth it :)



So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".



"" Functions 
function! Prodcolor()
if $USER == "prod"
set statusline+=%#error#
endif
endfunction

" Status line config
set statusline=
call Prodcolor() " Give the error color if `$USER` is "prod"
set statusline+=%$USER " Paste the current vim user
set statusline+=%* " Revert color to normal


To have it applied immediately in your current vim session, in vim type :so .vimrc






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047098%2fshow-user-in-vim-status-line%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    OK, I spent some time learning vimscript as it is well worth it :)



    So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".



    "" Functions 
    function! Prodcolor()
    if $USER == "prod"
    set statusline+=%#error#
    endif
    endfunction

    " Status line config
    set statusline=
    call Prodcolor() " Give the error color if `$USER` is "prod"
    set statusline+=%$USER " Paste the current vim user
    set statusline+=%* " Revert color to normal


    To have it applied immediately in your current vim session, in vim type :so .vimrc






    share|improve this answer



























      0














      OK, I spent some time learning vimscript as it is well worth it :)



      So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".



      "" Functions 
      function! Prodcolor()
      if $USER == "prod"
      set statusline+=%#error#
      endif
      endfunction

      " Status line config
      set statusline=
      call Prodcolor() " Give the error color if `$USER` is "prod"
      set statusline+=%$USER " Paste the current vim user
      set statusline+=%* " Revert color to normal


      To have it applied immediately in your current vim session, in vim type :so .vimrc






      share|improve this answer

























        0












        0








        0







        OK, I spent some time learning vimscript as it is well worth it :)



        So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".



        "" Functions 
        function! Prodcolor()
        if $USER == "prod"
        set statusline+=%#error#
        endif
        endfunction

        " Status line config
        set statusline=
        call Prodcolor() " Give the error color if `$USER` is "prod"
        set statusline+=%$USER " Paste the current vim user
        set statusline+=%* " Revert color to normal


        To have it applied immediately in your current vim session, in vim type :so .vimrc






        share|improve this answer













        OK, I spent some time learning vimscript as it is well worth it :)



        So there's the relevant part to add in .vimrc in order to print the $USER variable in the status line and to color it to red (using the error system color) if the user has the value "prod".



        "" Functions 
        function! Prodcolor()
        if $USER == "prod"
        set statusline+=%#error#
        endif
        endfunction

        " Status line config
        set statusline=
        call Prodcolor() " Give the error color if `$USER` is "prod"
        set statusline+=%$USER " Paste the current vim user
        set statusline+=%* " Revert color to normal


        To have it applied immediately in your current vim session, in vim type :so .vimrc







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 19:10









        Joel.OJoel.O

        7772921




        7772921





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047098%2fshow-user-in-vim-status-line%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229