Skip to content

pguerin3/cwmrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Calm Window Manager (CWM)

A minimalist floating window manager that also tiles.

This repository showcases configuration of the Calm Window Manager (CWM) to keep the minimal asthetic, but at the same time make more practical.

tiled windows

CWM is a minimalist floating window manager:

[x] float windows by default. [x] snap any window into a corner, or edge of the screen. [x] snap the floating windows into a tiling configuration. eg either [x] horizontal master/stack, or vertical master/stack. [x] retain gaps between the windows and the edge of the screen.

Also there is also a native application launcher that you can drive with the mouse or touchpad. eg use the keyboard to launch applications.

If the native application launcher is not to your liking, then it’s easy to add 3rd-party lanchers and status bars. eg Polybar.

As CWM doesn’t feature multi-monitor support, the ideal use-case is that you are just using a single monitor.

X11 startx configuration

Can use ~/.xinitrc to start the default the applications, before starting CWM:

# inside ~/.xinitrc or .bash_profile (note: bash_profile calls .bashrc)
xrandr --output VGA-0 --auto
# for VirtualBox only
# xrandr --output Virtual1 --mode 1440x900

# does this fix the file picker problem???
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

#feh --no-fehbg --bg-fill --randomize /usr/share/backgrounds/wallpapers-master&
feh --no-fehbg --bg-fill ~/Downloads/cropped-1920-1080-467642.jpg&

picom --backend xrender&

dunst&

exec cwm

Now start the Calm Window Manager from the TTY with:

startx

Screenshots of floating windows that are snapped into tiles

To create a few terminal windows, use alt+cntrl+enter for each terminal.

Without a Polybar:

For example, 4 floating windows can be snapped into tiles.

Then alt+cntrl+minus to tile the 4 windows, into a master window on the left and 3 stacked windows on the right.

Then in the tiled layout, to switch the active window (in the non-primary) with the primary position - simply alt-cntrl-minus again.

4 tiled windows snapped with alt+cntrl+minus

Use alt+cntrl+enter to create another terminal.

It will float on top of the 4 other windows for a total of 5 windows.

5 windows

Then alt+cntrl+minus to restacck the 5 windows into the tiled layout with the focused window placed in the master position on the left.

5 tiled windows

So now 4 windows have been snapped into the stack on the right, and the focused window at that time was snapped into the master position on the left.

The tiled windows can also be restacked with alt+cntrl+shift+minus, so the master is now on top.

tiled windows

Other configurations include:

tiled windows

tiled windows

tiled windows

Screenshots of floating windows (without tiling)

If you prefer floating windows then CWM has you covered too:

screenshot1

screenshot2

screenshot3

screenshot4

screenshot5

screenshot6

screenshot7

Screenshots with the native application launcher

A native application laucher can be run with a mouse right-click.

native-luancher1

native-luancher2

Or you may run applications from the shell. For example:

chromium-browser&

And to ignore any run-time errors:

chromium-browser > /dev/null 2>&1 &

Add the disown command to detach the application from the terminal:

chromium-browser > /dev/null 2>&1 & disown

As systemd is used, managing the host from the shell can also be achieved with the following commands:

systemctl suspend
systemctl reboot
systemctl poweroff

Installation and configuration of CWM

The official repo for CWM is here:

Most Linux distributions have the CWM in their repository. So installing CWM is extremely easy. For example, to install in Fedora:

sudo dnf install cwm

For Debian:

sudo apt-get install cwm

For Arch:

sudo pacman -S cwm

FreeBSD also has CWM in their repository, and is installed as follows:

sudo pkg install cwm

The ~/.cwmrc configuration file used in the screen shots is similar to this:

# CMS-r = restart

# these are for the menu
#fontname "sans-serif:pixelsize=16"
#fontname "monospace:pixelsize=15"
#fontname "dejavu sans mono:size=7"
fontname fixed-11

moveamount 10	# granularity of finest movement
vtile 50
htile 75
gap 1 1 1 1
color activeborder red
color inactiveborder black
snapdist 3

#bind-key CM-Return	"urxvt"
bind-key CM-Return	"kitty"
bind-key CM-minus	window-vtile
bind-key CMS-minus	window-htile
unbind-key CS-minus
unbind-key CS-plus
unbind-key C-slash

# autogroup definitions
# as shown by xprop
autogroup 1 kitty,kitty
autogroup 2 urxvt,URxvt
autogroup 3 brave-browser, Brave-browser
autogroup 4 chromium-browser, Chromium-browser
#autogroup 5 "thorium-browser", "Thorium-browser"
autogroup 5 thorium-browser, Thorium-browser
autogroup 6 "VirtualBox Manager", "VirtualBox Manager"
autogroup 7 "VirtualBox Machine", "VirtualBox Machine"
autogroup 8 "vncviewer", "Vncviewer"
autogroup 9 "vncviewer", "Vncviewer"

bind-key M-1 group-toggle-1
bind-key M-2 group-toggle-2
bind-key M-3 group-toggle-3
bind-key M-4 group-toggle-4
bind-key M-5 group-toggle-5
bind-key M-6 group-toggle-6
bind-key M-7 group-toggle-7
bind-key M-8 group-toggle-8
bind-key M-9 group-toggle-9
bind-key M-0 group-toggle-all

# don't include Polybar as a window
#ignore polybar

