diff options
| -rw-r--r-- | .kshrc | 133 | ||||
| -rw-r--r-- | .profile | 27 |
2 files changed, 160 insertions, 0 deletions
@@ -0,0 +1,133 @@ +# +# .kshrc - oksh - Public domain Korn shell startup file +# +# See also oksh(1) + +# If helpers exist +_exists() { + type $1 > /dev/null 2>&1 +} + +# Don't do anything if we don't have a prompt (not an interactive shell) +[[ $- != *i* ]] && return || [ -z "$PS1" ] && return + +# Don't let \^{}d logout +set -o ignoreeof + +# Export all +set -o allexport + +# Setup history +HISTFILE=$HOME/.ksh_history +HISTSIZE=10000 +HISTCONTROL=ignoredups:ignorespace + +# Some useful aliases +# If btop is installed then alias top to btop +_exists btop && alias top="/usr/local/bin/btop" +alias ls='ls --color=auto -hv' +alias config='/usr/local/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' + +_exists bat && alias cat='bat --paging=never' +alias wanip='dig @resolver4.opendns.com myip.opendns.com +short' + +# Alias to stop foot terminal confusing ssh +if [ "$TERM" = "foot" ]; then + alias ssh='TERM=linux ssh' +fi + +# Simple, lightweight git prompt for oksh: if inside a git repo, adds the +# branch name to PS1. +__get_current_git_branch_name() { + branch_name="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" && \ + [ -n "$branch_name" ] && \ + echo -en " $branch_name" +} + +# Pager +if _exists less; then + PAGER=less + LESSHISTFILE=- +# # -I ignore case +# # -R colored output +# # -X don't clear on exit +# # -Ps string prompt + # LESS='-IRXPs %lt-%lb (%Pt-%Pb \%) ░ %bt-%bbb ░ %f ░▒▓' + LESS='-IRX' + export PAGER LESSHISTFILE LESS +fi + +# Colored man pages +man() { + sh -c "man '$@' | col -bx | bat -l man" +} + +# Set prompt: ``username@hostname directory $ '' +PS1="\[\e[1;32m\]\u@\h \[\e[1;34m\]\w\[\e[0m\] \[\e[1;31m\]\$(__get_current_git_branch_name)\[\e[0m\] $ " + +COLORTERM="truecolor" +EDITOR="vim" +VISUAL="vim" +STARSHIP_CONFIG=~/.config/starship/config.toml +BROWSER="qutebrowser" +XDG_CONFIG_HOME="$HOME/.config" +WEECHAT_HOME="$XDG_CONFIG_HOME/weechat" +MOZ_ENABLE_WAYLAND=1 +XDG_SESSION_TYPE=wayland +GDK_BACKEND=wayland +# export QT_QPA_PLATFORM=wayland +# export XKB_DEFAULT_LAYOUT=us +# export LANG="en_US.UTF-8" +# export LC_ALL="en_US.UTF-8" +TERMINAL="foot" +SAL_USE_VCLPLUGIN=gtk3 +# To make Qutebrowser run under FreeBSD Wayland +QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" + +# Search path for cd(1) +CDPATH=:$HOME + +# Always add below to allow gpg-agent to work correctly +GPG_TTY=$(tty) + +# Enable the use of ssh-agent +if [ ! -f "$XDG_RUNTIME_DIR/ssh-agent.env" ]; then + pkill -f ssh-agent +fi +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" +fi +if [ ! -f "$SSH_AUTH_SOCK" ]; then + . "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null +fi + +# Completions + +# Display possible interfaces on this machine for ifconfig +set -A complete_ifconfig_1 -- $(ifconfig | grep ^[a-z] | cut -d: -f1) + +# Remote access +_SSH_HOSTS=$(awk '/^host/{ print $2 }' ~/.ssh/config) +set -A complete_ssh -- $_SSH_HOSTS + +set -A complete_pkg -- autoremove clean install search update upgrade version +# Git completion +set -A complete_git -- \ + $(git --list-cmds=main) \ + $(git config --get-regexp ^alias\. | awk -F '[\. ]' '{ print $2 }') +set -A complete_config -- add commit diff push status +set -A complete_service_2 -- onereload onerestart onestop restart start status stop +set -A complete_service_1 -- $(service -l) +set -A complete_zfs -- clone create diff get jail list mount promote receive set send share snapshot upgrade +set -A complete_zpool -- add attach checkpoint clear create detach export get history import iostat list offline \ +online scrub set split status upgrade + +# Turn off export all +set +o allexport + +# Set vi mode +set -o vi + +if [ "$(tty)" = "/dev/ttyv0" ]; then + exec dbus-run-session mango > /dev/null 2>&1 +fi diff --git a/.profile b/.profile new file mode 100644 index 0000000..de7eb6f --- /dev/null +++ b/.profile @@ -0,0 +1,27 @@ +# +# .profile - oksh - Public domain Korn shell startup script for login shells +# +# see also oksh(1), environ(7). +# + +# These are normally set through /etc/login.conf. You may override them here +# if wanted. +# PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH +PATH=$PATH:$HOME/.local/bin; export PATH + +MANPATH=$HOME/.local/share/man/:$MANPATH; export MANPATH + +EDITOR='nvim'; export EDITOR +PAGER='less'; export PAGER + +SSH_ASKPASS='/home/justine/.local/bin/ssh-askpass.sh'; export SSH_ASKPASS +SSH_ASKPASS_REQUIRE=prefer; export SSH_ASKPASS_REQUIRE + +# Set ENV to a file invoked each time sh is started for interactive use. +ENV=$HOME/.kshrc; export ENV + +# Query terminal size; useful for serial lines. +if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi + +# Display a random cookie on each login. +if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi |
