Shell .profile brainer

Hello! I was comparing the .profile in my user and root homefolders, where this pretty basic snippet made my brain stop.
Code:
TERM=${TERM:-xterm}
export TERM
PAGER=less
export PAGER
export QT_QPA_PLATFORMTHEME=qt6ct

While they're fine, theres no need to define qt_qpa_platformtheme on an extra line, so why would the other envs need that simplification which really adds keypresses?
Are confs printed this way in an attempt to guide the user of how commands -can- be entered?
Does it make a real difference further on?
 
This i my regular user , .shrc , each line has a reason,
Code:
# .shrc - bourne shell startup file
# file permissions: rwxr-xr-x
# umask    022

# some useful aliases
alias h='fc -l'
alias j=jobs
alias m="$PAGER"
alias ll='ls -laFo'
alias l='ls -l'
alias g='egrep -i'
alias egrep='grep -E'
# # csh like history on arrow up and down
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

# # ctrl+arrow allow to jump from words to words
bind "\\e[1;5C" em-next-word
bind "\\e[1;5D" ed-prev-word
alias history="fc -l"

# Fix home/del for mobaxterm
bind ^[[5~ ed-move-to-beg
bind ^[[6~ ed-move-to-end

export JAVA_VERSION=23
export JAVA_HOME="/usr/local/openjdk23"


# Function to safely prepend a directory to PATH if it exists and isn't already there
path_add() {
    if [ -d "$1" ]; then
        case ":$PATH:" in
            *":$1:"*) ;; # Already in PATH
            *) PATH="$1:$PATH" ;;
        esac
    fi
}

export PATH=""

CUSTOM_PATHS="
$JAVA_HOME/bin
/home/x/.local/share/gem/ruby/3.3/bin
/home/x/.local/bin
/home/x/.local/share/coursier/bin
/home/x/.cargo/bin
/home/x/.dotnet/tools
/home/x/.acme.sh
/home/x/.roswell/lisp/quicklisp/bin
/home/x/.nimble/bin
/home/x/git/alire/bin
/home/x/git/DCD/bin
/home/x/git/serve-d
/home/x/git/crystalline/bin
/home/x/git/cppfront/source
/home/x/git/c3-lsp/server/bin
/home/x/git/zls/zig-out/bin
/home/x/git/pony-language-server/build/release
/home/x/git/clojure-lsp
/home/x/git/clojure-lsp/cli
/home/x/KEEP/Apps/ldc2/ldc2/bin
/home/x/config/doomemacs/bin
/usr/local/gnat12/bin
/usr/local/gnat13/bin
/usr/local/gerbil/bin
/home/x/bin
/usr/local/swift510/bin
/home/x/git/Odin
/home/x/git/ols
/home/x/git/Nim/bin
/home/x/git/harec/.bin
"

for dir in $CUSTOM_PATHS; do
    path_add "$dir"
done

path_add "/usr/local/bin"
path_add "/usr/local/sbin"
path_add "/usr/bin"
path_add "/usr/sbin"
path_add "/usr/local/llvm21/bin"
path_add "/bin"
path_add "/sbin"

export PATH

export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools

#-----------------------------------------------------------------------
export CPATH="/usr/local/include:$CPATH"
export CPATH="/usr/local/llvm21/include:$CPATH"
export LIBRARY_PATH="/usr/local/lib:$LIBRARY_PATH"
export LIBRARY_PATH="/usr/local/llvm21/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/local/llvm21/lib:$LD_LIBRARY_PATH"
#-----------------------------------------------------------------------
export LANG="nl_BE.UTF-8"
export LANGUAGE="nl_BE.UTF-8"
export LC_ALL=$LANG
export LC_CTYPE=$LANG
export LC_NUMERIC=$LANG
export LC_TIME=$LANG
export LC_COLLATE=$LANG
export LC_MONETARY=$LANG
export LC_MESSAGES=$LANG
export LC_PAPER=$LANG
export LC_NAME=$LANG
export LC_ADDRESS=$LANG
export LC_TELEPHONE=$LANG
export LC_MEASUREMENT=$LANG
export LC_IDENTIFICATION=$LANG
export MM_CHARSET=$LANG
export TZ=Europe/Brussels
#-----------------------------------------------------------------------
export CLICOLOR
export COLORFGBG="15;0"
export COLORTERM="truecolor"
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
export PAGER=less
export EDITOR=nvim
export VISUAL=nvim
export TERM="xterm-256color"
export QT_QPA_PLATFORMTHEME="qt6ct"
export BROWSER=firefox
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export NO_AT_BRIDGE=1
export CLICOLOR="yes"
export LSCOLORS="Gxfxcxdxbxegedabagacad"
#-----------------------------------------------------------------------
export DOTNET_HOST_PATH=/usr/share/dotnet/dotnet
export LD_PRELOAD=
export DC=ldc2
export SAGE_ROOT=/usr/local
export SAGE_LOCAL=/usr/local
#-----------------------------------------------------------------------
export CC=clang
export CXX=clang++
export CPP=clang-cpp
export DOTNET_ROOT=/usr/local/share/dotnet
export LIBGL_DRI3_DISABLE=1
#-----------------------------------------------------------------------

alias y='grep -iE' # egrep is deprecated; use grep -E
alias x='gnls --color=auto'
alias w='eza -l --color-scale=size --icons --group-directories-first --header --hyperlink --sort=modified -h'
alias vman='man -P "nvim +Man!"'
alias n='nvim-qt'
#PS1="$(whoami)@$(hostname -s):$(pwd) \$ "
PS1="\u@\h:\w \\$ "

gai() {
    # This opens Gemini with your query pre-filled
    firefox "https://gemini.google.com"
}

cpanm --local-lib=~/perl5 local::lib
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)

export OLLAMA_MODELS="/SSD/ollama"

export QT_QPA_PLATFORMTHEME=qt5ct
unset QT_STYLE_OVERRIDE

#export QT_QPA_PLATFORM=wayland
#export GDK_BACKEND=wayland
#export SDL_VIDEODRIVER=wayland
#export MOZ_ENABLE_WAYLAND=1
#export QT_STYLE_OVERRIDE=fusion
 
Last edited:
If I'm understanding your question, you're asking why some take the form 'foo=bar; export foo' and others take the form 'export baz=mu'? If so, it's that some shells, especially early, only understood the first syntax whereas most shells learned the more concise syntax eventually or were born that way. Still, the first form is more reliable.

If I misunderstood, sorry.
 
Hello! I was comparing the .profile in my user and root homefolders, where this pretty basic snippet made my brain stop.
Code:
TERM=${TERM:-xterm}
export TERM
PAGER=less
export PAGER
export QT_QPA_PLATFORMTHEME=qt6ct

While they're fine, theres no need to define qt_qpa_platformtheme on an extra line, so why would the other envs need that simplification which really adds keypresses?
Are confs printed this way in an attempt to guide the user of how commands -can- be entered?
Does it make a real difference further on?
Which file has QT_QPA_PLATFORMTHEME line in it? User or root?
What's the output of "echo $SHELL" for your user and for root?
The single line syntax works in /bin/sh (root shell) and for bash so it's likely just a stylistic thing.
The QT line is likely not in the default versions of the file so should not be in root's version, which
means whoever added it to the user version decided one liner was cleaner.

It makes no difference; at one point in time (maybe a long time ago) the single line was not valid syntax in sh so would cause an error.
 
raffle4 the two-line form isn't giving any indication of what can or should be modified.
The reason why they're written on two lines is the export command initially did not have the option to set the value of an environment variable. It only marked an existing variable for export. This was the case up to an including System V R4 (1988) and POSIX.1 (1988).
Although FreeBSD's Bourne-compatible shell never required this, a lot of the oldest code in FreeBSD comes from the time when developers would have had to keep such things in mind.
 
Thank you those replies combined answers just what I was wondering about, curiosity satisfied. It's not related to an error, the snippet is combined from both user and root, qt6 is only for the user now. I can't even imagine yet what root would need special .profile settings for. (Alains example holds clues though)
 
Back
Top