# applications
# note - scroll up = shift-pageup, and scroll down = shift-pagedown
# +ssr = turn off secondary screen scroll
#command alacritty-top   "alacritty -e top"
command xscreensaver	"xscreensaver"
command xclock		"xclock"
command chromium	"chrome"
command tmux		"urxvt +sb -depth 32 -bg rgba:0000/0000/0000/aaaa -fg [100]grey -e tmux"
command top-green	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]green -e top"
command top-magenta	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]magenta -e top"
command top-grey	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]grey -e top"
command top-lightgrey	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]lightgrey -e top"
command top-lightblue	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]lightblue -e top"
command top-lightgreen	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]lightgreen -e top"
command top-lightpink	"urxvt +sb -depth 32 -bg rgba:1111/1111/1111/9999 -fg [100]lightpink -e top"
command top		"urxvt +sb -depth 32 -bg rgba:0000/0000/0000/6666 -fg [100]cyan -e top"
command vim		"urxvt -e vim ."
command gvim		"urxvt -e gvim ."

Inspect the CWM manual for all the default key bindings:

man cwm

Then inspect the CWM configuration manual for the other possibilities for the ~/.cwmrc file:

man cwmrc

Applications

The virtual terminal with Urxvt

In an X11 environment, it’s good to have a few terminal emulators available. In the event that you want to edit the configuration of a terminal emulator, and you get an unexpected result, then you should have another ready to go.

I like to have the Urxvt terminal emulator ready to go in cate I need it in a hurry.

Urxvt is present in the Fedora repo:

sudo dnf install rxvt-unicode

My urxvt terminal is configured without scroll bars. Also use shift-pageup to scroll up, and shift-pagedown to scroll down. The +ssr parameter of urxvt turns off secondary screen scroll, so for example text inside the Vim editor will not be shown in the primary window after Vim has exited. The same setting is set with secondaryScroll.

Create a ~/.Xdefaults file for the configuration of the urxvt terminal. Place the following configuration in it:

# effective on next login
URxvt.scrollBar: off
# turn off secondary screen scroll for a pager. eg less.
URxvt.secondaryScroll: off
URxvt.depth: 32
# black (0000/0000/0000) with no transparency (ffff)
# grey (1111/1111/1111) with no transparency (ffff)
URxvt.background: rgba:1111/1111/1111/ffff
URxvt.foreground: [100]grey
URxvt.font: xft:monospace:pixelsize=12
URxvt.geometry: 132x50
URxvt.visualBell: on

The virtual terminal with Kitty

Kitty is in the Fedora repo:

sudo dnf install kitty

My Kitty terminal is configured without scroll bars. Also use cntrl-shift-pageup to scroll up, and cntrl-shift-pagedown to scroll down. In Kitty, secondary screen scrolling is off by default.

Also define the font and font size you want to use with the Fish shell. In the config above I’m using FiraCode:

sudo dnf install fira-code-fonts

Kitty can autocreate a default configuration file in ~/.config/kitty/kitty.conf by using ctrl+shft+f2. Or you can maually create a configuration file yourself in the same location.

Then you can add configurations to the head of the file similar to as follows:

remember_window_size no
initial_window_width  1000
initial_window_height 1000
hide_window_decorations yes
background_opacity 0.9
dynamic_background_opacity yes
scrollback_fill_enlarged_window yes
focus_follows_mouse yes
# dnf install fira-code-fonts
font_family Fira Code Regular
font_size 8
enable_audio_bell no
visual_bell_duration 0.1
enabled_layouts vertical
editor nvim

System information with Fastfetch

Also as an option, install Fastfetch for some bling when a terminal is started. The source is here:

Fastfetch is present in the Fedora repo:

sudo dnf install fastfetch

This is what Fastfetch looks like on Fedora by default.

image

However I can also use an actual image for the graphic, if I download a suitable image like as follows:

Then as I’m using the Kitty terminal emulator, I can call Fastfetch to use the image.

fastfetch --logo-type kitty --logo-width 60 --logo ~/Downloads/Fedora_logo.png

image

Terminal multiplexing with Tmux

Handy to have, so install it like this:

sudo dnf install tmux

Create a default ~/.tmux.conf file with the following contents:

# Note that tmux should be restarted entirely (run tmux kill-server) after making changes to .tmux.conf

# needs to be at the top??
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

set -g @plugin 'tmux-plugins/tmux-prefix-highlight'

set -g @plugin 'catppuccin/tmux'
set -g @catppuccin_flavour 'latte' # or frappe, macchiato, mocha

set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_middle_separator " | "
set -g @catppuccin_window_default_fill "none"
set -g @catppuccin_window_current_fill "all"
set -g @catppuccin_status_modules_right "application session user host date_time"
#set -g @catppuccin_date_time_text "%Y-%m-%d %H:%M:%S"

# battery monitor - Plug and play battery percentage and icon indicator for Tmux.
set -g @plugin 'tmux-plugins/tmux-battery'
set -g status-right '#{battery_status_bg} #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '

# Note that tmux should be restarted entirely (run tmux kill-server) after making changes to .tmux.conf
set -g status-position top

# status bar
set -g status-style "bg=black"
set -ag status-style "fg=yellow"

# inactive status bar
set -g window-status-style bg=yellow
# active status bar
set -g window-status-current-style bg=red,fg=white

# try this to change the cursor from nvim??
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'

# An easier workflow to make a selection available outside Tmux
# Turn the clipboard off first (also security implications with the clipboard on)
set -s set-clipboard off
# Reconfigure the 'enter' in copy mode to pipe to the clipboard selection
%if "#{==:#{host},fedora}"
# My X11 terminal
# Note: may be better with primary selection instead of the clipboard
set -s copy-command 'xsel -i --clipboard'
%else
# My Cygwin terminal
# Note: need to install the cygutils-extra package from Cygwin
set -s copy-command 'putclip'
%endif

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Terminal shell with Zsh

