summary refs log tree commit diff stats
path: root/.kshrc
blob: 30aeb9cab2fef3dd5930df41228067a1a9a78bad (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
#shellcheck shell=ksh

bind ^L=clear-screen
set -o emacs
export TERM=xterm-256color

export GPG_TTY="$(tty)"
#export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
#gpgconf --create-socketdir
#gpgconf --launch gpg-agent
#gpg-connect-agent updatestartuptty /bye >/dev/null

[ -f "$HOME/.ksh_completions" ] && . "$HOME/.ksh_completions"

_ps1_ret_code() {
  _ret=$?
  [ -n "${_ret##0}" ] && echo " [${_ret}]"
}

_ps1_git_branch() {
  git_status="$(git branch --show-current 2>/dev/null)"
  if [ "$git_status" != "" ]; then
    echo " ($git_status)" 
  fi
}

#shellcheck disable=SC2025
export PS1='\n\u@\h \w`_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"
}