summaryrefslogtreecommitdiffstats
path: root/kshrc
blob: 997dbefd991634842467534ac5fbb992cc70bb3b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# from https://www.c0ffee.net/blog/openbsd-on-a-laptop/#x11
# use vim if it's installed, vi otherwise
# case "$(command -v vim)" in
#   */vim) VIM=vim ;;
#   *)     VIM=vi  ;;
# esac

export EDITOR=$VIM
export FCEDIT=$EDITOR
export PAGER=less
export LESS='-iMRS -x2'
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export CLICOLOR=1
#export LSCOLORS=Gxfxcxdxbxegedabagacad
#export PATH=$PATH:/usr/local/jdk-11/bin
export PATH=$PATH:/home/lemon/.fzf/bin
export PATH=/home/lemon/bin:$PATH
HISTFILE=$HOME/.ksh_history
HISTSIZE=20000

# emacs mode gives you the familiar Ctrl-A, Ctrl-E, etc
set -o emacs

# use colorls if it's installed, plain old ls otherwise
if command -v colorls > /dev/null ; then
  LS='colorls'
else
  LS='ls'
fi
command -v neomutt > /dev/null && alias mutt='neomutt'
alias gac="git commit -am 'update' && git push origin master"

if [ -e /home/lemon/.ksh_aliases ]; then
. /home/lemon/.ksh_aliases
fi

# set environment variables for bookmark.py
if [ -e /home/lemon/.bookmarkpy ]; then
. /home/lemon/.bookmarkpy
fi

# nice colored prompt that also sets xterm title
_XTERM_TITLE='\[\033]0;\u@\h:\w\007\]'
_PS1_CLEAR='\[\033[0m\]'
_PS1_BLUE='\[\033[34m\]'
case "$(id -u)" in
  0) _PS1_COLOR='\[\033[1;31m\]' ;;
  *) _PS1_COLOR='\[\033[32m\]'   ;;
esac
# PS1='$_XTERM_TITLE\A $_PS1_COLOR\u@\h$_PS1_CLEAR:$_PS1_BLUE\w$_PS1_COLOR\$$_PS1_CLEAR '
# export PS1="x1\[\e[31m\] \[\e[m\]\[\e[31m\]:\[\e[m\]\[\e[31m\]:\[\e[m\] \[\e[32m\]\w\[\e[m\] \[\e[34m\]ยป\[\e[m\] "
export PS1='\u@\h:\[\e[33m\]\w\[\e[0m\]\$ '

todj () {
	CMD=cat
	if [[ $1 = "-v" ]]; then
		CMD=vim
	fi
	$CMD $(find /home/lemon/Notes/journal -name "*$(date '+%Y-%m-%d')*")
}

tj () {
	if [[ -z $1 ]]; then
		echo "Please give me your message in quotes."
	fi
	echo $1 | _tj
}

tjclip () {
	if [[ -z $1 ]]; then
		echo "Please give me your message in quotes."
	fi
	echo "$1: $(xclip -o -selection clipboard)." | _tj
}

# mpv func
yta() {
      mpv --ytdl-format=bestaudio ytdl://ytsearch:"$*"
  }

# search for a file and download instantly
ytda() {
  cd ~/Downloads && yt-dlp -f 'bestaudio' -x --audio-format mp3 ytsearch"$2":"$1" -o '%(title)s.%(ext)s' && cd - || return
}

# get best audio of YouTube file or playlist (just use the right URL)
ytmp3 () {
  if [ -z "$1" ]; then print "I need a valid YouTube URL.\n"; fi
  cd ~/Downloads && yt-dlp -f 'ba' -x --audio-format mp3 "$1" -o '%(title)s.%(ext)s' && cd - || return
}

# update /usr/ports
myupdateports() {
  cd /usr && cvs -d anoncvs@anoncvs.spacehopper.org:/cvs -q up -Pd -A ports && cd - || return
}

# update /usr/sr
myupdatesrc() {
  cd /usr && cvs -d anoncvs@anoncvs.spacehopper.org:/cvs -q up -Pd -A src && cd - || return
}

# completions - experimental
set -A complete_task_1 -- add sync

# GPG agent
GPG_TTY=$(tty)
export GPG_TTY

# FZF
#export FZF_DEFAULT_COMMAND='ag  -g ""'
#export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND
#export FZF_ALT_C_COMMAND=$FZF_DEFAULT_COMMAND
#export FZF_DEFAULT_OPTS='--color info:108,prompt:109,spinner:108,pointer:168,marker:168'
#[ -f ~/.fzf.bash ] && source ~/.fzf.bash

# from https://dataswamp.org/~solene/2021-10-17-ksh-fzf.html
#function fzf-histo {
#    RES=$(fzf --tac --no-sort -e < $HISTFILE)
#        test -n "$RES" || exit 0
#	    eval "$RES"
#    }
#
#bind -m ^R=fzf-histo^J