The Zsh shell is pretty plain out-of-the box but can be configured easily enough.

Unlike Fish, Zsh as a vim mode so you can escape and then use the vim key bindings to help you edit a command.

Install the Zsh shell (with some Zsh packages in the Fedora repo) as follows:

sudo dnf install zsh zsh-autosuggestions zsh-syntax-highlighting

We will use a Zsh plugin manager named Zap:

Install it as follows:

zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-v1

There are a number of native command prompt themes available, and they can be listed with :

prompt -p

image

An example of a basic Zsh command prompt theme (eg walters) is below:

image

Compared with Fish, there are less features out-of-the-box, so Zsh should be setup with a configuration file up-front. Create a default ~/.zshrc file with the following contents:

# Created by Zap installer
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"
plug "zsh-users/zsh-autosuggestions"
#plug "zap-zsh/supercharge"
#plug "zap-zsh/zap-prompt"
#plug "zsh-users/zsh-syntax-highlighting"
#plug "zsh-zsh/vim"

plug 'zdharma-continuum/fast-syntax-highlighting'
plug 'zsh-users/zsh-history-substring-search'

################################################################
# environment variables
################################################################

# In Zsh, define LS_COLORS which are handled later with: zstyle ':completion:*' list-colors "${(s,:,)LS_COLORS}"
# Redhat 8 LS_COLORS
export LS_COLORS='rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=01;05;37;41:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;40:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.zst=38;5;9:*.tzst=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.wim=38;5;9:*.swm=38;5;9:*.dwm=38;5;9:*.esd=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.mjpg=38;5;13:*.mjpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.m4a=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.oga=38;5;45:*.opus=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:'
export LS_COLORS

# Allow the List command to pipe color information downstream. eg tail, head, less, etc
alias ls='ls --color=always --group-directories-first -v'

# Enable the Less pager to show colour
export LESS='-R --use-color -Dd+r$Du+b$'

## Linux TTY ie login terminal, or first terminal of the session
# for any Linux TTY: $OSTYPE == linux-gnu   $0 == -zsh, $TTY == /dev/tty1, /dev/tty2, etc
[[ $OSTYPE == 'linux-gnu' && $TTY =~ ^/dev/tty ]] && {
  fastfetch
}

