From e42c989d6def401dd893a73cef5d5deac8b42778 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 16 Nov 2018 01:34:16 -0500 Subject: prefer xdg basedir specification directories --- config/sh/aliases | 42 +++++++++++++ config/sh/cdhist.sh | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++ config/sh/env | 25 ++++++++ config/sh/functions | 20 ++++++ config/sh/fzf | 1 + 5 files changed, 262 insertions(+) create mode 100644 config/sh/aliases create mode 100644 config/sh/cdhist.sh create mode 100644 config/sh/env create mode 100644 config/sh/functions create mode 160000 config/sh/fzf (limited to 'config/sh') diff --git a/config/sh/aliases b/config/sh/aliases new file mode 100644 index 0000000..c764f38 --- /dev/null +++ b/config/sh/aliases @@ -0,0 +1,42 @@ +# improvements to common commands {{{ +alias ls="exa --group-directories-first --time-style=long-iso --git --color-scale" +alias ll="ls -l" +alias grep="grep --color=auto" +alias rm="rm -i" +alias cp="cp -i" +alias mv="mv -i" +alias bc="bc -lq" +alias ag="ag --pager=less --smart-case" +type forkprove > /dev/null 2>&1 && alias prove="forkprove" +type tput > /dev/null 2>&1 && alias reset="tput reset" +type sudo-askpass > /dev/null 2>&1 && alias sudo="sudo -A" +# }}} +# games {{{ +alias nao="env TERM=rxvt telnet nethack.alt.org" +alias cao="env TERM=rxvt /usr/bin/ssh -C -i $HOME/.ssh/cao_key joshua@crawl.akrasiac.org" +alias cdo="ssh -C -i $HOME/.ssh/cao_key crawl@crawl.develz.org" +# }}} +# termcast {{{ +alias tc="telnet termcast.org" +# }}} +# shells {{{ +alias bishamon='ssh doy@bishamon' +alias tozt="ssh doy@tozt.net" +# }}} +# tmux sessions {{{ +alias main='tmux new -As main' +alias chat='tmux new -As chat' +alias work='tmux new -As work' +alias docs='tmux new -As docs' +alias misc='tmux new -As misc' +# }}} +# other {{{ +alias pm="find lib -type f" +alias v="vim --cmd 'let g:startify_disable_at_vimenter = 1' -c 'call feedkeys(\"t\")'" +alias g="vim --cmd 'let g:startify_disable_at_vimenter = 1' -c 'call feedkeys(\"ff\")'" +alias utc="env TZ=UTC date" +alias pd="perldoc" +alias pc="p -c" +# }}} + +# vim:ft=sh:fdm=marker diff --git a/config/sh/cdhist.sh b/config/sh/cdhist.sh new file mode 100644 index 0000000..d67d2e9 --- /dev/null +++ b/config/sh/cdhist.sh @@ -0,0 +1,174 @@ +### cdhist.sh +### +### Copyright (c) 2001 Yusuke Shinyama +### +### Permission to use, copy, modify, distribute this software and +### its documentation for any purpose is hereby granted, provided +### that existing copyright notices are retained in all copies and +### that this notice is included verbatim in any distributions. +### This software is provided ``AS IS'' without any express or implied +### warranty. +### + +### WARNING: THIS SCRIPT IS FOR GNU BASH ONLY! + +### What is this? +### +### Cdhist adds 'web-browser like history' to your bash shell. +### Every time you change the current directory it records the directory +### you can go back by simply typing a short command such as '-' or '+', +### just like clicking web-browsers's 'back' button. +### It's more convenient than using directory stacks when +### you walk around two or three directories. +### + +### Usage +### +### Just call this file from your .bashrc script. +### The following commands are added. +### +### cd [pathname] +### Go to the given directory, or your home directory if +### pathname is omitted. This overrides the original command. +### You can use it by typing '\cd'. +### +### + [n] +### 'Forward' button. Go to the n'th posterior directory in the history. +### Go to the next directory if the number is omitted. +### +### - [n] +### 'Back' button. Go to the n'th prior directory in the history. +### Go to the previous directory if the number is omitted. +### +### = [n] +### Show histories with directory numbers. +### +### A directory number shows the index to the current directory +### in the history. The current directory always has directory number 0. +### For prior directories, a negative number is given. +### For posterior directories, a positive number is given. +### +### cdhist_reset +### Clear the cd history. +### + +### Example +### +### /home/yusuke:$ . cdhist.sh +### /home/yusuke:$ cd /tmp +### /tmp:$ cd /usr/bin +### /usr/bin:$ cd /etc +### /etc:$ - +### /usr/bin:$ - +### /tmp:$ + +### /usr/bin:$ = +### -2 ~ +### -1 /tmp +### 0:/usr/bin +### 1 /etc +### /usr/bin:$ - 2 +### /home/yusuke:$ +### + + +CDHIST_CDQMAX=10 +declare -a CDHIST_CDQ + +function cdhist_reset { + CDHIST_CDQ=("$PWD") +} + +function cdhist_disp { + echo "$*" | sed "s $HOME ~ g" +} + +function cdhist_add { + CDHIST_CDQ=("$1" "${CDHIST_CDQ[@]}") +} + +function cdhist_del { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + local i=${1-0} + if [ ${#CDHIST_CDQ[@]} -le 1 ]; then return; fi + for ((; i<${#CDHIST_CDQ[@]}-1; i++)); do + CDHIST_CDQ[$i]="${CDHIST_CDQ[$((i+1))]}" + done + unset CDHIST_CDQ[$i] +} + +function cdhist_rot { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + local i q + declare -a q + for ((i=0; i<$1; i++)); do + q[$i]="${CDHIST_CDQ[$(((i+$1+$2)%$1))]}" + done + for ((i=0; i<$1; i++)); do + CDHIST_CDQ[$i]="${q[$i]}" + done +} + +function cdhist_cd { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + local i f=0 + builtin cd "$@" || return 1 + for ((i=0; i<${#CDHIST_CDQ[@]}; i++)); do + if [ "${CDHIST_CDQ[$i]}" = "$PWD" ]; then f=1; break; fi + done + if [ $f -eq 1 ]; then + cdhist_rot $((i+1)) -1 + elif [ ${#CDHIST_CDQ[@]} -lt $CDHIST_CDQMAX ]; then + cdhist_add "$PWD" + else + cdhist_rot ${#CDHIST_CDQ[@]} -1 + CDHIST_CDQ[0]="$PWD" + fi +} + +function cdhist_history { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + local i d + if [ $# -eq 0 ]; then + for ((i=${#CDHIST_CDQ[@]}-1; 0<=i; i--)); do + cdhist_disp " $i ${CDHIST_CDQ[$i]}" + done + elif [ "$1" -lt ${#CDHIST_CDQ[@]} ]; then + d=${CDHIST_CDQ[$1]} + if builtin cd "$d"; then + cdhist_rot $(($1+1)) -1 + else + cdhist_del $1 + fi + cdhist_disp "${CDHIST_CDQ[@]}" + fi +} + +function cdhist_forward { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + cdhist_rot ${#CDHIST_CDQ[@]} -${1-1} + if ! builtin cd "${CDHIST_CDQ[0]}"; then + cdhist_del 0 + fi + cdhist_disp "${CDHIST_CDQ[@]}" +} + +function cdhist_back { + [[ -n $ZSH_VERSION ]] && setopt localoptions && setopt ksharrays + cdhist_rot ${#CDHIST_CDQ[@]} ${1-1} + if ! builtin cd "${CDHIST_CDQ[0]}"; then + cdhist_del 0 + fi + cdhist_disp "${CDHIST_CDQ[@]}" +} + + +if [ ${#CDHIST_CDQ[@]} = 0 ]; then cdhist_reset; fi + + +### Aliases +### + +function cd { cdhist_cd "$@"; } +function + { cdhist_forward "$@"; } +function - { cdhist_back "$@"; } +function = { cdhist_history "$@"; } diff --git a/config/sh/env b/config/sh/env new file mode 100644 index 0000000..218ddde --- /dev/null +++ b/config/sh/env @@ -0,0 +1,25 @@ +export GPG_TTY=$(tty) +export MANPAGER="$HOME/.bin/vimmanpager" +export PERLDOC_PAGER="$HOME/.bin/vimmanpager" +export EDITOR=$(/usr/bin/which vim) +ssh="${HOME}/.bin/$(hostname)/ssh" +if [ -x "$ssh" ]; then + export GIT_SSH="$ssh" + export RSYNC_RSH="$ssh" +fi +if type sudo-askpass > /dev/null 2>&1; then + SUDO_ASKPASS=$(command -v sudo-askpass) + export SUDO_ASKPASS +fi +export TEXINPUTS=".:$HOME/.config/tex:" +export LESS='-QR' +export PERL_CPANM_OPT="-q --mirror http://mirrors.kernel.org/cpan/ --mirror http://cpan.metacpan.org/ --prompt" +export FZF_DEFAULT_OPTS="--reverse --inline-info --bind=tab:down,shift-tab:up,change:top" +export FZF_DEFAULT_COMMAND="ag --hidden -l ." +export FANCY_PROMPT_COLORS="user_doy=bright_blue,host_st-doy1=bright_white,host_bishamon=blue,host_tozt=bright_yellow,host_hush=bright_black,host_partofme=magenta" +export PASSWORD_STORE_X_SELECTION=primary +type brew > /dev/null 2>&1 && export PATH="/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/sbin:$PATH" +type brew > /dev/null 2>&1 && export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:/usr/local/opt/findutils/libexec/gnuman:$MANPATH" +export NOTMUCH_CONFIG="${XDG_CONFIG_HOME:-${HOME}/.config}/notmuch/config" + +# vim:ft=sh: diff --git a/config/sh/functions b/config/sh/functions new file mode 100644 index 0000000..d6068e0 --- /dev/null +++ b/config/sh/functions @@ -0,0 +1,20 @@ +function perldoc { + # XXX bash specific + if type cpandoc > /dev/null 2>&1; then + cpandoc "$@" + else + command perldoc "$@" + fi +} + +function cdu { + local root + root="$(git rev-parse --show-superproject-working-tree 2>/dev/null)" + if [ -n "$root" ]; then + cd "$root" + else + cd "$(git rev-parse --show-toplevel)" + fi +} + +# vim:ft=sh: diff --git a/config/sh/fzf b/config/sh/fzf new file mode 160000 index 0000000..d4ed955 --- /dev/null +++ b/config/sh/fzf @@ -0,0 +1 @@ +Subproject commit d4ed955aee08a1c2ceb64e562ab4a88bdc9af8f0 -- cgit v1.2.3-54-g00ecf