shell - doubility-sky/daydayup GitHub Wiki
In computing, a shell is a command-line interpreter which exposes access to an operating system's services. In general, operating system shells use either a command-line interface (CLI) or graphical user interface (GUI), depending on a computer's role and particular operation. It is named a shell because it is the outermost layer around the operating system.
Command-line shells require the user to be familiar with commands and their calling syntax, and to understand concepts about the shell-specific scripting language (for example, bash).
- You Don't Need GUI: Stop relying on GUI; CLI ROCKS
- The Art of Command Line, Master the command line, in one page. - zh-CN
- 命令行通配符教程
- Modern PATH environment variable
- Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting
- Shell 脚本编程30分钟入门
-
Shell 脚本传参方法总结
echo $0 # 当前脚本的文件名(间接运行时还包括绝对路径)。 echo $n # 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是 $1 。 echo $# # 传递给脚本或函数的参数个数。 echo $* # 传递给脚本或函数的所有参数。 echo $@ # 传递给脚本或函数的所有参数。被双引号 (" ") 包含时,与 $* 不同,下面将会讲到。 echo $? # 上个命令的退出状态,或函数的返回值。 echo $$ # 当前 Shell 进程 ID。对于 Shell 脚本,就是这些脚本所在的进程 ID。 echo $_ # 上一个命令的最后一个参数 echo $! # 后台运行的最后一个进程的 ID 号
- useful scripts for making developer's everyday life easier and happier, involved java, shell etc.
- Minimal safe Bash script template
- Advanced Shell Scripting Techniques: Automating Complex Tasks with Bash
Bourne shell (sh)
The Bourne shell was the default shell for Version 7 Unix. Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic link or hard link to a compatible shell—even when other shells are used by most users.
- pure sh bible: A collection of pure POSIX sh alternatives to external processes.
Bash (the Bourne-Again shell)
Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been used as the default login shell for most Linux distributions and all releases of Apple's macOS prior to macOS Catalina. A version is also available for Windows 10 via the Windows Subsystem for Linux. It is also the default user shell in Solaris 11.
- pure bash bible: A collection of pure bash alternatives to external processes.
-
bash-tutorial 本教程介绍 Linux 命令行 Bash 的基本用法和脚本编程。 https://wangdoc.com/bash/
- ruanyf/simple-bash-scripts A collection of simple Bash scripts
- bash cheatsheet, 中文速查表
- Bash-Oneliner: A collection of handy Bash One-Liners and terminal tricks for data processing and Linux system maintenance.
- ⭐linux default
shisdash-
ls -al /bin/shlrwxrwxrwx 1 root root 4 Feb 20 14:30 /bin/sh -> dash
- let
shto bebash:ln -sf /bin/bash /bin/sh
-
- Bash Shortcuts
The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
- Moving to zsh
- 你不需要花哨的命令提示符
- Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.
- Antigen is a small set of functions that help you easily manage your shell (zsh) plugins, called bundles. The concept is pretty much the same as bundles in a typical vim+pathogen setup. Antigen is to zsh, what Vundle is to vim.
- awesome-zsh-plugins: A collection of ZSH frameworks, plugins, tutorials & themes inspired by the various awesome list collections out there.
- Zellij is a workspace aimed at developers, ops-oriented people and anyone who loves the terminal. Similar programs are sometimes called "Terminal Multiplexers".
Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells.
- How To Use Screen
- linux screen 命令详解
- Frequently Command:
screen -ls 列出当前所有的session -r <作业名称> 恢复离线的screen作业。 - In Session Command:
C-a n -> Next,切换到下一个 window C-a p -> Previous,切换到前一个 window C-a d -> detach,暂时离开当前session, 将目前的 screen session (可能含有多个 windows) 丢到后台执行, 并会回到还没进 screen 时的状态,此时在 screen session 里, 每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。 - man screen
tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.
- Getting Started
- Gentle Guide to Get Started With tmux
- Getting started with Tmux
- Tmux 使用教程
- frequently used commands
tmux ls # or `tmux list-session` tmux new -s <session-name> tmux at -t <session-name> # or `tmux attach -t <session-name>` tmux rename-session -t <session-name> <new-name> tmux switch -t <session-name> tmux detach # or `C-b d` tmux kill-session -t <session-name> # inside a tmux session tmux new-window -n <window-name> # or `C-b c` tmux rename-window <new-name> tmux select-window -t <window-name>
- frequently used shortcuts (prefix key
C-b):-
C-b cCreate a new window -
C-b sList all sessions -
C-b wList all sessions' windows -
C-b nNext window in current session -
C-b pPrevious window in current session -
C-b <0~9>Select window 0~9 in current session -
C-b $Rename current session -
C-b tShow a clock
-
- tmux shortcuts & cheatsheet - zh-CN
tmux help `C-b ?`
C-b Space Select next layout
C-b ! Break pane to a new window
C-b " Split window vertically
C-b # List all paste buffers
C-b $ Rename current session
C-b % Split window horizontally
C-b & Kill current window
C-b ' Prompt for window index to select
C-b ( Switch to previous client
C-b ) Switch to next client
C-b , Rename current window
C-b - Delete the most recent paste buffer
C-b . Move the current window
C-b / Describe key binding
C-b <0~9> Select window 0~9
C-b : Prompt for a command
C-b ; Move to the previously active pane
C-b = Choose a paste buffer from a list
C-b ? List key bindings
C-b C Customize options
C-b D Choose and detach a client from a list
C-b E Spread panes out evenly
C-b L Switch to the last client
C-b M Clear the marked pane
C-b [ Enter copy mode
C-b ] Paste the most recent paste buffer
C-b c Create a new window
C-b d Detach the current client
C-b f Search for a pane
C-b i Display window information
C-b l Select the previously current window
C-b m Toggle the marked pane
C-b n Select the next window
C-b o Select the next pane
C-b p Select the previous window
C-b q Display pane numbers
C-b r Redraw the current client
C-b s Choose a session from a list
C-b t Show a clock
C-b w Choose a window from a list
C-b x Kill the active pane
C-b z Zoom the active pane
C-b { Swap the active pane with the pane above
C-b } Swap the active pane with the pane below
C-b ~ Show messages
C-b DC Reset so the visible part of the window follows the cursor
C-b PPage Enter copy mode and scroll up
C-b Up Select the pane above the active pane
C-b Down Select the pane below the active pane
C-b Left Select the pane to the left of the active pane
C-b Right Select the pane to the right of the active pane
C-b M-1 Set the even-horizontal layout
C-b M-2 Set the even-vertical layout
C-b M-3 Set the main-horizontal layout
C-b M-4 Set the main-vertical layout
C-b M-5 Select the tiled layout
C-b M-6 Set the main-horizontal-mirrored layout
C-b M-7 Set the main-vertical-mirrored layout
C-b M-n Select the next window with an alert
C-b M-o Rotate through the panes in reverse
C-b M-p Select the previous window with an alert
C-b M-Up Resize the pane up by 5
C-b M-Down Resize the pane down by 5
C-b M-Left Resize the pane left by 5
C-b M-Right Resize the pane right by 5
C-b C-b Send the prefix key
C-b C-o Rotate through the panes
C-b C-z Suspend the current client
C-b C-Up Resize the pane up
C-b C-Down Resize the pane down
C-b C-Left Resize the pane left
C-b C-Right Resize the pane right
C-b S-Up Move the visible part of the window up
C-b S-Down Move the visible part of the window down
C-b S-Left Move the visible part of the window left
C-b S-Right Move the visible part of the window right
~/.tmux.conf — 精简实用配置(适配 Ghostty 终端)
# =============================================================================
# ~/.tmux.conf — 精简实用配置(适配 Ghostty 终端)
# 放到 ~/.tmux.conf
# - 无 server 运行时,tmux new 会自动加载
# - server 已运行时,需手动加载:tmux source-file ~/.tmux.conf
# 或在 tmux 内按 Ctrl-b r 热重载
# - history-limit 只对之后新建的 pane 生效
# =============================================================================
# ── 终端与显示 ──────────────────────────────────────────────
# 告诉 tmux 内部程序"你运行在什么终端里"
# screen-256color 兼容性最好,几乎所有服务器都有这个 terminfo
set -g default-terminal "screen-256color"
# 告诉 tmux:"如果外层终端是 ghostty 或 xterm-256color,就启用真彩色"
# Tc = True Color,RGB 颜色不会被降级成 256 色
set -ga terminal-overrides ",xterm-ghostty:Tc,xterm-256color:Tc"
# 减少按 ESC 后的等待时间(毫秒)
# 默认 500ms,在 vim/neovim 里按 ESC 会明显卡顿,设成 10 基本无感
set -g escape-time 10
# ── 滚动与历史 ──────────────────────────────────────────────
# 每个 pane 保留多少行历史(默认只有 2000 行,太少了)
# 注意:只对设置后新创建的 pane 生效
set -g history-limit 50000
# ── 鼠标 ──────────────────────────────────────────────────────
# 开启鼠标支持后:
# - 滚轮 → 自动进入 copy mode 并滚动(不用记 Ctrl-b [)
# - 点击 pane → 切换焦点
# - 拖拽 pane 边框 → 调整大小
# - 点击状态栏窗口名 → 切换窗口
set -g mouse on
# ── 编号 ──────────────────────────────────────────────────────
# 窗口和面板编号从 1 开始(键盘上 1 比 0 好按)
set -g base-index 1
setw -g pane-base-index 1
# 关闭某个窗口后,后面的窗口编号自动补位(不会出现 1,3,4 的空洞)
set -g renumber-windows on
# ── Copy Mode(复制模式)─────────────────────────────────────
# 在 copy mode 中使用 vi 风格的按键
# 进入: Ctrl-b [ 退出: q
# 移动: h/j/k/l 或方向键 搜索: / 或 ?
# 选择: v(开始) → y(复制并退出)
setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel
# ── 快捷键 ────────────────────────────────────────────────────
# 前缀键保持默认 Ctrl-b(不改,避免和其他工具冲突)
# 竖直分屏(左|右),保留当前目录
# 默认是 Ctrl-b %,不直观
bind | split-window -h -c "#{pane_current_path}"
# 水平分屏(上—下),保留当前目录
# 默认是 Ctrl-b ",不直观
bind - split-window -v -c "#{pane_current_path}"
# 新建窗口时保留当前目录(默认会跳回 home)
bind c new-window -c "#{pane_current_path}"
# 快速重载本配置文件(修改 .tmux.conf 后不用退出 tmux)
bind r source-file ~/.tmux.conf \; display "配置已重载!"
# ── 状态栏 ────────────────────────────────────────────────────
# 简洁的深色状态栏
set -g status-style "bg=#282c34,fg=#abb2bf"
set -g status-left "#[fg=#61afef,bold] #S " # 左侧显示 session 名
set -g status-right "#[fg=#98c379] %m-%d %H:%M " # 右侧显示日期时间
set -g status-left-length 20
setw -g window-status-current-style "fg=#61afef,bold,underscore" # 当前窗口高亮
# =============================================================================
# 常用操作速查(不是配置,纯注释备忘)
#
# Ctrl-b d 脱离 session(回到普通 shell,session 后台继续运行)
# Ctrl-b | 竖直分屏(上面自定义的)
# Ctrl-b - 水平分屏(上面自定义的)
# Ctrl-b 方向键 切换到相邻面板
# Ctrl-b c 新建窗口
# Ctrl-b 1/2/3 切换到第 1/2/3 号窗口
# Ctrl-b , 重命名当前窗口
# Ctrl-b x 关闭当前面板(会确认)
# Ctrl-b z 当前面板全屏/恢复(zoom toggle)
# Ctrl-b [ 进入 copy mode(然后用滚轮或 j/k 翻页)
# Ctrl-b r 重载配置(上面自定义的)
# tmux ls 列出所有 session
# tmux attach 重新连回 session
# =============================================================================Zellij is a workspace aimed at developers, ops-oriented people and anyone who loves the terminal. At its core, it is a terminal multiplexer (similar to tmux and screen), but this is merely its infrastructure layer.
- ⭐shellcheck, a static analysis tool for shell scripts https://www.shellcheck.net
- explainshell is a tool (with a web interface) capable of parsing man pages, extracting options and explain a given command-line by matching each argument to the relevant help text in the man page. http://www.explainshell.com/
- cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.
- cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
- Generic Colouriser is yet another colouriser (written in python) for beautifying your logfiles or output of commands.
- CLI: improved - zh-CN
- Modern Unix: A collection of modern/faster/saner alternatives to common unix commands.
- fzf is a general-purpose command-line fuzzy finder.
- When You Should Use Bash Over Python
- sh Python process launching http://amoffat.github.com/sh
- xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt. The language is a superset of Python 3.5+ with additional shell primitives. xonsh (pronounced conch) is meant for the daily use of experts and novices alike.
- sarge, a wrapper for subprocess which aims to make life easier for anyone who needs to interact with external applications from their Python code.
- (:warning:May be outdated)Plumbum: Shell Combinators http://plumbum.readthedocs.org
- 流行终端模拟器 汇总
- kitty - the fast, feature-rich, cross-platform, GPU based terminal
- 👻 Ghostty is a fast, feature-rich, and cross-platform terminal emulator that uses platform-native UI and GPU acceleration.
- Tabby (formerly Terminus) is a highly configurable terminal emulator, SSH and serial client for Windows 10, macOS and Linux
- Alacritty - A fast, cross-platform, OpenGL terminal emulator
- wezterm - A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
- hyper - A terminal built on web technologies
- sshx - Fast, collaborative live terminal sharing over the web
-
view shell codes
function readJson { UNAMESTR=`uname` if [[ "$UNAMESTR" == 'Linux' ]]; then SED_EXTENDED='-r' elif [[ "$UNAMESTR" == 'Darwin' ]]; then SED_EXTENDED='-E' fi; VALUE=`grep -m 1 "\"${2}\"" ${1} | sed ${SED_EXTENDED} 's/^ *//;s/.*: *"//;s/",?//'` if [ ! "$VALUE" ]; then echo "Error: Cannot find \"${2}\" in ${1}" >&2; exit 1; else echo $VALUE ; fi; }
- Awesome Shell: A curated list of awesome command-line frameworks, toolkits, guides and gizmos. Inspired by awesome-php.
- Awesome Bash: A curated list of delightful Bash scripts and resources.
- awesome-cli-apps A curated list of command line apps