## Linux terminal emulators
# Linux kiTTY:	  $OSTYPE == linux-gnu $0 == /usr/bin/zsh,  $TTY == /dev/pts/0,  $TERM == xterm-kitty
# Linux urxvt:	  $OSTYPE == linux-gnu $0 == zsh,	      $TTY == /dev/pts/0,  $TERM == rxvt-unicode-256color
# Linux tmux:	  $OSTYPE == linux-gnu $0 == -zsh,	      $TTY == /dev/pts/1,  $TERM == tmux-256color
# Linux nvimTerm  $OSTYPE == linux-gnu $0 == /usr/bin/zsh,  $TTY == /dev/pts/13, $TERM == xterm-256color
# ie KiTTY or nvimTerm
# if [[ $TTY =~ ^/dev/pts && $0 == '/usr/bin/zsh' ]]; then
[[ $OSTYPE == 'linux-gnu' && $TTY =~ ^/dev/pts ]] && {
  setxkbmap -layout us -variant EngramMod
  # for Linux kitty
  export EDITOR=nvim
  # Show the man page in Neovim but not in a Cygwin Tmux session
  export MANPAGER='nvim +Man!'
  # universally set the transparency
  picom-trans -c 90
  #
  if [[ -d ~/bin ]]; then
    PATH=$PATH:~/bin
  fi
  # first Linux kitty only - but not for nvim terminal
  [[ $TTY = '/dev/pts/0' && $TERM == 'xterm-kitty' ]] && {
    # note: download image: https://fedoraproject.org/wiki/File:Fedora_logo.png
    fastfetch --logo-type kitty --logo-width 60 --logo ~/Downloads/Fedora_logo.png
    zap update all&
    cd ~/me && git pull
    redshift -l manual -l -34.43:150.85 -t 6500:3000&
    ~/./battery.sh&
    #
    # Tmux
    # 4 multi-coloured panes
    ( tmux new-session -s local-4tiled-bluegreenredblack \; \
    set-option -p window-style 'bg=#000033' \; split-window -h \; \
    set-option -p window-style 'bg=#003333' \; split-window \; \
    set-option -p window-style 'bg=#330000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; \
    select-pane -UL \; \
    select-layout tiled \; \
    detach ) > /dev/null&
    #
    # just a single pane
    ( tmux new-session -s local-singlepane \; \
    detach ) > /dev/null&
    #
    # 4 black panes
    ( tmux new-session -s local-4tiled-black \; \
    set-option -p window-style 'bg=#000000' \; split-window -h \; \
    set-option -p window-style 'bg=#000000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; \
    select-pane -UL \; \
    select-layout tiled \; \
    detach ) > /dev/null&
    #
    # at the end tell me, what git changes were made
    git --no-pager log --stat -1
    #
  }
}

## Cygwin: Effectively every session is a login shell, including all the Tmux sessions
# Cygwin:	  $OSTYPE == cygwin  $0 == -zsh,	      $TTY == /dev/pty0, /dev/pty1, etc	  $TERM == xterm-256color
# Cygwin Tmux:    $OSTYPE == cygwin  $0 == -zsh,	      $TTY == /dev/pty1 ,    $TERM == tmux-256color
# Cygwin nvimTerm $OSTYPE == cygwin  $0 == /usr/bin/bash,  $TTY == /dev/cons0,    $TERM == xterm-256color
# ie any Cygwin and Tmux
[[ $OSTYPE == 'cygwin' && $TTY =~ ^/dev/pty ]] && {
  #
  # for the nvim terminal to work
  # Note: Cygwin uses /etc/nsswitch.conf instead of chsh
  # " so Cygwin can interpret the path correctly
  # nvim command line syntax is :!"command"
  export SHELL="c:\cygwin64\bin\bash.exe"
  # Show the man page in Neovim
  export MANPAGER='nvim +Man!'
  #
  # For Cygwin, start a new path from scratch
  PATH='/usr/local/bin:/usr/bin'
  if [[ -d ~/bin ]]; then
    PATH=$PATH:~/bin
  fi
  #
  readonly -a p=(
    # Neovim Windows binary from Winget installation
    '/cygdrive/c/Program Files/Neovim/bin'
    # for Fastfetch (Cygwin) get the package from here
    # https://github.com/fastfetch-cli/fastfetch/releases
    # chmod 700 fastfetch.exe
    /home/guerin.paul/fastfetch
    # Note: Cygwin setup
    /cygdrive/c/Users/guerin.paul/Downloads
  )
  for cm in "${p[@]}"; do
    PATH=$PATH:$cm
    #echo $PATH
  done
  #
  # need to do this for Cygwins (and the tmuxes)
  # so the ZSH cursor styles are recogised in the terminal
  # Note: don't need to do this for KiTTY.
  BLINKING_BLOCK='\e[1 q'
  BLINKING_BEAM='\e[5 q'
  function zle-line-init zle-keymap-select {
    if [[ $KEYMAP == vicmd ]] || [[ $1 = 'block' ]]; then
      echo -ne $BLINKING_BLOCK
    elif [[ $KEYMAP == main ]] || [[ $KEYMAP == viins ]] ||
	 [[ $KEYMAP = '' ]] || [[ $1 = 'beam' ]]; then
      echo -ne $BLINKING_BEAM
    fi
  }
  # then do this:
  # Create a user-defined widget, or overwrite an existing one.
  # Note: zle-line-init - Executed every time the line editor is started to read a new line of input.
  zle -N zle-line-init
  # zle-keymap-select - Executed every time the keymap changes,
  # i.e. the special parameter KEYMAP is set to a different value, while the line editor is active.
  zle -N zle-keymap-select
  #
  # One-off prepare for the xreation of the Tmux sessions
  # ie the first Cygwin PTY only ie not Tmux
  [[ $TTY == '/dev/pty0' ]] && {
    #Note: for Tmux, EDITOR needs to be set before tmux is first started
    export EDITOR=vim
    #
    fastfetch
    #
    # 4 multi-coloured panes
    ( tmux new-session -s local-4tiled-bluegreenredblack \; \
    set-option -p window-style 'bg=#000033' \; split-window -h \; \
    set-option -p window-style 'bg=#003333' \; split-window \; \
    set-option -p window-style 'bg=#330000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; \
    select-pane -UL \; \
    select-layout tiled \; \
    detach ) > /dev/null&
    #
    # just a single pane
    ( tmux new-session -s local-singlepane \; \
    detach ) > /dev/null&
    #
    # 2 equally spaced command prompt panes horizontally
    ( tmux new-session -s local-2hori-cmd cmd \; \
    split-window -h cmd \; \
    select-pane -L \; \
    detach ) > /dev/null&
    #
    # 4 black panes
    ( tmux new-session -s local-4tiled-black \; \
    set-option -p window-style 'bg=#000000' \; split-window -h \; \
    set-option -p window-style 'bg=#000000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; split-window \; \
    set-option -p window-style 'bg=#000000' \; \
    select-pane -UL \; \
    select-layout tiled \; \
    detach ) > /dev/null&
    #
    zap update all
    reset
    cd ~/me && git pull
    #
    # at the end tell me, what git changes were made
    git --no-pager log --stat -1
    #
  }
}

## Any Tmuxes ie Kitty and Cygwin
# Linux Tmux kitty: $0 == -zsh, $TTY == /dev/pts/2,  $TERM == tmux-256color
# Linux Tmux urxvt: $0 == -zsh, $TTY == /dev/pts/22, $TERM == tmux-256color
# Cygwin Tmux:      $0 == -zsh, $TTY == /dev/pty1    $TERM == tmux-256color
# Note: =~ is for a regular expression
[[ $0 == '-zsh' && $TERM =~ ^tmux ]] && {
  #
  # need to do this for Cygwins (and the tmuxes)
  # so the ZSH cursor styles are recogised in the terminal
  # Note: don't need to do this for KiTTY.
  BLINKING_BLOCK='\e[1 q'
  BLINKING_BEAM='\e[5 q'
  function zle-line-init zle-keymap-select {
    if [[ $KEYMAP == vicmd ]] || [[ $1 = 'block' ]]; then
      echo -ne $BLINKING_BLOCK
    elif [[ $KEYMAP == main ]] || [[ $KEYMAP == viins ]] ||
	 [[ $KEYMAP = '' ]] || [[ $1 = 'beam' ]]; then
      echo -ne $BLINKING_BEAM
    fi
  }
  # then do this:
  # Create a user-defined widget, or overwrite an existing one.
  # Note: zle-line-init - Executed every time the line editor is started to read a new line of input.
  zle -N zle-line-init
  # zle-keymap-select - Executed every time the keymap changes,
  # i.e. the special parameter KEYMAP is set to a different value, while the line editor is active.
  zle -N zle-keymap-select
  #
}

# show all the jobs
jobs


################################################################
# Autoload functions and themes
# Note - needs to be set before the prompt is shown in the terminal
################################################################
# Created by newuser for 5.8
autoload -Uz compinit promptinit
compinit
# a prompt theme system for changing prompts easily
promptinit

# This will set the default prompt to the walters theme
prompt walters

##################################################
# shell parameters
##################################################
# keep the history file independent from the Bash history file.
# Note: stores interactive history only
# Note: not the same as the Bash history file.
HISTFILE=~/.zhistfile

# SAVEHIST - The maximum number of history events to save in the history file.
# Note: may not be applicable as we are using the APPEND_HISTORY feature.
SAVEHIST=130

# HISTSIZE - The maximum number of events stored in the internal history list.
# Immediately before execution, each command is saved in the history list, the size of which is
# controlled by the HISTSIZE parameter.
HISTSIZE=150

# HISTORY_IGNORE -  Any potential history entry that matches the pattern is not written to the history file.
# Compared to the HIST_NO_STORE option which prevents such commands being written to the interactive history.
#HISTORY_IGNORE='(first|second|...)'
HISTORY_IGNORE='(less|vim|nvim|man|cd|if|scp|cp|mv|rm|head|tar|zip|unzip|export|tail|nslookup|ping|DISPLAY|HOST|ACCOUNT|VERSION|FILE|SOURCE|test)'

# The default editor for the fc builtin.
# Note: will follow EDITOR, if blank.
FCEDIT='vim'

# output to the terminal instead of beeping.
# eg flashing reverse video on and off.
ZBEEP='\e[?5h\e[?5l'

# The primary prompt string, printed before a command is read.
# Note: same as PS1
PROMPT='%F{green}%n%f@%F{magenta}%m%f %F{blue}%B%~%b%f %# '
# This prompt is displayed on the right-hand side of the screen when the primary
# prompt is being displayed on the left.
# note; same as RPS1
RPROMPT='[%F{yellow}%?%f]'

##################################################
# options
##################################################

## Changing Directories
# if not a command, then assume a directory and do a cd against it.
setopt AUTO_CD

## Completion

## Expansion and Globbing
# Treat the #, ~ and ^ characters as part of patterns for filename generation, etc.
setopt EXTENDED_GLOB
# If a pattern for filename generation has no matches, print an error, instead of leaving it unchanged
setopt NOMATCH

## History list (not to be confused with the history file)
# Note: before execution, each command is saved in the history list
# Note: each zsh session has their own history list.
# Each saved command in the history list is called a history event and is assigned a number,
# beginning with 1 (one) when the shell starts up. ie echo $HISTCMD
# Looks like:
#  - the most recent history file events (max=HISTSIZE) are loaded at session startup into the history list.
#  - the local event number increments from there as you execute commands interactively.
#  - the history list is written to the history file at exit. ie configured as append, instead of overwrite.
# Return all the local history events from most recent first to oldest last. ie echo ${history[@]}

# Beep in ZLE when a widget attempts to access a history entry which isn’t there.
setopt HIST_BEEP
# zsh sessions will append their history list to the history file, rather than replace it. * but when the session exits *
# When appending, the history file is trimmed when the number of lines grows 20% beyond the value specified by $SAVEHIST.
# eg the history file is trimmed to 1200 lines in length with SAVEHIST=1000
setopt APPEND_HISTORY
# Perform textual history expansion, csh-style, treating the character ‘!’ specially.
setopt BANG_HIST
# If a new command line being added to the history list duplicates an older one, the older command is removed from the list
setopt HIST_IGNORE_ALL_DUPS
# Do not enter command lines into the history list if they are duplicates of the previous event.
setopt HIST_IGNORE_DUPS
# Remove command lines from the history list when the first character on the line is a space.
setopt HIST_IGNORE_SPACE
# Remove function definitions from the history list.
setopt HIST_NO_FUNCTIONS
# Remove the history (fc -l) command from the history list when invoked.
setopt HIST_NO_STORE
# Remove superfluous blanks from each command line being added to the history list.
setopt HIST_REDUCE_BLANKS
# Write out a copy of the file named $HISTFILE.new and then rename it over the old one.
setopt HIST_SAVE_BY_COPY
# When writing out the history file, older commands that duplicate newer ones are omitted.
setopt HIST_SAVE_NO_DUPS
# with history expansion, instead, perform the history expansion and reload the line into the editing buffer.
setopt HIST_VERIFY

## Initialisation

## Input/Output
# Try to correct the spelling of all arguments in a line.
#setopt CORRECT_ALL
# stop zsh from allowing flow control. ie disable cntrl-s (ie stop) and cntrl-q (ie resume)
unsetopt FLOW_CONTROL
# Do not exit on end-of-file. Require the use of exit or logout instead.
setopt IGNORE_EOF
# Subsequent invocations of the same command will use the saved location, avoiding a path search.
setopt HASH_CMDS

## Job Control
# Report the status of background jobs immediately, rather than waiting until just before printing a prompt.
setopt NOTIFY

## Prompting

## Scripts and Functions

## Shell Emulation

## Shell State

## ZLE
# Beep on error in ZLE.
setopt BEEP


##################################################
# ZSH Line Editor
##################################################
# Selects keymap ‘viins’ for any operations by the current command
bindkey -v

# use ^p and ^n to search through history more precisely with a starting prefix.
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward

##################################################
# Shell built in commands
##################################################
zstyle ':completion::complete:*' gain-privileges 1
# make the search case insensitive for the auto-completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
# add colour to the auto-completions too
zstyle ':completion:*' list-colors "${(s,:,)LS_COLORS}"

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -g -A key

#key[Home]="${terminfo[khome]}"
#key[End]="${terminfo[kend]}"
#key[Insert]="${terminfo[kich1]}"
#key[Backspace]="${terminfo[kbs]}"
#key[Delete]="${terminfo[kdch1]}"
#key[Up]="${terminfo[kcuu1]}"
#key[Down]="${terminfo[kcud1]}"
#key[Left]="${terminfo[kcub1]}"
#key[Right]="${terminfo[kcuf1]}"
#key[PageUp]="${terminfo[kpp]}"
#key[PageDown]="${terminfo[knp]}"
#key[Shift-Tab]="${terminfo[kcbt]}"

## setup key accordingly
#[[ -n "${key[Home]}"      ]] && bindkey -- "${key[Home]}"       beginning-of-line
#[[ -n "${key[End]}"       ]] && bindkey -- "${key[End]}"        end-of-line
#[[ -n "${key[Insert]}"    ]] && bindkey -- "${key[Insert]}"     overwrite-mode
#[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}"  backward-delete-char
#[[ -n "${key[Delete]}"    ]] && bindkey -- "${key[Delete]}"     delete-char
#[[ -n "${key[Up]}"        ]] && bindkey -- "${key[Up]}"         up-line-or-history
#[[ -n "${key[Down]}"      ]] && bindkey -- "${key[Down]}"       down-line-or-history
#[[ -n "${key[Left]}"      ]] && bindkey -- "${key[Left]}"       backward-char
#[[ -n "${key[Right]}"     ]] && bindkey -- "${key[Right]}"      forward-char
#[[ -n "${key[PageUp]}"    ]] && bindkey -- "${key[PageUp]}"     beginning-of-buffer-or-history
#[[ -n "${key[PageDown]}"  ]] && bindkey -- "${key[PageDown]}"   end-of-buffer-or-history
#[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}"  reverse-menu-complete

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
	autoload -Uz add-zle-hook-widget
	function zle_application_mode_start { echoti smkx }
	function zle_application_mode_stop { echoti rmkx }
	add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
	add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi


# man zshzle
# A zle widget is a synonym for zle command. Everything is a widget.
# List bindkeys: bindkey
# List widgets: zle -l
# And in Bash can use cntrl-x cntrl-e (by default)
# Can setup the same key bindings for ZLE
# Note: for this to work correctly, need to still be in insert mode at the command line.
autoload -U edit-command-line;
zle -N edit-command-line;
bindkey '^x^e' edit-command-line;

################################################################
# other
################################################################

# for any Linux : $0 = -zsh, $TTY = /dev/pts/*
# ie not for Cygwin
# Note: =~ is for a regular expression
if [[ $0 = '-zsh' && $TTY =~ '/dev/pts/' ]]; then
  #source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  #source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  # Note: can get fzf from the Fedora repo
  #source /etc/profile.d/fzf-completion.zsh
  #source /etc/profile.d/fzf.zsh
fi

An interactive shell with Fish

The Fish shell has syntax highlighting out-of-the box with a selection of prompts and colour themes. Install the Fish shell as follows:

sudo dnf install fish

The ~/.config/fish/config.fish file is like this:

if status is-interactive
    # Commands to run in interactive sessions can go here
    # add color to the less pager in Fish, not Bash does this differently using export.
    set -gx LESS_TERMCAP_mb (printf '\e[01;31m') # enter blinking mode - red
    set -gx LESS_TERMCAP_md (printf '\e[01;35m') # enter double-bright mode - bold, magenta
    set -gx LESS_TERMCAP_me (printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
    set -gx LESS_TERMCAP_se (printf '\e[0m') # leave standout mode
    set -gx LESS_TERMCAP_so (printf '\e[01;33m') # enter standout mode - yellow
    set -gx LESS_TERMCAP_ue (printf '\e[0m') # leave underline mode
    set -gx LESS_TERMCAP_us (printf '\e[04;36m') # enter underline mode - cyan
end
#Note - same what may be found in a Bash configuration file except the $ is removed.

#Add your favourite keyboard layout here for X11
#setxkbmap -layout us -variant <name>

# Now it's your choice of fastfetch for every terminal
#fastfetch
# or fastfetch just for the 1st terminal (fish syntax)
set -l LIVE_COUNTER $(ps a -o tty $(pgrep $(echo $TERM)) | uniq --unique | wc -l)
if [ $LIVE_COUNTER -eq 1 ]
     fastfetch
end

The theme and prompt can also be selected from the native configurations. Display a list of Fish themes with:

fish_config theme show

image

Then choose a Fish theme like this:

fish_config theme choose 'ayu Dark'
fish_config theme save 'ayu Dark'

Similarly display a list of Fish prompts with:

fish_config prompt show

And choose a Fish prompt like this:

fish_config prompt choose nim
fish_config prompt save

An example of the 'ayu Dark' theme with a 'nim' prompt is below:

image

If you are running a job in the background then it will be shown.

image

When no jobs are present then the normal prompt returns.

Window transparency with Picom

Transparency in the terminal is enabled in the terminal, but the transparency itself is performed by Picom:

sudo dnf install picom

Status bar with Polybar

Status bar can be provided by Polybar:

sudo dnf install polybar

In the Fedora repo there is an example config file installed by default: /usr/share/doc/polybar/examples/config.ini

However this file can be copied to: ~/.config/polybar/config.ini

mkdir ~/.config/polybar/
cp /usr/share/doc/polybar/examples/config.ini ~/.config/polybar/config.ini

By default, this is what it looks like (need the prerequisite fonts installed - see below)

image

However, the bar is easy to customise to your liking, and edit the configuration file to remove any components that you don’t want to use.

For Fedora, you may need to install the right fonts (eg siji, and NotoColorEmoji) for the Polybar config file. Also need the xset app for the siji font below:

sudo dnf install xset

Then follow the instructions in github to install the siji font:

Now ensure the Polybar config.ini file refers to the google-noto-emoji font:

font-0 = fixed:pixelsize=10;1
;font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
;then edit the font-1 line in the config look like this (uses the google-noto-emoji font)
font-1 = NotoColorEmoji:fontformat=truetype:scale=8;0
font-2 = siji:pixelsize=10;1

Then run the example bar with:

polybar example&

Or place the above command in the CWM configuration file (shown below).

Now the Polybar will look something like this:

image

Tiled windows with a Polybar (top right corner):

An modified version of the example Polybar, with the bar at 50% of the screen width, is shown below:

image

Text editing with Neovim and Lua

Neovim can be thought of as an enhanced Vim editor, with the advantage that the Lua language can be used for configuration.

Install Neovim in Fedora like this:

sudo dnf install neovim

Neovim can reuse a Vim configuration file (with Vimscript), but for those that want to use Lua, then the starting point is to do the following steps.

Create a Lua directory for Neovim:

mkdir -p ~/.config/nvim/lua

Now create a settings file using Lua in ~/.config/nvim/lua/settings.lua The settings file will be based on your current vim.init file, but now the Lua syntax will be used instead.

-- show the config location from the Neovim command line :echo stdpath('config)
-- for Cygwin settings.lua
--   vim "C:/Users/guerin.paul/AppData/Local/nvim/lua/settings.lua"
--   nvim "C:/Users/guerin.paul/AppData/Local/nvim/lua/settings.lua"
-- for Linux settings.lua
--   nvim ~/.config/nvim/lua/settings.lua

local o = vim.o
local wo = vim.wo
local bo = vim.bo

-- global options
o.termguicolors = true
o.foldclose = 'all'
o.linebreak = true
o.visualbell = true
o.mousefocus = true

if vim.fn.has 'win64' == 1 then
  --if vim.fn.isdirectory '/home/guerin.paul' == 1 then
  -- print("Found git repository at")
  -- This is for Cygwin to allow executing comands from the : prompt
  vim.opt_global.shellcmdflag = '-c'
end

-- Note: default termpastefilter is 'BS,HT,ESC,DEL'
o.termpastefilter = o.termpastefilter .. ',C0,C1'
-- The minimal width of a window, when it's not the current window.
o.winminwidth = 12

-- select everforest
-- https://github.com/neanias/everforest-nvim
require('everforest').load()
-- or select it from:
-- colorscheme everforest
--vim.api.nvim_command('colorscheme everforest')

-- this was in the neovim help
-- :set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
--  \,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
--  \,sm:block-blinkwait175-blinkoff150-blinkon175
o.guicursor = 'n-v-c:block,'
  .. 'i-ci-ve:ver25,'
  .. 'r-cr:hor20,'
  .. 'o:hor50,'
  .. 'a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,'
  .. 'sm:block-blinkwait175-blinkoff150-blinkon175'
-- to stop the wrapping to the top of the file on searching
o.wrapscan = true
-- track the directory to the file
o.autochdir = true
-- Add a column marker
o.colorcolumn = '81'

-- try this
vim.g.have_nerd_font = true

-- window-local options
vim.opt.number = true
vim.opt.relativenumber = true
-- Enables pseudo-transparency for a floating window.
wo.winblend = 20
--wo.linebreak = true

-- buffer-local options
-- set the increment and decrement of indenting
vim.o.shiftwidth = 4
vim.o.autoindent = true
-- for the increment cntrl-a and decrement cntrl-x.
vim.o.nrformats = vim.o.nrformats .. ',octal,alpha'
-- Note: default matchpairs is '(:),{:},[:]'. Also /* and */ is already included.
vim.o.matchpairs = vim.o.matchpairs .. ',<:>'

--imap ( ()<left>
--vim.api.nvim_set_keymap('i', '(', '()<left>', { noremap = true, silent = true })
vim.keymap.set('i', '(', '()<left>')

-- seems to work
vim.api.nvim_set_keymap('n', 'ZZ', '<Nop>', { noremap = true, silent = true })
-- why does this error?
--vim.keymap.del('n', 'ZZ')

-- this works with cursor placed on the fold, and F9 without the fn key but old syntax
--vim.api.nvim_set_keymap('n', '<F9>', 'zoj"+yiWzc', { noremap, nosilent })

--	let g:netrw_liststyle=3
--	let g:netrw_keepdir=0
--	let g:netrw_sizestyle='H'
vim.g.netrw_liststyle = 3
vim.g.netrw_keepdir = 0
vim.g.netrw_sizestyle = 'H'
vim.g.netrw_winsize = -90

-- Kickstart config sets this to true, so set it back to false
--vim.g.splitright = false
vim.opt.splitright = false

-- Simple example for an autocommand
-- https://neovim.io/doc/user/api.html#api-autocmd
--vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, {
--  pattern = { '*.c', '*.h' },
--  command = "echo 'Entering a C or C++ file'",
--})

-- for highlight on yank
--vim.cmd [[
--    au TextYankPost * silent! lua vim.highlight.on_yank {higroup="IncSearch", timeout=150}
--]]

-- valid syntax!!!
-- check if |clipboard| provider is available.
--if vim.fn.has 'clipboard' == 1 then
--  vim.keymap.set('', 'cp', '"+y')
--  vim.keymap.set('', 'cv', '"+p')
--end

-- valid syntax!!!
--if vim.fn.has 'linux' == 1 then
--  print(vim.uv.os_uname().sysname)
--end

-- this one works in X11 !!!
-- ###### but not X11 in Tmux #######
-- Note: need to have the clipboard flag enabled
-- :echo has('clipboard')
-- returns 1
if vim.fn.has 'Linux' == 1 then
  vim.g.clipboard = {
    name = 'OSC 52',
    copy = {
      ['+'] = require('vim.ui.clipboard.osc52').copy '+',
      ['*'] = require('vim.ui.clipboard.osc52').copy '*',
    },
    paste = {
      ['+'] = require('vim.ui.clipboard.osc52').paste '+',
      ['*'] = require('vim.ui.clipboard.osc52').paste '*',
    },
  }
end

-- this works for Cygwin!!!!!
-- Note: need to have the clipboard flag enabled
-- :echo has('clipboard')
-- if enabled then returns 1
--if vim.fn.has 'win64' == 1 then
--  -- Cygwin
--  -- the following clipboard command is based on the :help clipboard
--  vim.g.clipboard = {
--    name = 'WslClipboard',
--    copy = {
--      ['+'] = 'clip.exe',
--      ['*'] = 'clip.exe',
--    },
--    paste = {
--      ['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
--      ['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
--    },
--  }
--end

-- This works in Cygwin
-- Need to have the getclip and putclip installed in Cygwin
-- https://neovim.io/doc/user/provider.html#provider-clipboard
-- putclip.exe = copies stdin to the Windows clipboard does NOT use Cygwin's /dev/clipboard
-- getclip.exe = copies the Windows clipboard to stdout does NOT use Cygwin's /dev/clipboard
if vim.fn.has 'win64' == 1 then
  -- Cygwin
  vim.g.clipboard = {
    name = 'CygwinClipboard',
    copy = {
      ['+'] = 'putclip.exe',
      ['*'] = 'putclip.exe',
    },
    paste = {
      ['+'] = 'getclip.exe',
      ['*'] = 'getclip.exe',
    },
  }
end

Now get an initial settings file from Kickstart:

Now create a reference to the settings file in ~/.config/nvim/init.lua file like this:

--
-- Kickstart settings are here
--

-- Environment settings in lua/settings.lua
require('settings')

The following screenshot uses the everforest color scheme.

image

As Kickstart uses the Lazy plugin manager, enter the plugin manager like this: :Lazy

PDF document viewer with Zathura

It’s possible to view PDFs with your browser, but a dedicated PDF viewer can be more convenient.

sudo dnf install zathura zathura-plugins-all
sudo dnf install zathura-fish-completion

Some of the key bindings are the same as Vim, with the basics as:

  • j = down

  • k = up

  • g = top of document

  • G = bottom of document

  • minus = zoom in

  • plus = zoom out

  • equals = original size

  • q = quit

Viewing a PDF is as easy as:

zathura <name of pdf>

image

Other applications

Use of other packages can be seen in the screenshots, and they are:

  • chromium - browser

  • exa - a modern replacement for ls

  • feh - wallpaper launcher

  • xclip - copy between the clipboard and the primary selection

  • git - version control

  • sysstat - for the sar utility

  • redshift - adjusts the color temperature of your screen

  • flameshot - for screenshots

Install those from DNF

sudo dnf install chromium exa feh xclip vim-X11 git sysstat redshift flameshot

So using xsel or xclip you can copy selections as follows:

xsel -o --primary| xsel -i --clipboard

xclip -o -selection primary| xclip -i -selection clipboard

Flameshot can be used like this:

flameshot gui

Other configurations

Enhance the touchpad

If you are using a laptop, then the touchpad may not have full functionality. For example, a drag selection is possible, but a double-tap selection is not. So to enable a double-tap selection, create the following file as the root user: /etc/X11/xorg.conf.d/10-touchpad.conf

Section "InputClass"
    Identifier "tap-by-default"
    Driver "libinput"
    Option "Tapping" "on"
EndSection

Rectify any screen tearing and freezing

If you are using the native X11 drivers for your GPU, then it’s possible you may encounter abnormal video. The same problems may not exist with the vendor supplied drivers.

For the native X11 drivers, you may experience screen tearing and freezing for the Intel GPU that you’re using. If so, then try the following.

Create the following file as the root user: /etc/X11/xorg.conf.d/20-intel.conf

Section "Device"
    Identifier  "Intel Graphics"
    Driver      "intel"
    # stop screen tearing
    Option "TearFree" "true"
    Option "TripleBuffer" "true"
    # stop screen freezing
    Option "DRI" "2"
EndSection

Package management with DNF

Optimise dnf for performance, by adding the following to /etc/dnf/dnf.conf

max_parallel_downloads=10
fastestmirror=True

About

Configuration of the Calm Window Manager (CWM)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages