Console
Console
No matter from which side you approach penguins, more always come from behind
- A friend of mine
Colors
Noweb function to get colors.
(let ((color (or (my/color-value name))))
(if (> quote 0)
(concat "\"" color "\"")
color))
(let ((val (if (ct-light-p (my/color-value name))
(my/color-value 'black)
(my/color-value 'white))))
(if (eq quote 1)
(concat "\"" val "\"")
val))
(setq-local org-confirm-babel-evaluate nil)
.profile
Environment
export QT_QPA_PLATFORMTHEME="qt5ct"
export QT_AUTO_SCREEN_SCALE_FACTOR=0
Set ripgrep config path
export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc
hledger path
export LEDGER_FILE="$HOME/30-39 Life/32 org-mode/ledger/ledger.journal"
Checking if running inside termux
if command -v termux-setup-storage > /dev/null; then
export IS_ANDROID=true
[[ -f ~/.android_profile ]] && . ~/.android_profile
fi
Timezone
# TZ='Asia/Karachi'; export TZ
Turn off Guix
if [ -f "/home/pavel/.no-guix" ]; then
export NO_GUIX=true
export PATH=$(echo $PATH | tr ":" "\n" | grep -vE "guix|nix|gnu" | tr "\n" ":")
fi
My paths
My script folders
if [ -d "$HOME/bin" ] ; then
export PATH="$HOME/bin:$PATH"
export PATH="$HOME/bin/scripts:$PATH"
fi
if [ -d "$HOME/.local/bin" ] ; then
export PATH="$HOME/.local/bin:$PATH"
fi
SSL Certs
This seems necessary when running Guix on a foreign distro.
if [ -d "$HOME/.guix-extra-profiles" ] ; then
export SSL_CERT_DIR="$HOME/.guix-extra-profiles/system/system/etc/ssl/certs/"
export SSL_CERT_FILE="$HOME/.guix-extra-profiles/system/system/etc/ssl/certs/ca-certificates.crt"
export GIT_SSL_CAINFO="$SSL_CERT_FILE"
export CURL_CA_BUNDLE="$SSL_CERT_FILE"
fi
Guix settings
Enable extra profiles
if [ -z "$IS_ANDROID" ] && [ -z "$NO_GUIX" ] ; then
GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
for i in $GUIX_EXTRA_PROFILES/*; do
profile=$i/$(basename "$i")
if [ -f "$profile"/etc/profile ]; then
GUIX_PROFILE="$profile"
. "$GUIX_PROFILE"/etc/profile
fi
if [ -d "$profile"/share/man ]; then
if command -v manpath; then
export MANPATH="${MANPATH:-$(manpath)}:$profile/share/man"
else
export MANPATH="${MANPATH}:$profile/share/man"
fi
fi
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$profile/share"
unset profile
done
fi
Set Jupyter config PATH. It defaults to readonly directory somewhere in Guix profile.
export JUPYTER_CONFIG_DIR=$HOME/.config/jupyter
Set a folder for my packages.
export GUIX_PACKAGE_PATH=~/guix-packages
Locale settings
export GUIX_LOCPATH=$HOME/.guix-extra-profiles/console/console/lib/locale
Somehow LibreOffice doesn’t work without the following:
export GIO_EXTRA_MODULES=""
Other package managers
Using other package managers with Guix requires some extra work.
Cask
if [ -d "$HOME/.cask" ]; then
export PATH="/home/pavel/.cask/bin:$PATH"
fi
Make flatpak apps visible to launchers:
if [ -d "$HOME/.local/share/flatpak" ]; then
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
fi
Enable Nix
if [ -f /run/current-system/profile/etc/profile.d/nix.sh ] && [ -z "$NO_GUIX" ] ; then
. /run/current-system/profile/etc/profile.d/nix.sh
fi
if [ -e /home/pavel/.nix-profile/etc/profile.d/nix.sh ] && [ -z "$NO_GUIX" ] ; then . /home/pavel/.nix-profile/etc/profile.d/nix.sh; fi
Use Guix fontconfig. Necessary for nix apps
if [ -d "$HOME/.guix-extra-profiles/desktop-misc" ] && [ -z "$NO_GUIX" ] ; then
export FONTCONFIG_PATH="$HOME/.guix-extra-profiles/desktop-misc/desktop-misc/etc/fonts"
fi
Make nix apps visible to launchers:
if [ -d "$HOME/.nix-profile" ] && [ -z "$NO_GUIX" ]; then
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
fi
npm
npm is especially cumbersome, for instance because by default it tries to install packages to /gnu/store/
.
In principle, one can set a prefix like this:
prefix=/home/pavel/.npm-packages
But I also want to use node from conda occasionally, where prefix is already set correctly. So instead of tangling the above to the ~/.npmrc
directly, I set an environment variable in the profile:
export NPM_CONFIG_USERCONFIG=$HOME/._npmrc
The variable is unset in a script in Guix.org.
Set PATH & MANPATH
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
export MANPATH="${MANPATH:-$(manpath)}:$NPM_PACKAGES/share/man"
XResources
Guix dependency |
---|
xrdb |
if [ -z "$IS_ANDROID" ]; then
xrdb ~/.Xresources
fi
OFF (OFF) Package manager paths
Turned off for now, because probably it won’t be necessary in Guix.
LaTeX
if [ -d "/usr/local/texlive/2020" ]; then
export MANPATH="/usr/local/texlive/2020/texmf-dist/doc/man:$MANPATH"
export INFOPATH="/usr/local/texlive/2020/texmf-dist/doc/info:$INFOPATH"
export PATH="/usr/local/texlive/2020/bin/x86_64-linux:$PATH"
fi
Cargo (Rust)
if [ -d "$HOME/.cargo" ] ; then
export PATH="$HOME/.cargo/bin:$PATH"
fi
RVM (Ruby)
if [ -d "$HOME/.rvm" ] ; then
export PATH="$PATH:$HOME/.rvm/bin"
fi
# if [ -d "$HOME/.gem" ]; then
# export PATH="$HOME/.gem/ruby/2.7.0/bin:$PATH"
# fi
Go
if [ -d "$HOME/go" ] ; then
export PATH="$HOME/go/bin:$PATH"
fi
ghcup (Haskell)
[ -f "/home/pavel/.ghcup/env" ] && source "/home/pavel/.ghcup/env" # ghcup-env
Perl
if [ -d "$HOME/perl5" ] ; then
PATH="/home/pavel/perl5/bin${PATH:+:${PATH}}"
PERL5LIB="/home/pavel/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/pavel/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/pavel/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/pavel/perl5"; export PERL_MM_OPT;
fi
Bash
.bash_profile
[[ -f ~/.profile ]] && . ~/.profile
[[ -f ~/.bashrc ]] && . ~/.bashrc
.bashrc
My .bashrc
, which has pieces from the default one in Guix & Manjaro, as well some mine settings.
Startup & environment
Export ‘SHELL’ to child processes. Programs such as ‘screen’ honor it and otherwise use /bin/sh.
export SHELL
We are being invoked from a non-interactive shell. If this is an SSH session (as in “ssh host command”), source /etc/profile, so we get PATH and other essential variables.
if [[ $- != *i* ]]
then
[[ -n "$SSH_CLIENT" && -f "/etc/bashrc" ]] && source /etc/profile
return
fi
If termux-setup-storage
is available, then we’re running inside termux. It is necessary to source ~/.profile
manually.
if command -v termux-setup-storage > /dev/null; then
if [[ -z "$IS_ANDROID" ]]; then
source ~/.profile
fi
fi
Source the system-wide file
if [[ -f "/etc/bashrc" ]]; then
source /etc/bashrc
fi
Guix dependency |
---|
xhost |
Allow other users to access X server. Necessary for stuff like aw-watcher-window.
xhost +local:root > /dev/null 2>&1
Set manpager to bat
export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'"
eat integration
[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && source "$EAT_SHELL_INTEGRATION_DIR/bash"
Launch fish
Launch fish shell unless bash itself is launched from fish.
use_fish=true
if [[ $(ps --no-header --pid=$PPID --format=cmd) != "fish" && ${use_fish} && $(command -v fish) ]]
then
exec fish
fi
The rest of .bashrc
is not executed if fish was launched.
Colors
Setting for colors, packed in the default .bashrc
in Manjaro
use_color=true
# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
if ${use_color} ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
else
PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi
unset use_color safe_term match_lhs sh
Settings
Some general bash settings.
References:
complete -cf sudo # Sudo autocompletion
shopt -s checkwinsize # Check windows size after each command
shopt -s expand_aliases # Aliases
shopt -s autocd # Cd to directory just by typing its name (without cd)
History control
shopt -s histappend
export HISTCONTROL=ignoredups:erasedups
HISTSIZE=
HISTFILESIZE=
Autocompletions
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
if [ -d "/usr/share/fzf" ]; then
source /usr/share/fzf/completion.bash
source /usr/share/fzf/key-bindings.bash
fi
Aliases
alias v="vim"
if command -v exa > /dev/null; then
alias ls="exa --icons"
alias ll="exa -lah --icons"
else
alias ll='ls -lah'
fi
alias q="exit"
alias c="clear"
alias ci="init_mamba"
alias ca="micromamba activate"
alias cii="export INIT_MAMBA=true && init_mamba"
if [[ ! -z "$SIMPLE" ]]; then
unalias ls
alias ll="ls -lah"
fi
Micromamba
I’ve moved from conda to micromamba because it’s faster.
managed by ‘mamba init’ !!!
Yeah, tell this to yourself
init_mamba () {
export MAMBA_EXE="/home/pavel/.guix-extra-profiles/dev/dev/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/pavel/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
if [ -f "/home/pavel/micromamba/etc/profile.d/micromamba.sh" ]; then
. "/home/pavel/micromamba/etc/profile.d/micromamba.sh"
else
export PATH="/home/pavel/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
fi
fi
unset __mamba_setup
}
if [[ ! -z "$INIT_MAMBA" ]]; then
init_mamba
fi
Starship
if [[ -z "$SIMPLE" && "$TERM" != "dumb" ]]; then
eval "$(starship init bash)"
fi
Yandex Cloud
init_yc () {
# The next line updates PATH for Yandex Cloud CLI.
if [ -f '/home/pavel/yandex-cloud/path.bash.inc' ]; then source '/home/pavel/yandex-cloud/path.bash.inc'; fi
# The next line enables shell command completion for yc.
if [ -f '/home/pavel/yandex-cloud/completion.bash.inc' ]; then source '/home/pavel/yandex-cloud/completion.bash.inc'; fi
}
Fish
Guix dependency | Description |
---|---|
fish | An alternative non POSIX-compliant shell |
Fish shell is a non-POSIX-compliant shell, which offers some fancy UI & UX features.
Launch starship
if [ "$TERM" != "dumb" ]; and type -q starship;
starship init fish | source
else
function fish_prompt -d "Write out the prompt"
printf '%s@%s %s%s%s > ' $USER $hostname \
(set_color $fish_color_cwd) (basename (pwd)) (set_color normal)
end
end
Enable vi keybindings & aliases. The alias syntax is the same as in bash, so it’s just a noweb reference to .bashrc
.
if [ "$IS_VTERM" != "1" ];
fish_vi_key_bindings
else
fish_default_key_bindings
end
alias q="exit"
alias c="clear"
if type -q exa
alias ls="exa --icons"
alias ll="exa -lah --icons"
else
alias ll="ls -h"
end
Guix dependency |
---|
dt-colorscripts |
Launch a random DT’s colorscript unless ran inside tmux or Emacs.
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS"; and type -q colorscript
colorscript random
end
Suppress fish greeting
set fish_greeting
Micromamba
First, a function to initialize micromamba.
function init_mamba
set -gx MAMBA_EXE "/home/pavel/.guix-extra-profiles/dev/dev/bin/micromamba"
set -gx MAMBA_ROOT_PREFIX "/home/pavel/micromamba"
$MAMBA_EXE shell hook --shell fish --prefix $MAMBA_ROOT_PREFIX | source
end
if test -n "$INIT_MAMBA";
init_mamba
end
alias ca="micromamba activate"
alias ci="init_mamba"
alias cii="export INIT_MAMBA=true && init_mamba"
Then, check if launched from Emacs with environment activated.
# if test -n "$EMACS_CONDA_ENV";
# conda activate $EMACS_CONDA_ENV
# end
Colors
Fish seems to have hardcoded colorcodes in some color settings. I set these to base16 colors, so they would match Xresources.
set fish_color_command cyan
set fish_color_comment green
set fish_color_end black
set fish_color_error red
set fish_color_escape yellow
set fish_color_operator yellow
set fish_color_param magenta
set fish_color_quote green
set fish_color_redirection yellow
Keybindings
bind -M insert \el forward-char
bind -M insert \eh backward-char
bind -M insert \ew forward-word
bind -M insert \eb backward-word
Functions
A small function to open the file with $EDITOR
.
function e
eval $EDITOR $argv
end
direnv
if type -q direnv
direnv hook fish | source
end
atuin
if type -q atuin
set -gx ATUIN_NOBIND "true"
atuin init fish | source
bind \cr _atuin_search
bind -M insert \cr _atuin_search
end
Nushell
Guix dependency |
---|
nushell-bin |
A structured shell. I don’t use it as of now, but perhaps one day.
Starship prompt
Guix dependency | Description |
---|---|
starship-bin | my prompt of choice |
Starship is a nice cross-shell prompt, written in Rust.
References:
[character]
success_symbol = "[> ](bold green)"
error_symbol = "[✕ ](bold red)"
vicmd_symbol = "[ᐊ ](bold green)"
[aws]
symbol = " "
# [battery]
# full_symbol = ""
# charging_symbol = ""
# discharging_symbol = ""
[conda]
symbol = " "
[cmd_duration]
min_time = 500
format = " [$duration]($style) "
[docker_context]
symbol = " "
[elixir]
symbol = " "
[elm]
symbol = " "
[git_branch]
symbol = " "
truncation_length = 20
[golang]
symbol = " "
# [haskell]
# symbol = " "
[hg_branch]
symbol = " "
[java]
symbol = " "
[julia]
symbol = " "
[memory_usage]
symbol = " "
[nim]
symbol = " "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[package]
symbol = " "
disabled = true
[php]
symbol = " "
[python]
symbol = " "
[ruby]
symbol = " "
[rust]
symbol = " "
Tmux
Guix dependency |
---|
tmux |
python-tmuxp |
tmux is my terminal multiplexer of choice.
It provides pretty sane defaults, so the config is not too large. I rebind the prefix to C-a
though.
Term settings
I have no idea how and why these statements work.
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",*256col*:Tc"
History limit.
set -g history-limit 20000
Keybindings
Enable vi keys and mouse.
set-window-option -g mode-keys vi
set-option -g xterm-keys on
set-option -g mouse on
set -sg escape-time 10
Change prefix from C-b
to C-a
.
unbind C-b
set -g prefix C-a
bind C-a send-prefix
Vi-like keybindings to manage panes & windows.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind s split-window
bind v split-window -h
bind-key n new-window
bind-key t next-window
bind-key T previous-window
Reload the config.
bind r source-file ~/.tmux.conf
Copy to clipboard
Guix dependency |
---|
xclip |
Make tmux copy to clipboard as well
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
UI
On tmuxline.vim plugin and palenight theme for vim-airline.
, I had generated the first version of this following withThen I adapted it to use the current Emacs theme.
set -g status-justify "centre"
set -g status "on"
set -g status-left-style "none"
set -g message-command-style "fg=<<get-color(name="fg")>>,bg=<<get-color(name="bg-other")>>"
set -g status-right-style "none"
set -g pane-active-border-style "fg=<<get-color(name="blue")>>"
set -g status-style "none,bg=<<get-color(name="bg-other")>>"
set -g message-style "fg=<<get-color(name="fg")>>,bg=<<get-color(name="bg-other")>>"
set -g pane-border-style "fg=<<get-color(name="blue")>>"
set -g status-right-length "100"
set -g status-left-length "100"
setw -g window-status-activity-style "none,fg=<<get-color(name="blue")>>,bg=<<get-color(name="bg-other")>>"
setw -g window-status-separator ""
setw -g window-status-style "none,fg=<<get-color(name="fg")>>,bg=<<get-color(name="bg-other")>>"
set -g status-left "#[fg=<<get-fg-for-color(name="blue")>>,bg=<<get-color(name="blue")>>] #S #[fg=<<get-color(name="blue")>>,bg=<<get-color(name="light-blue")>>,nobold,nounderscore,noitalics]#[fg=<<get-fg-for-color(name="light-blue")>>,bg=<<get-color(name="light-blue")>>] #W #[fg=<<get-color(name="light-blue")>>,bg=<<get-color(name="bg-other")>>,nobold,nounderscore,noitalics]"
set -g status-right "%-H:%M #[bg=<<get-color(name="bg-other")>>,fg=<<get-color(name="light-blue")>>,nobold,nounderscore,noitalics]#[fg=<<get-fg-for-color(name="light-blue")>>,bg=<<get-color(name="light-blue")>>] %a, %b %d #[bg=<<get-color(name="light-blue")>>,fg=<<get-color(name="blue")>>,nobold,nounderscore,noitalics]#[fg=<<get-fg-for-color(name="blue")>>,bg=<<get-color(name="blue")>>] #H "
setw -g window-status-format "#[fg=<<get-color(name="bg-other")>>,bg=<<get-color(name="light-blue")>>,nobold,nounderscore,noitalics]#[fg=<<get-fg-for-color(name="light-blue")>>,bg=<<get-color(name="light-blue")>>] #I #W #[align=left] #[fg=<<get-color(name="light-blue")>>,bg=<<get-color(name="bg-other")>>,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=<<get-color(name="bg-other")>>,bg=<<get-color(name="blue")>>,nobold,nounderscore,noitalics]#[fg=<<get-fg-for-color(name="blue")>>,bg=<<get-color(name="blue")>>] #I #W #[fg=<<get-color(name="blue")>>,bg=<<get-color(name="bg-other")>>,nobold,nounderscore,noitalics]"
Source the line config:
source ~/.tmux.line.conf
Alacritty
Guix dependency |
---|
alacritty |
Alacritty is a GPU-accelerated terminal emulator. I haven’t found it to be an inch faster than st, but yml
configuration is way more convenient than patches.
References:
decorations: none
font:
normal:
family: JetBrainsMono Nerd Font
style: Regular
size: 10
env:
TERM: xterm-256color
colors:
primary:
background: '<<get-color(name="bg")>>'
foreground: '<<get-color(name="fg")>>'
normal:
black: '<<get-color(name="black")>>'
red: '<<get-color(name="red")>>'
green: '<<get-color(name="green")>>'
yellow: '<<get-color(name="yellow")>>'
blue: '<<get-color(name="blue")>>'
magenta: '<<get-color(name="magenta")>>'
cyan: '<<get-color(name="cyan")>>'
white: '<<get-color(name="white")>>'
bright:
Black: '<<get-color(name="light-black")>>'
Red: '<<get-color(name="light-red")>>'
Green: '<<get-color(name="light-green")>>'
Yellow: '<<get-color(name="light-yellow")>>'
Blue: '<<get-color(name="light-blue")>>'
Magenta: '<<get-color(name="light-magenta")>>'
Cyan: '<<get-color(name="light-cyan")>>'
White: '<<get-color(name="light-white")>>'
window:
padding:
x: 0
y: 0
dynamic_padding: true
opacity: 1
key_bindings:
- { key: Paste, action: Paste }
- { key: Copy, action: Copy }
- { key: L, mods: Control, action: ClearLogNotice }
- { key: L, mods: Control, mode: ~Vi|~Search, chars: "\x0c" }
- { key: PageUp, mods: Shift, mode: ~Alt, action: ScrollPageUp, }
- { key: PageDown, mods: Shift, mode: ~Alt, action: ScrollPageDown }
- { key: Home, mods: Shift, mode: ~Alt, action: ScrollToTop, }
- { key: End, mods: Shift, mode: ~Alt, action: ScrollToBottom }
# Turn off vi mode
- { key: Space, mods: Shift|Control, mode: ~Search, action: ReceiveChar }
# (Windows, Linux, and BSD only)
- { key: V, mods: Control|Shift, mode: ~Vi, action: Paste }
- { key: C, mods: Control|Shift, action: Copy }
- { key: F, mods: Control|Shift, mode: ~Search, action: ReceiveChar }
- { key: B, mods: Control|Shift, mode: ~Search, action: ReceiveChar }
- { key: Insert, mods: Shift, action: PasteSelection }
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Equals, mods: Control, action: IncreaseFontSize }
- { key: Plus, mods: Control, action: IncreaseFontSize }
- { key: NumpadAdd, mods: Control, action: IncreaseFontSize }
- { key: Minus, mods: Control, action: DecreaseFontSize }
- { key: NumpadSubtract, mods: Control, action: DecreaseFontSize }
Bottom
Guix dependency | Description |
---|---|
bottom-bin | resource monitor |
bottom is a TUI system monitor.
See the default config for the avaliable options.
(if (my/light-p) "default-light" "default")
[flags]
hide_table_gap = true # Remove space in tables
color = "<<bottom-theme()>>"
process_command = true
[processes]
columns = ["PID", "State", "Name", "CPU%", "Mem%", "R/s", "W/s", "User"]
Atuin
atuin is a tool that replaces shell history with a SQLite database, providing some additional functionality.
See config reference.
update_check = false
enter_accept = true
keymap_mode = "vim-insert"
Various console applications
Guix dependency | Description |
---|---|
ncurses | Provides stuff like clear |
exa | ls replacement, written in Rust |
bat | cat clone with syntax highlighting |
htop | Interactive process viewer |
nethogs | A tool to group processed by used bandwidth |
osync | rsync wrapper |
neofetch | Fetch system info |
fzf | fuzzy finder |
p7zip | archiver |
password-store | CLI password manager |
zip | |
unzip | |
jmtpfs | A tool to mount MTP devices (e.g. Android) |
tokei | Count lines of code |
sshfs | Mount stuff over SSH |
lftp | File transfer |
git-lfs | |
glibc-locales | |
direnv | |
jless-bin | JSON viewer |
megacmd | mega.nz client |
ncdu | disk usage analyzer |
openssl | |
aria2 | Download tool |
ripgrep config
Occasionally I can’t exclude certain files from ripgrep via the VCS settings, so here is a simple config to ignore certain files globally.
--ignore-file=/home/pavel/.config/ripgrep/ripgrepignore
The ignore file:
*.ts.snap
By default, ripgrep doesn’t read any configs, so it is necessary to set the RIPGREP_CONFIG_PATH
variable in the .profile.
Misc scripts
nt
- exec command with a finished notification
Usage:
nt <command>
command="$@"
if [ ! -z "$command" ]; then
start_time="$(date -u +%s)"
$command
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
notify-send "Terminal" "Command\n$command\nexecuted in $elapsed seconds"
else
notify-send "Terminal" "Command execution complete"
fi
autocommit
A script to perform automatic commits in a repository. I use it to sync my org directory and password store. I guess it’s not how git is intended to be used, but it works for me.
Usage:
autocommit <repository> [-F]
Environment:
Variable | Description | Default value |
---|---|---|
TIMEOUT_MIN |
Default timeout | 60 |
Here’s roughly what the script is doing:
- If there is a merge conflict, notify
- If there were changed files in the last
TIMEOUT_MIN
minutes, commit - Fetch
- If there were changes in the last
TTMEOUT_MIN
, merge (usually the merge is just fast-forward) - If the fetch was successful & the merge was either successful or delayed because of changes in the last
TIMEOUT_MIN
, push - Send a notification about the events above
- Send a separate notification if there is a merge conflict
TIMEOUT_MIN=${TIMEOUT_MIN:-60}
export DISPLAY=:0
cd "$1"
TIMESTAMP=$(date +%s)
LAST_COMMIT_TIMESTAMP=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%s)
RECENTLY_CHANGED_NUM=$(find . -not -path '*/\.*' -mmin -$TIMEOUT_MIN | wc -l)
CHANGED_NUM=$(git status --porcelain | wc -l)
COMMITED="No"
PUSHED="No"
FETCHED="No"
MERGED="No"
notify () {
if command -v notify-send; then
notify-send -u ${LEVEL:-normal} "$1" "$2"
else
echo "$1" "$2"
fi
}
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
if [[ ($RECENTLY_CHANGED_NUM -eq 0 || $2 = "-F") && $CHANGED_NUM -gt 0 ]]; then
read -r -d '' MESSAGE << EOM
Autocommit $(date -Iminutes)
Hostname: $(hostname)
EOM
git add -A
git commit -m "$MESSAGE"
COMMITED="Yes"
fi
NEED_TO_PUSH=$(git log origin/master..HEAD | wc -l)
git fetch && FETCHED="Yes" || FETCHED="No"
if [[ $RECENTLY_CHANGED_NUM -gt 0 && $2 != '-F' ]]; then
MERGED="Waiting"
fi
if [[ ($RECENTLY_CHANGED_NUM -eq 0 || $2 = "-F") && $FETCHED = "Yes" ]]; then
MERGE_OUT=$(git merge origin/master) && MERGED="Yes" || MERGED="No"
fi
if [[ $NEED_TO_PUSH -gt 0 && ($MERGED = "Yes" || $MERGED = "Waiting") ]]; then
git push origin && PUSHED="Yes" || PUSHED="No"
fi
if [[ $PUSHED = "Yes" || $COMMITED = "Yes" || ($MERGED = "Yes" && $MERGE_OUT != "Already up to date.")]]; then
read -r -d '' NOTIFICATION << EOM
Commited: $COMMITED
Fetched: $FETCHED
Merged: $MERGED
Pushed: $PUSHED
EOM
notify "Autocommit $(pwd)" "$NOTIFICATION"
fi
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
mcron
job:
(job "0 * * * *" "autocommit /home/pavel/30-39\\ Life/32\\ org-mode/")
(job "0,15,30,45 * * * *" "autocommit ~/.password-store")
Guix settings
(my/format-guix-dependencies)
(specifications->manifest
'(
<<packages()>>))
Android notes
SSH instructions: https://wiki.termux.com/wiki/Remote_Access
Installation
First, run
pkg update
Then install the following packages:
Package |
---|
yadm |
gnupg |
git |
which |
starship |
atuin |
vim |
tmux |
emacs |
make |
clang |
ripgrep |
cmake |
gperf |
iproute2 |
wakatime-cli |
Run
termux-setup-storage
Then import ssh and gpg keys. Set the main key to ultimate trust (gpg --edit-key ...
, then trust
).
Then:
yadm clone git@github.com/SqrtMinusOne/dotfiles.git
Install nerd fonts: https://github.com/notflawffles/termux-nerd-installer
git clone https://github.com/notflawffles/termux-nerd-installer.git
cd termux-nerd-installer
make install
Clone passwords.git
to ~/.password-store/
, org-mode.git
to ~/30-39 Life/32 org-mode
.
Create the file ~/.android-profile
with contents:
export ANDROID_NAME=<name>
Then emacs
should launch fine.
Also:
- cleanup
$PREFIX/etc/motd
to remove hello message.
Installation of DT’s colorscripts:
git clone https://gitlab.com/dwt1/shell-color-scripts.git
cd shell-color-scripts
Apply a patch:
--- a/colorscript.sh
+++ b/colorscript.sh
@@ -2,7 +2,7 @@
# Simple CLI for shell-color-scripts
-DIR_COLORSCRIPTS="/opt/shell-color-scripts/colorscripts"
+DIR_COLORSCRIPTS="$PREFIX/opt/shell-color-scripts/colorscripts"
LS_CMD="$(command -v ls)"
fmt_help=" %-20s\t%-54s\n"
list_colorscripts="$($LS_CMD "${DIR_COLORSCRIPTS}" | cut -d ' ' -f 1 | nl)"
sudo mkdir -p $PREFIX/opt/shell-color-scripts/colorscripts || return 1
sudo cp -rf colorscripts/* $PREFIX/opt/shell-color-scripts/colorscripts
sudo cp colorscript.sh $PREFIX/bin/colorscript