LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Terminal colours and locale (https://www.linuxquestions.org/questions/slackware-14/terminal-colours-and-locale-831327/)

mlpa 09-10-2010 03:00 AM

Terminal colours and locale
 
Hi everyone, I use slackware64 13.1. In my root account the terminal have colors for folders, files, etc and characters like ç appear correct.

I create a normal account for me, but specials characters don't appear and terminal have no colors.

I read in a lot that I need to configure a .bashrc and a .bash_profile but I don't found this files in my root account to get some guide lines.

Can someone explain this to me?

xeleema 09-10-2010 04:51 AM

Greetingz!

For starters, any file that begins with a dot (Example: ".filename") is typically excluded from the output when you run "ls". In order to see these 'hidden files' you have to use "ls -a" (see "man ls" for more options)

Side Note: Handy Aliases to put in your .bashrc or .bash_profile file
Code:

# List only hidden files & directories
alias l.='ls -A | grep ^.'
# List only directories
alias lD='ls -d */ 2>/dev/null'
# Long-Listing with Human-Readable sizes (GNU 'ls' required)
alias ll='ls -lhF'
# Long-Listing of hidden files & directories
alias ll.='ls -ld .??*'
# Long-Listing of only directories
alias llD='ls -l | grep ^d'
# 'Verbose' listing (for the Old School Slackers)
alias v='ls -lhF'

NOTE: You may want to check your current aliases (type "alias" at the command prompt) to see if the "ls" command itself is aliased with a few options. If not, then you can put an additional alias the top of the aforementioned block of text like so;
Code:

alias ls='ls --color=auto'
Now, the GNU "ls" command supports color via the "--color=auto" option. This looks for the Environment Variable LS_COLORS (which you can put in your .bashrc or .bash_profile to override the global setting).

Here's mine (note this has to be all one line):
Code:

LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rar=01;31:*.RAR=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2A=01;35:*.m2v=01;35:*.M2V=01;35:*.m4a=01;35:*.M4A=01;35:*.m4p=01;35:*.M4P=01;35:*.m4v=01;35:*.M4V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpc=01;35:*.MPC=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.PNG=01;35:*.ppm=01;35:*.ram=01;35:*.RAM=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.tiff=01;35:*.TIFF=01;35:*.wav=01;35:*.WAV=01;35:*.wma=01;35:*.WMA=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xcf=01;35:*.xpm=01;35:*.xwd=01;35:*.XWD=01;35
Note that some *NIX distributions have a "dircolors" file somewhere (usually in /etc)

mlpa 09-10-2010 05:29 AM

My question is, what is the content of a .bashrc file and a .bash_profile file.
Where are they located, stuff like that.

xeleema 09-10-2010 06:06 AM

Quote:

Originally Posted by mlpa (Post 4093300)
My question is, what is the content of a .bashrc file and a .bash_profile file.
Where are they located, stuff like that.

They're "hidden" files within each user's home directory. To see them, do an "ls -a". Note that the files are not required to exist, nor do you have to have both (you could create one, and symlink the other).

See the bash man page (man bash) if you're interested in the differences between .bashrc and .bash_profile.

As for what goes into them;

Short Answer: Nothing. The "Good Stuff" should be defined in the global profile files.

Long Answer: Anything.
A user can specify environment variables within their own .bashrc/.bash_profile file in order to override previously set "Global Defaults" (usually specified in /etc/bashrc or /etc/default/bashrc, check your *NIX distribution's documentation)

You can change the PS1 and PS2 shell prompts, define command aliases, setup custom environment variables.

It's also possible to setup the shell's command logging options via HISTFILE= HISTSIZE= and a few others.

Basically, if you took an autoexec.bat file, rolled it in ecstasy and dipped it in chocolate, that's what a .bashrc file is for. Only it's per-user.

Note: When a user calls you with a problem, check the time/date stamp on their shell's profile file (ksh uses .kshrc, csh uses .cshrc, bash can use .bashrc and/or .bash_profile). If the timestamp is recent, they !@#$%^-up their profile.

EDIT: To give you an idea of what's in one, here's my *extremely* customized .kshrc file (similar to a .bashrc/.bash_profile. It might even work if renamed)
*removed*

sahko 09-10-2010 07:20 AM

Quote:

Originally Posted by mlpa (Post 4093300)
My question is, what is the content of a .bashrc file and a .bash_profile file.
Where are they located, stuff like that.

Slackware doesnt have those files by default. You need to create them yourself.

mlpa 09-10-2010 08:40 AM

A .bashrc with
Quote:

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# List folders and files with colors
alias ls="ls --color=auto"
is enough? No need for .bash_profile?

And about locale? I think I use en_GB and ç don't appear correct, but in root account works?


All times are GMT -5. The time now is 02:47 AM.