diff options
author | Benjamin Morrison <ben@gbmor.org> | 2023-02-17 23:23:36 -0500 |
---|---|---|
committer | Benjamin Morrison <ben@gbmor.org> | 2023-02-17 23:23:36 -0500 |
commit | 88fb6eb07cae2b5ef069d35042ea78c59bde33db (patch) | |
tree | 4909605e85b9ca5506c6cebc358ed62b9e5a51e4 /.kshrc | |
parent | d60b99e02e0b5e8b1ba8b0fb82dbc2cde58c0c08 (diff) | |
download | dogfiles-88fb6eb07cae2b5ef069d35042ea78c59bde33db.tar.gz |
kshrc/completions
Diffstat (limited to '.kshrc')
-rw-r--r-- | .kshrc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/.kshrc b/.kshrc new file mode 100644 index 0000000..3dd091a --- /dev/null +++ b/.kshrc @@ -0,0 +1,71 @@ +#shellcheck shell=ksh + +bind ^L=clear-screen +set -o emacs +export TERM=xterm-256color + +[ -f "$HOME/.ksh_completions" ] && . "$HOME/.ksh_completions" + +_ps1_ret_code() { + _ret=$? + [ -n "${_ret##0}" ] && echo " [31m[[01m${_ret}[00m[31m][00m" +} + +_ps1_git_branch() { + git_status="$(git status 2>/dev/null | awk '/On branch/ {print $3}')" + if [ "$git_status" != "" ]; then + echo " ($git_status)" + fi +} + +#shellcheck disable=SC2025 +export PS1='[92m\u[0m@\h [92m\w[00m`_ps1_git_branch``_ps1_ret_code`\$ ' + +dotfiles() { + #shellcheck disable=SC2068 + /usr/bin/git --git-dir "$HOME/.dotfiles/" --work-tree "$HOME" $@ +} + +pkgs() { + if [ -z "$1" ]; then + printf 'no package name specified\n' + return 1 + fi + /usr/bin/apt search --names-only "$1" +} + +grabfile() { + if [ -z "$1" ]; then + printf 'no file name specified\n' + return 1 + fi + xclip -selection clipboard "$1" +} + +snip() { + cat - | xclip -selection clipboard -i +} + +emacs() { + command emacs -nw "$1" +} + +dev_cd() { + if [ -z "$1" ]; then + cd "$HOME/dev" || return 1 + return 0 + fi + if [ -z "$2" ]; then + cd "$1" || return 1 + return 0 + fi + cd "$1/$2" || return 1 +} + +devg() { + dev_cd "$HOME/dev/github" "$1" +} +devs() { + dev_cd "$HOME/dev/srht" "$1" +} + |