diff options
| -rw-r--r-- | ksh/.kshrc | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/ksh/.kshrc b/ksh/.kshrc new file mode 100644 index 0000000..b8f8648 --- /dev/null +++ b/ksh/.kshrc | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | # .kshrc | ||
| 2 | # | ||
| 3 | # note: this file is executed by interactive non-login shell | ||
| 4 | # if it needs to execute for login shells too (i.e. virtual | ||
| 5 | # tty) add export ENV=$HOME/.kshrc to .profile | ||
| 6 | |||
| 7 | LC_ALL="en_US.UTF-8" | ||
| 8 | # This PS1 is completed at the end, allowing statuses to be included between the directory and closing $ | ||
| 9 | PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]" | ||
| 10 | END_PS1="\$\[\e[m\] " | ||
| 11 | # This is the original PS1 | ||
| 12 | #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " | ||
| 13 | PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" | ||
| 14 | |||
| 15 | # OpenBSD | ||
| 16 | # FreeBSD | ||
| 17 | # Darwin | ||
| 18 | # Linux | ||
| 19 | OS_NAME=`uname` | ||
| 20 | |||
| 21 | ## Shell History | ||
| 22 | export HISTSIZE=99999 | ||
| 23 | export HISTFILE=$HOME/.ksh_history | ||
| 24 | export HISTCONTROL="ignoredupes:ignorespace" | ||
| 25 | |||
| 26 | export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" | ||
| 27 | |||
| 28 | ## Telemetry | ||
| 29 | # Disable various telemetry | ||
| 30 | export SAM_CLI_TELEMETRY=0 | ||
| 31 | |||
| 32 | ## Warpdir | ||
| 33 | WD=`which warpdir 2> /dev/null` | ||
| 34 | if [ -x "$WD" ]; then | ||
| 35 | wd() { | ||
| 36 | output=$(warpdir $@) | ||
| 37 | status_code=$? | ||
| 38 | if [[ $status_code -eq 0 ]]; then | ||
| 39 | cd "$output" | ||
| 40 | elif [[ "$output" != "" ]]; then | ||
| 41 | echo "$output" | ||
| 42 | fi | ||
| 43 | unset output | ||
| 44 | unset status_code | ||
| 45 | } | ||
| 46 | fi | ||
| 47 | |||
| 48 | ## FZF | ||
| 49 | FZF=`which fzf 2> /dev/null` | ||
| 50 | if [ -x "$FZF" ]; then | ||
| 51 | # fzf does not have first class ksh support. | ||
| 52 | function fzf-histo { | ||
| 53 | RES=$(fzf --tac --no-sort -e < $HISTFILE) | ||
| 54 | test -n "$RES" || exit 0 | ||
| 55 | eval "$RES" | ||
| 56 | } | ||
| 57 | |||
| 58 | # space so it isn't saved in the history | ||
| 59 | bind -m ^R=' fzf-histo'^J | ||
| 60 | fi | ||
| 61 | |||
| 62 | |||
| 63 | ## Python | ||
| 64 | __workon() { | ||
| 65 | source ~/.virtualenvs/$1/bin/activate | ||
| 66 | } | ||
| 67 | __mkvirtualenv() { | ||
| 68 | python -mvenv ~/.virtualenvs/$1 | ||
| 69 | . $HOME/.virtualenvs/$1/bin/activate | ||
| 70 | } | ||
| 71 | alias workon=__workon | ||
| 72 | alias mkvirtualenv=__mkvirtualenv | ||
| 73 | |||
| 74 | ## Go | ||
| 75 | |||
| 76 | if [ -d "$HOME/go/bin" ]; then | ||
| 77 | export PATH=$HOME/go/bin:$PATH | ||
| 78 | fi | ||
| 79 | |||
| 80 | ## direnv | ||
| 81 | DIRENV=`which direnv 2> /dev/null` | ||
| 82 | if [ -x "$DIRENV" ]; then | ||
| 83 | # https://github.com/direnv/direnv/issues/873 | ||
| 84 | refresh_direnv() { | ||
| 85 | eval "$("$DIRENV" export bash | sed 's@=\$'\''@='\''@g')" | ||
| 86 | } | ||
| 87 | |||
| 88 | direnv() { | ||
| 89 | "$DIRENV" "$@" | ||
| 90 | refresh_direnv | ||
| 91 | } | ||
| 92 | |||
| 93 | cd() { | ||
| 94 | builtin cd "$@" | ||
| 95 | refresh_direnv | ||
| 96 | } | ||
| 97 | fi | ||
| 98 | |||
| 99 | ## nvm | ||
| 100 | export NVM_DIR="$HOME/.nvm" | ||
| 101 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
| 102 | |||
| 103 | # Close off the PS1 with the $ | ||
| 104 | export PS1=${PS1}${END_PS1} | ||