Repository navigation
Expand file tree
/
Copy pathbashrc.common
More file actions
78 lines (75 loc) · 2.96 KB
/
Copy pathbashrc.common
File metadata and controls
78 lines (75 loc) · 2.96 KB
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
78
# ============================================================
# shell-setup: common Bash configuration
# Installed at: ~/.config/shell-setup/bashrc.common
#
# Keep machine-specific settings (ROS, CUDA, proxy, conda, etc.)
# in the machine's existing ~/.bashrc. This file is intentionally
# limited to portable interactive-shell conveniences.
# ============================================================
# ------------------------------
# History
# ------------------------------
HISTSIZE=50000
HISTFILESIZE=100000
HISTCONTROL=ignoreboth
shopt -s histappend
shopt -s cmdhist
# Make commands entered in one terminal visible to other Bash terminals.
# Preserve any pre-existing PROMPT_COMMAND used by ROS/conda/tools/prompts.
__shell_setup_history_sync() {
builtin history -a
builtin history -n
}
if declare -p PROMPT_COMMAND 2>/dev/null | grep -q '^declare -a'; then
_shell_setup_history_hook_found=0
for _shell_setup_cmd in "${PROMPT_COMMAND[@]}"; do
if [[ "$_shell_setup_cmd" == "__shell_setup_history_sync" ]]; then
_shell_setup_history_hook_found=1
break
fi
done
if [[ $_shell_setup_history_hook_found -eq 0 ]]; then
PROMPT_COMMAND+=("__shell_setup_history_sync")
fi
unset _shell_setup_history_hook_found _shell_setup_cmd
else
if [[ "${PROMPT_COMMAND:-}" != *"__shell_setup_history_sync"* ]]; then
PROMPT_COMMAND="__shell_setup_history_sync${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
fi
fi
# ------------------------------
# bash-completion
# ------------------------------
# Ubuntu may already load bash-completion from ~/.bashrc or /etc/bash.bashrc.
# Load it only when it is not already active.
if ! declare -p BASH_COMPLETION_VERSINFO >/dev/null 2>&1; then
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
fi
fi
fi
# ------------------------------
# fzf defaults
# ------------------------------
# The fzf shell integration itself is sourced by the managed block in
# ~/.bashrc. These variables only define the default UI behavior.
: "${FZF_DEFAULT_OPTS:=--height=50% --layout=reverse --border --info=inline}"
: "${FZF_CTRL_R_OPTS:=--height=60% --layout=reverse --border}"
export FZF_DEFAULT_OPTS FZF_CTRL_R_OPTS
# ------------------------------
# Terminal/TUI scroll behavior
# ------------------------------
# Claude Code:
# alternate screenを使わず、tmux/native scrollbackを使えるようにする
export CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1
# Vim:
# SHELL_SETUP_VIM_MOUSE=1 adds mouse=a; existing ~/.vimrc still loads.
# 既に vim alias/function がある場合は上書きしない
# Opt in explicitly; otherwise leave mouse handling to the terminal/.vimrc.
if [[ "${SHELL_SETUP_VIM_MOUSE:-0}" == 1 ]] &&
[[ "$(type -t vim 2>/dev/null || true)" == "file" ]]; then
alias vim='vim -c "set mouse=a"'
fi