# How to convert this .bashrc to .tcshrc



## giahung1997 (Feb 15, 2018)

I've just installed FreeBSD with XFCE, everything seemed OK except the terminal show no color, it's too ugly. I run echo $SHELL it said it's tcsh. This is my .bashrc on MXLinux17, with I'm very pleased with, please help me to translate it to the .tcshrc version. Thanks.


```
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
# force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

red='\[\e[0;31m\]'
RED='\[\e[1;31m\]'
blue='\[\e[0;34m\]'
BLUE='\[\e[1;34m\]'
cyan='\[\e[0;36m\]'
CYAN='\[\e[1;36m\]'
green='\[\e[0;32m\]'
GREEN='\[\e[1;32m\]'
yellow='\[\e[0;33m\]'
YELLOW='\[\e[1;33m\]'
PURPLE='\[\e[1;35m\]'
purple='\[\e[0;35m\]'
nc='\[\e[0m\]'

if [ "$UID" = 0 ]; then
    PS1="$red\u$nc@$red\H$nc:$CYAN\w$nc\\n$red#$nc "
else
    PS1="$PURPLE\u$nc@$CYAN\H$nc:$GREEN\w$nc\\n$GREEN\$$nc "
fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -lh'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# Default parameter to send to the "less" command
# -R: show ANSI colors correctly; -i: case insensitive search
LESS="-R -i"

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

# Add sbin directories to PATH.  This is useful on systems that have sudo

[ -z "${PATH##*/sbin*}" ] || PATH=$PATH:/sbin:/usr/sbin
export QT_QPA_PLATFORMTHEME=qt5ct
JAVA_HOME=/home/scrt/Documents/up-to-date-java/zulu8.27.0.7-jdk8.0.162-linux_x64
export PATH=$JAVA_HOME/bin:$PATH
FAN_HOME=/home/scrt/Documents/not-needed-but-still-cached/fantom-1.0.70
PATH=$PATH:$FAN_HOME/bin:$HOME/bin
```

I'm also post my .profile on Linux too:


```
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
```


----------



## Minbari (Feb 15, 2018)

SH and Bash have a different syntax and you have to modify/rewrite that file to meet the sh/tcsh syntax. Also keep in mind that most software is installed in /usr/local/... on FreeBSD, where in GNU/Linux it's only /usr/...


----------



## SirDice (Feb 15, 2018)

I suggest you start reading tcsh(1) and ~/.cshrc.


----------



## tobik@ (Feb 15, 2018)

giahung1997 said:


> I've just installed FreeBSD with XFCE, everything seemed OK except the terminal show no color, it's too ugly. I run echo $SHELL it said it's tcsh. This is my .bashrc on MXLinux17, with I'm very pleased with, please help me to translate it to the .tcshrc version. Thanks.


Hmm, why not install bash if you're happy with it?


----------



## ShelLuser (Feb 15, 2018)

giahung1997 said:


> I've just installed FreeBSD with XFCE, everything seemed OK except the terminal show no color, it's too ugly. I run echo $SHELL it said it's tcsh.



Other than what tobik@ said I think it's also important to realize that within X the terminal application itself is often also responsible for adding colors to the environment. So you may just as well be done with properly configuring that.

Still, this question does raise another: are you by any chance using the environment while being logged in as root? Because that would definitely explain the use of csh vs. the common sh, and it could also cause more problems than they're worth. Misusing / overusing the root account is generally speaking not the best of ideas on a Unix-like OS.

So if you are using the root account my suggestion would be to create another user account and use that instead. The very moment you need root privileges then rely on su or optionally security/sudo.


----------



## SirDice (Feb 15, 2018)

Colors work just fine but a lot of people don't like them, so it's off by default. Nothing is preventing you from creating your own prompt _with_ colors though. And if you set the environment variable CLICOLOR ls(1) will automatically switch to color mode.


```
CLICOLOR            Use ANSI color sequences to distinguish file types.
                         See LSCOLORS below.  In addition to the file types
                         mentioned in the -F option some extra attributes
                         (setuid bit set, etc.) are also displayed.  The
                         colorization is dependent on a terminal type with the
                         proper termcap(5) capabilities.  The default "cons25"
                         console has the proper capabilities, but to display
                         the colors in an xterm(1), for example, the TERM
                         variable must be set to "xterm-color".  Other
                         terminal types may require similar adjustments.
                         Colorization is silently disabled if the output is
                         not directed to a terminal unless the CLICOLOR_FORCE
                         variable is defined.
```
See ls(1).


----------



## giahung1997 (Feb 15, 2018)

Something went wrong with the forums, I can't multiquote.

SirDice: I'm somewhat stupid, I'm lost in the forest of options in manpage.

ShelLuser: I'm not remember clearly but, FreeBSD seemed doesn't include sudo by default. I've to install it and manually edit sudoers by nano, I hate vi so much, I can't quit except using Ctrl-C. As my normal user account (not root) with sudo I installed the whole X and XFCE thing from pkg. Configure Slim and get something less ugly to work with. I said about my XFCE4-Terminal with my normal user account, it doesn't coloring the output of ls -la like on Linux.

tobik@: I installed bash with pkg and again no coloring like tcsh. I changed the shell with chsh.

Uhm, are you FreeBSD has something trouble with Intel Integrated Graphics? When I scroll using Firefox it hurts my eye, it never smooth like on Windows, nor at lease on MXLinux. Right now I'm downloading the MX iso and going to dd it to my usb and wipe out whole disk FreeBSD with MXLinux. Perhaps I better go with GhostBSD, waiting for them to become a bit more stable than their current now (I tried). FreeBSD is a server OS, for Desktop and non-expert user it's too cumbersome. People like me want something out of the box, doesn't care about customization, freedom of choice, philosophy, licences, etc...

Updated: not yet remove FreeBSD, still living with scrolling problem, I've converted my Linux .bashrc and it works fine.


----------

