Trying to get colored output with ls on openBSD 6.4
Hello,
I have openBSD 6.4 installed on a VM which I've been using in an attempt to learn how to get file shares running on openBSD. Quite frankly, I've taken for granted how colors pertaining to file type when ls is invoked or having aliases for lengthy commands is done in Linux. In an attempt to get the same thing on openBSD, I went ahead and installed bash on my system. I also changed my default shell to bash. I can only confirm this as whenever I logon now, I get bash instead openBSD's default. When I echo $SHELL, I get the following path: /usr/local/bin/bash When I echo $BASH_VERSION, I get 4.4.23(1)-Release Under my home directory, I find the following files & folders: Code:
.Xdefaults I've tried to see if there was a bashrc file anywhere but I don't know if that's the right file I should be editing now. I read somewhere that I could get what I'm asking for from other files, such as .bash_profile or even .profile. I honestly don't know where to look at this point as I'm pretty new to BSD in general and I've never had to do this before on a Linux host. Could I get some assistance? TIA EDIT: I'm trying to get colors to function under the terminal (by that, I mean I want colored output). I already see color in instances where man is invoked and a man page is displayed. What I would like next is to see the colors I normally see when I invoke ls. On all Linux machines I've used in the past, I was able to run ls and the color scheme would be generated automatically. I don't know how to enable that same feature with ls on openBSD. I'm looking to achieve that, and my guess is to edit some config file, but I don't know if that's true. EDIT #2: This is all being done on an openBSD guest machine run via virtualbox. I am not trying to get this on a Linux machine 'cause I don't have to. |
The files you mention (.bash_profile, .profile, you can add .bsh_aliases and .bashrc) are optional and generally written by the user.
Try this command to know more: man bash Aldo, you could read http://tldp.org/LDP/Bash-Beginners-G...ers-Guide.html (old, but mostly still valid). |
Quote:
They are normally set by a program 'dircolors', which in _MY_ system is invoked by a script in the /etc/profile.d directory (all of the .sh scripts in that directory are executed by /etc/profile), but you can create your own /etc/profile.d/dircolors.sh (or any other name with the .sh extension) to set those variables AND create aliases for 'ls' with the $LS_OPTIONS added/ Again, mine is: Code:
/bin/ls --color=auto -T 0 |
That Random Guy, what is the problem?
i cannot make out a clear question in your op. |
Quote:
Install the coreutils package and you will be able to use the GNU ls ( gls(1) ) which supports this feature. Refer to the man page. You can then alias it as your ls(1) command. Quote:
|
Quote:
http://mywiki.wooledge.org/DotFiles?...=%28profile%29 Quite some linux distributions come with a lot of configurations out of box, debian even autocreates .profile and .bashrc (also very complex ones) in the users home directory. I sometimes copy them to distros or OS'es where i ain't got them. In general i think you are asking about what ehartman said. As cynwulf said you can't expect a different flavor of commands, though with the same name, to always work the exact same way (in this case the command "ls"). Always make sure the according manpage confirms what you know from Gnu/Linux. Though it really ain't that clear what exactly your problem is (as ondoho said too). |
LS colors
Quote:
I initially also needed help with aliases but after playing with the .profile file, I was able to get that going. I edited my OP so that others understand better as well. It was kind of vague. |
Yep
Quote:
|
Yikes!
Quote:
|
Quote:
As I've said above, you will need to install coreutils from ports and use the GNU gls(1) command to get the colorised output (just tested and works). |
Yep
Quote:
I was able to get an alias going for gls, but it doesn't seem to be working (i.e. colored output; the command does run). I'm thinking there's something else I haven't configured right, which would explain why even colorls wasn't showing colors when invoked. I'll have to investigate some more. :study: |
It worked here. Can you post the exact alias you used?
|
!
Quote:
Code:
PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:. According to the man page, it's assumed to leave color on always by default. So, I tried without the color option and also setting it to always. Incidentally, I'm running this machine as a guest on Virtualbox. I don't know if that would have anything to do with it, though. |
Quote:
Code:
alias ls='gls --color=auto' color=auto means: use color on an interactive terminal but NOT when ls is used within a script, crontab etc as the colors may disturb further processing (like in a ls|grep pipe). See the man page of the GNU version of ls about using colors. Note that displaying colors is DISabled by default so you do need to use the --colors option (with a value other then 'never'). |
Got it
Quote:
It turns out my TERM variable wasn't one that supported colorization as prescribed in the dircolors man page. After changing that, and running gdircolors -b (and editing my profile), I've now received colored output when invoking ls. What I need to figure out now is how to make the TERM change permanent. So far, I've only been able to do that via export TERM=vt100. In any case, I'm marking this thread as solved. |
All times are GMT -5. The time now is 03:02 PM. |