-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_not_found_hundle.sh
executable file
·55 lines (51 loc) · 1.73 KB
/
command_not_found_hundle.sh
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
#!/bin/bash
# Copyright(c) 2023 Blacknon. All rights reserved.
# Use of this source code is governed by an MIT license
# that can be found in the LICENSE file.
# コマンドがない場合に出力されるテキスト
function __command_not_found_animation() {
echo "${COLOR_PURPLE}(#`・ω ・´) ${COLOR_NONE}「${COLOR_CYAN}$1${COLOR_NONE}」なんて代物はねぇぞ!こんにゃろーめ!!"
}
# コマンドが無い場合に実行される処理の定義
function __command_not_found() {
# compopt(bashの補完用コマンド)の場合、コマンドは無いものとして処理
if [ "$1" == "compopt" ]; then
return 127
fi
case ${OSTYPE} in
darwin*)
__command_not_found_animation "$1"
return 127
;;
linux*)
if [ -x /usr/lib/command-not-found ] || [ -x /usr/share/command-not-found/command-not-found ]; then
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
__command_not_found_animation "$1"
return 127
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
__command_not_found_animation "$1"
return 127
fi
else
__command_not_found_animation "$1"
return 127
fi
;;
esac
}
# command_not_found_handle(zshの場合はcommand_not_found_handler)の定義
case $(basename "${SHELL}") in
zsh*)
function command_not_found_handler() {
trap '' 1 2 3 15
__command_not_found "$1"
}
;;
bash*)
function command_not_found_handle() {
__command_not_found "$1"
}
;;
esac