@@ -81,12 +81,6 @@ alias lr="ls -AR1 -I .git|awk '/:$/{gsub(/[^\/]+\//,\"--\",\$0);printf(\"%d file
81
81
alias bell=" printf '\a'" # either echo -ne '\007' or printf '\a'" or tput bel
82
82
alias h=" history"
83
83
alias hc=" history -c"
84
- alias sc=" systemctl"
85
- alias jc=" journalctl"
86
- alias scs=" systemctl status"
87
- alias sc0=" systemctl stop"
88
- alias sc1=" systemctl start"
89
- alias scr=" systemctl restart"
90
84
alias psql=" INPUTRC=/dev/fd/9 psql 9<<<'set editing-mode vi'" ;
91
85
alias mysql=' INPUTRC=/dev/fd/9 mysql 9<<<' \' ' set editing-mode vi' \' ' '
92
86
# This is getting even uglier, but must have on remote machines
@@ -95,6 +89,25 @@ alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s
95
89
alias gs=" git status -sb" ;
96
90
alias json=" python -mjson.tool"
97
91
alias tmux=" tmux -2"
92
+
93
+ # Better systemd. We use $SCS to store the unit we're working on, so no need for typing or history athletics.
94
+ # self-reload, because systemd can't do it on its own...
95
+ sdr () { systemctl daemon-reload ; }
96
+ # `sc` is like systemctl, but stores last param in $SCS.
97
+ sc () { SCS=" ${@: -1} " ; systemctl " $@ " ; }
98
+ # STATUS, full lines
99
+ scs () { SCS=" ${1:- ${SCS} } " ; systemctl status -l " $SCS " ; }
100
+ # STOP, but shows a status afterwards
101
+ sc0 () { SCS=" ${1:- ${SCS} } " ; systemctl stop " $SCS " ; scs ; }
102
+ # START, but shows a status afterwards, and tails the log
103
+ sc1 () { SCS=" ${1:- ${SCS} } " ; sdr ; journalctl -n 0 -xfu " $SCS " & systemctl start " $SCS " ; scs ; fg ; }
104
+ # RELOAD, but shows a status afterwards, and tails the log
105
+ scr () { SCS=" ${1:- ${SCS} } " ; sdr ; journalctl -n 0 -xfu " $SCS " & systemctl reload-or-restart " $SCS " ; scs ; fg ; }
106
+ # LOG in pager, extended info, jump to end
107
+ jc () { SCS=" ${1:- ${SCS} } " ; journalctl -xeu " $SCS " ; }
108
+ # LOG "tail -f". Tries to fill the screen.
109
+ jcf () { SCS=" ${1:- ${SCS} } " ; journalctl -n " ${LINES:- 45} " -xefu " $SCS " ; }
110
+
98
111
# Only if not on busybox
99
112
[ -L $( type -p grep) ] || alias grep=" grep --color"
100
113
[ -L $( type -p less) ] || alias less=" less -X" # No alt screen
111
124
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion # OS X
112
125
if type _completion_loader 2> /dev/null > /dev/null; then _completion_loader systemctl; _completion_loader journalctl; fi
113
126
complete -F _systemctl sc
114
- complete -F _journalctl jc
115
127
complete -F _ssh sssh
116
128
117
129
# Poor man's history expansion (which bash doesn't do on TAB)
0 commit comments