如何通过优化Ubuntu别名命令,实现高效快捷操作,大幅提升工作效率?
- 内容介绍
- 文章标签
- 相关推荐
Ubuntu别名命令调整:解决你的效率痛点!
作为Ubuntu使用者,你是否常因长命令输入而感到烦躁?是否希望用更简单的方式完成重复操作?老实说,别名命令就是你的救星!
1. 别名基础:立即提高效率
问题痛点:每次都要输入复杂的参数组合?方法:
-
alias ll='ls -l'- 简化目录列表查看 -
alias grep='grep --color'- 高亮显示搜索结果 -
alias update='sudo apt update && sudo apt upgrade'- 一键程序更新
2. 持久化设置:避免重复工作
问题痛点:每次重启终端就要重新设置别名?方法:
$ nano ~/.bashrc
# 在文件末尾添加别名定义
alias myip='curl ifconfig.me'
# 保存后执行:
$ source ~/.bashrc
# 或使用更现代的方法:
echo "alias myip='curl ifconfig.me'">> ~/.bashrc && source ~/.bashrc
3. 高级调整技巧:真正提高工作流速度!说起来,
命令提高型别名
"我想查看git状态但不想输入那么多字符" —— 用这个解决!
$ alias gs='git status'
$ alias gd='git diff | less'
$ alias gaa='git add .'
$ alias gcm='git commit -m'
$ alias gpom='git push origin master'
# 项目管理专用!不过,$ alias projs="cd ~/projects"
$ alias ws="cd ~/workspace"
# 快速跳转到特定项目目录!$ alias wp="cd ~/workspace/myproject && ls"
# 项目管理专用!$ alias projs="cd ~/projects"
$ alias ws="cd ~/workspace"
# 快速跳转到特定项目目录!不过,$ alias wp="cd ~/workspace/myproject && ls"
# 查看当前目录下所有隐藏文件
$ alias la='ls -A | grep ^.'
# 使用vim编辑.bashrc并自动生效
$ alias vrc="vim ~/.bashrc && source ~/.bashrc"
# 安全删除
$ alias rm='mv -i ~/.trash/'
# 一键备份关键文件夹
$ backup { tar czvf backup_$.tar.gz /path/to/backup }
### 添加到.bashrc中:
echo 'backup { tar czvf backup_$.tar.gz /path/to/backup }'>> ~/.bashrc && source ~/.bashrc
### 接下来可以这样使用:
backup /home/user/documents
## 快速创建Python虚拟环境
python-venv {
python3 -m venv $1 && echo "Virtualenv created at $1" && echo "Activate with: source $1/bin/activate"
}
echo 'python-venv { python3 -m venv $1 && echo "Virtualenv created at $1" && echo "Activate with: source $1/bin/activate" }'>> ~/.bashrc
## 在线检查网络端口占用情况
checkport {
sudo lsof -i :${1:-80} || netstat -tuln | grep ${1:-80}
}
## 超级清理临时文件
superclean {
read -p "Are you sure?This will delete a lot of files!" ans
|| exit 0
sudo apt-get clean>/dev/null &
sudo bleachbit --clean system.cache system.logs system.tmp>/dev/null &
rm -rf /tmp/* /var/tmp/* ~/.cache/* ~/*.swp ~/*.swo ~/*.bak ~/*.orig 2>/dev/null &
}
## 一键安装常用软件包
install-common {
sudo apt update && \
sudo apt install build-essential git curl wget htop tmux neovim zsh tree \
ripgrep fd-find bat exa tmuxinator yarn npm python3-pip \
docker docker-compose ffmpeg mplayer vlc smplayer gimp inkscape audacity \
shutter qemu qemu-kvm libvirt-daemon-system libvirt-clients virt-manager \
bridge-utils qpdfview okular okular-extra-backends calibre unrar p7zip-full \
filezilla thunderbird telegram-desktop discord slack-desktop obs-studio kdenlive \
krita blender nomacs shotwell simplescreenrecorder gparted testdisk timeshift \
gufw tlp tlp-rdw ufwufwufwufwufwufwufwufwufwufwufwufwufwuwfwfwfwfwfwfwffwwfwwwfwwfwwwwwfffffffffffffffffffffff
警告!: 上面这些高级技巧要谨慎使用。是:

-
- 'rm'被替换为安全删除,但仍需注意关键文件;
-
- 超级清理功能会彻底删除大量数据,请确认内容无误再操作;
-
- 安装脚本会安装许多软件包,可能影响程序性能或引入冲突。
函数式别名的高级应用
"我需要为不同项目切换不同设置环境" —— 函数+环境变量来解决!老实说,
bash
## 项目环境切换函数集合
setup_project_env {
local project_dir="$HOME/projects/$1"
# 检查项目是否存在并进入目录
if;n
echo "Project directory not found: $project_dir"
return 1
fi
cd "$project_dir"
# 检测并激活虚拟环境
if;n
source .venv/bin/activate || return 2;fi
bash
bash
bash
bash
bash
bash
setup_git_config {
local git_email=$(
if;n # 工作电脑配置 echo "";else # 其他设备配置 echo "";fi )
local git_user=$
git config user.email "$git_email"
setup_git_config
{
local git_email=$" = "work-laptop.example.com" ];n # 工作电脑配置 echo "";else # 其他设备配置 echo "";fi )
local git_user=$
export GIT_AUTHOR_NAME="$git_user"
export GIT_COMMITTER_NAME="$git_user"
export GIT_AUTHOR_EMAIL="$git_email"
export GIT_COMMITTER_EMAIL="$git_email"
export PROJECT_ENV_ACTIVE=true
echo " Environment setup for '$PWD' as user: '$GIT_USER_NAME <'$GIT_USER_EMAIL'>'"
}
### 在.bashrc中调用:
if ];n # 初始化一次 touch $HOME/.last_project chmod +x $HOME/.last_project fi
function project { local project_name=$1 local last_project=$ setup_project_env "$project_name" || return;if ],n direnv allow;fi,老实说,echo "$project_name">"$HOME/.last_project";
] || tmux new-session;话说回来,}
function proj { last_project=$;if ],n find .|fgrep "/src/"|less else fd --type d src;fi }
function back { cd ../.. }
function pj { cd ~/projects/$*;pwd,ls }
function open-vscode {
if ];n code-insiders . else code .
}
}
function open-vscode-root {
if ];说起来,n code-insiders / else code /
}
}
### 添加这些函数到.bashrc中:
cat < EOF>>$HOME/scripts/functions.sh &&
#!/bin/bash function setup_git_config... EOF && cat < EOF>>$HOME/scripts/project.sh &&... EOF && chmod +x ~/scripts/*.sh && cat >~/.zshrc ## Load custom functions for f in \~/scripts/\*.sh;do \. "\${f}" done unset f EOF && cat >~/.zshrcfn load_custom_functions{ for f in \~/scripts/\*.sh;do \. "\${f}" done } load_custom_functions EOF
上下文感知型别名
"我需要在不同项目中使用不同命令参数"
bash
在~/.direnvrc 中添加:
layoutpython{ if ];n export PYTHONVERSION=python3.9 elif ];n export PYTHONVERSION=python elif ];n export PYTHONVERSION=python else export PYTHON_VERSION=python fi }
layoutdocker{ unset DOCKERHOST DOCKERTLSVERIFY DOCKERCERTPATH DOCKERMACHINENAME DOCKERAPIVERSION unset COMPOSETLSVERSION COMPOSECONNECTIONTIMEOUT COMPOSERESPONSETIMEOUT unset MACHINESTORAGEPATH MACHINEDRIVER } layoutconda{ CONDAENVPATH="" eval "\$" conda deactivate conda activate base conda activate base setopt HISTIGNORESPACE setopt HISTFINDNODUPS setopt INCAPPENDHISTORY HISTFILE=/tmp/zhistory SIZE=\$\ let “SIZE -= 50” head –\$-SIZE \$HISTFILE> \$HISTFILE.tmp mv \$HISTFILE.tmp \$HISTFILE uniq!\~ /.zshrchistory> history-temp mv history-temp /.zshrchistory export CONDAPROMPT_MODIFIER="" export PSI=\u@\h:\W \\$]\]\e]]\] ]\]
setprompt{ PROMPT="'%{\u@%M:%~%'}" RPROMPT="'%❯%f'"} unsetprompt{ PROMPT="'%'"} RPROMPT="'%'"} layout_gcloud{ gcloud config configurations list --format=\"table\" gcloud config configurations activate default-source-code-project-source-repo-name-source-repo-url-service-account-email-service-account-key-file-name-gcloud-component-name-gcloud-component-version-installed-status-bucket-name-default-storage-bucket-name-default-compute-zone-default-compute-region-datastore-database-url-firestore-database-url-bigquery-dataset-id-pubsub-topic-id-cloud-build-trigger-id-container-cluster-name-container-node-pool-name-container-machine-type-container-num-nodes-container-cluster-version-container-enable-autoscaling-container-min-nodes-container-max-nodes-app-engine-service-account-email-app-engine-default-bucket-name-cloud-functions-location-cloud-scheduler-location-secret-manager-instance-id-sql-instance-connection-string-sql-instance-tier-sql-instance-size-sql-instance-cpu-count-sql-instance-memory-size-sql-instance-storage-size-sql-instance-storage-type-db-proxy-enabled-db-proxy-connection-string-db-proxy-port-number-db-proxy-user-db-proxy-password-db-proxy-address-db-proxy-installation-path-cloud-dataflow-runner cloud-dataflow-network cloud-dataflow-subnetwork cloud-dataflow-worker-machine-type cloud-dataflow-worker-machine-image cloud-dataflow-worker-boot-disk-size-gb cloud-dataflow-worker-boot-disk-type cloud-dataflow-worker-harness-dir-volume-size-gb cloud-dataflow-network-mode cloud-dataflow-subnetwork-mode pubsub-emulator-host pubsub-emulator-port datastore-emulator-host datastore-emulator-port firestore-emulator-host firestore-emulator-port bigtable-emulator-host bigtable-emulator-port spanner-emulator-host spanner-emulator-port redis-cache-tier redis-cache-memory-size-gib redis-cache-transit-in-transit-enabled redis-cache-persistence-enabled redis-cache-persistence-aof-enabled redis-cache-persistence-rdb-frequency redis-cache-persistence-aof-frequency appengine-api-server-host appengine-api-server-port appengine-api-server-usehttps memorystore-redis-tier memorystore-redis-capacity-gib memorystore-redis-transit-in-transit-enabled memorystore-redis-persistence-enabled memorystore-redis-persistence-aof-enabled memorystore-redis-persistence-rdb-frequency memorystore-redis-persistence-aof-frequency compute-quotas-list compute-quotas-limit compute-quotas-used compute-regions-list compute-zones-list sql-admin-instances-list sql-admin-backups-list sql-admin-flags-list sql-admin-maintenance-windows-list sql-admin-operations-list sql-admin-settings-get storage-classes-list storage-buckets-get storage-objects-get storage-objects-acl-set storage-objects-acl-get dataproc-jobs-create dataproc-jobs-get dataproc-jobs-update dataproc-jobs-delete dataproc-clusters-create dataproc-clusters-get dataproc-clusters-update dataproc-clusters-delete container-images-add container-images-get container-images-delete container-images-tag container-images-retag container-images-deletemany pubsub-projects-topics-create pubsub-projects-topics-update pubsub-projects-topics-delete pubsub-projects-topics-message-send pubsub-projects-topics-message-receive datafusion-instances-create datafusion-instances-update datafusion-instances-delete datafusion-instances-get datafusion-instances-environment-setup datafusion-flow-configurations-create datafusion-flow-configurations-update datafusion-flow-configurations-delete datafusion-flow-configurations-start flow-configuration-import flow-configuration-export flow-configuration-test flow-configuration-debug bigquery-jobs-create bigquery-jobs-cancel bigquery-jobs-check bigquery-jobs-wait bigquery-tables-copy bigquery-tables-emptytruncate bigquery-tables-load bigquery-tables-query bigquery-tables-upload job-template-run job-template-schedule job-template-unschedule job-template-update job-template-get job-template-delete resource-manager-folders list resource-manager-folders get resource-manager-folders create resource-manager-folders delete resource-manager-organizations list resource-manager-organizations get resource-manager-organizations create resource-manager-organizations delete secretmanager-secrets list secretmanager-secrets create secretmanager-secrets destroy secretmanager-secretversions add secretmanager-secretversions destroy artifactregistry-repositories list artifactregistry-repositories get artifactregistry-repositories create artifactregistry-repositories delete artifactregistry-packages list artifactregistry-packages get artifactregistry-packages create artifactregistry-packages delete dlpcmd jobs submit dlpcmd jobs cancel dlpcmd jobs check dlpcmd jobs wait dlpcmd datasets copy dlpcmd datasets emptrydlpcmd datasets load dlpcmd datasets query dlpcmd datasets upload run-template run run-template schedule run-template unschedule run-template update run-template get run-template delete workflow-executions list workflow-executions get workflow-executions create workflow-executions cancel workflow-executions execute taskrunner-runs create taskrunner-runs cancel taskrunner-runs execute taskrunner-taskdefinitions create taskrunner-taskdefinitions update taskrunner-taskdefinitions delete taskrunner-taskdefinitions get taskrunner-taskdefinitions list apigee-apps-key-certs apigee-apps-oauth apigee-apps-customers apigee-apps-products apigee-apps-resources apigee-asset-manifest-files apigee-asset-manifest-files-upload apigee-asset-manifest-files-download auditlogs-events filter auditlogs-events describe auditlogs-events search auditlogs-events stream billing-budgets list billing-budgets get billing-budgets create billing-budgets update billing-budgets patch billing-budgets delete billing-costreports generate billing-reservations list billing-reservations get billing-reservations create billing-reservations patch billing-reservations delete budgets-notificationsettings patch budgets-notificationsettings delete budgetsserviceusage-restrictions serviceusage-restrictions serviceusage-restrictions-enable serviceusage-restrictions-disable serviceusage-restrictions-modify serviceusage-services disable serviceusage-services enable serviceusage-services modify cbt projects instances locations clusters nodes pools nodegroups nodes pools scale cbt projects zones instancegroups instances groups machines machineimages machineimagefamilies machineimagetypes machineimagetypes machineimages diskimages disks snapshots snapshotfamilies snapshotdisktypes diskdisktypes disktiers disktiertypes disks snapshots attach detach resize extend migrate clone mirroring mirroringmirroringmirroringmirroringmirroringmirroringsnapshots attach detach resize extend migrate clone mirroring mirroringmirroringsnapshots attach detach resize extend migrate clone networking networks routers firewalls networkservices networkservices networkservices networkservices networkservices networkservices networkservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesoperations operations operations operations operations operations operations operations operationsoperationsoperationsoperationsoperationsoperationsoperationsoperationsoperationsoperationstasks tasks tasks tasks tasks tasks tasks tasks tasks operationsexecute operationsexecute operationsexecute operationsexecute operationsexecute operationsexecute operationsexecutepackages packages packages packages packages packages packageinstalls packageinstalls packageinstalls packageinstalls packageinstalls packagemanagers packagemanagers packagemanagers packagemanagers packagemanagersextensions extensions extensions extensions extensions extensions extensioninstall extensioninstall extensioninstall extensioninstall extensioninstall eventarc triggers triggers triggers triggers triggers triggerstriggers triggerstriggers triggerstriggers triggerstriggers eventarc channels channels channels channels channelschannelseventarcchannels eventarcchannels events events events events eventschannelseventschannels eventschannels channelstopicspubsubtopics topics topics topics topics topicssubscriptions subscriptions subscriptions subscriptions subscriptions subscriptionspull subscriptionspull subscriptionspush subscriptionspullacknowledge subscriptionspullmodifyackdeadline subscriptionspushsubscriptionstopicsmessages publish publish subscribe subscribe subscribe pull pull modifyackdeadline acknowledge pullmodifyackdeadline acknowledge pushtopics messages publish messages publish messages publish messages publish messagepull messagepull messagepull messagepull messagepush messagepushmessagepushmessagepushtopicsmessagessubscri娱乐opicsmessagessubscri娱乐opictopicssubscribesubscriptionstopictopicssubscriptio...
跨网站兼容性处理
"我的脚本需要在Linux和Windows都能运行"
$ is_windows {
case `uname` in CYGWIN*|MINGW*|MSYS*) return 0;,*) return 1;,esac }
case `uname` in CYGWIN*) cygwin=true;,*) cygwin=false;,esac }
uname | findstr CYGWIN MINGW MSYS>nul and set win=true or set win=false )
else win=false fi )
else win=false
命令提高与可视化输出
pre>
preh5" 安全防护与风险控制 /preh5 "
pre " ⚠️警告!⚠️< span>" "
pre " 一些危险操作可能导致数据丢失或程序损坏。务必谨慎,怎么说呢,永远不要将以下命令作为别名: rm * rm rf / dd if=/dev/random of=/dev/sdX bs=5M # 历史错误示例! yes N | rm rf / # 禁止这样的恶意命令! chmod R+x / # 绝对不要这样做!按理说,
说到预防措施。为rm创建安全封装: safe_remove{ read - p " 确认删除'$*'?" && return,
find . name " $ *"- delete- ok;} alias rm=" safe_remove "
限制sudo权限: restricted_sudo{ && echo " 权限受限!仅允许编辑和重启操作,";return,} for cmd in vim nano vi emacs shutdown reboot halt initpoweroff;do sudo - K cmd;done,
for cmd in rm cp mv chown chmod passwd useradd userdel groupadd groupdel;do sudo - R cmd;done,
禁止明文密码出现在历史记录中: alias mysql=" mysql - p "(read - sP ";password:" passwd && printf "%% %s%%n " $ passwd)" unset passwd;} " "
preh6""常用方法"/preh6 ""
ol class=" best-pratices"> ""
ol class=" best-pratices"> ""
ol class=" best-pratices"> ""
Ubuntu别名命令调整:解决你的效率痛点!
作为Ubuntu使用者,你是否常因长命令输入而感到烦躁?是否希望用更简单的方式完成重复操作?老实说,别名命令就是你的救星!
1. 别名基础:立即提高效率
问题痛点:每次都要输入复杂的参数组合?方法:
-
alias ll='ls -l'- 简化目录列表查看 -
alias grep='grep --color'- 高亮显示搜索结果 -
alias update='sudo apt update && sudo apt upgrade'- 一键程序更新
2. 持久化设置:避免重复工作
问题痛点:每次重启终端就要重新设置别名?方法:
$ nano ~/.bashrc
# 在文件末尾添加别名定义
alias myip='curl ifconfig.me'
# 保存后执行:
$ source ~/.bashrc
# 或使用更现代的方法:
echo "alias myip='curl ifconfig.me'">> ~/.bashrc && source ~/.bashrc
3. 高级调整技巧:真正提高工作流速度!说起来,
命令提高型别名
"我想查看git状态但不想输入那么多字符" —— 用这个解决!
$ alias gs='git status'
$ alias gd='git diff | less'
$ alias gaa='git add .'
$ alias gcm='git commit -m'
$ alias gpom='git push origin master'
# 项目管理专用!不过,$ alias projs="cd ~/projects"
$ alias ws="cd ~/workspace"
# 快速跳转到特定项目目录!$ alias wp="cd ~/workspace/myproject && ls"
# 项目管理专用!$ alias projs="cd ~/projects"
$ alias ws="cd ~/workspace"
# 快速跳转到特定项目目录!不过,$ alias wp="cd ~/workspace/myproject && ls"
# 查看当前目录下所有隐藏文件
$ alias la='ls -A | grep ^.'
# 使用vim编辑.bashrc并自动生效
$ alias vrc="vim ~/.bashrc && source ~/.bashrc"
# 安全删除
$ alias rm='mv -i ~/.trash/'
# 一键备份关键文件夹
$ backup { tar czvf backup_$.tar.gz /path/to/backup }
### 添加到.bashrc中:
echo 'backup { tar czvf backup_$.tar.gz /path/to/backup }'>> ~/.bashrc && source ~/.bashrc
### 接下来可以这样使用:
backup /home/user/documents
## 快速创建Python虚拟环境
python-venv {
python3 -m venv $1 && echo "Virtualenv created at $1" && echo "Activate with: source $1/bin/activate"
}
echo 'python-venv { python3 -m venv $1 && echo "Virtualenv created at $1" && echo "Activate with: source $1/bin/activate" }'>> ~/.bashrc
## 在线检查网络端口占用情况
checkport {
sudo lsof -i :${1:-80} || netstat -tuln | grep ${1:-80}
}
## 超级清理临时文件
superclean {
read -p "Are you sure?This will delete a lot of files!" ans
|| exit 0
sudo apt-get clean>/dev/null &
sudo bleachbit --clean system.cache system.logs system.tmp>/dev/null &
rm -rf /tmp/* /var/tmp/* ~/.cache/* ~/*.swp ~/*.swo ~/*.bak ~/*.orig 2>/dev/null &
}
## 一键安装常用软件包
install-common {
sudo apt update && \
sudo apt install build-essential git curl wget htop tmux neovim zsh tree \
ripgrep fd-find bat exa tmuxinator yarn npm python3-pip \
docker docker-compose ffmpeg mplayer vlc smplayer gimp inkscape audacity \
shutter qemu qemu-kvm libvirt-daemon-system libvirt-clients virt-manager \
bridge-utils qpdfview okular okular-extra-backends calibre unrar p7zip-full \
filezilla thunderbird telegram-desktop discord slack-desktop obs-studio kdenlive \
krita blender nomacs shotwell simplescreenrecorder gparted testdisk timeshift \
gufw tlp tlp-rdw ufwufwufwufwufwufwufwufwufwufwufwufwufwuwfwfwfwfwfwfwffwwfwwwfwwfwwwwwfffffffffffffffffffffff
警告!: 上面这些高级技巧要谨慎使用。是:

-
- 'rm'被替换为安全删除,但仍需注意关键文件;
-
- 超级清理功能会彻底删除大量数据,请确认内容无误再操作;
-
- 安装脚本会安装许多软件包,可能影响程序性能或引入冲突。
函数式别名的高级应用
"我需要为不同项目切换不同设置环境" —— 函数+环境变量来解决!老实说,
bash
## 项目环境切换函数集合
setup_project_env {
local project_dir="$HOME/projects/$1"
# 检查项目是否存在并进入目录
if;n
echo "Project directory not found: $project_dir"
return 1
fi
cd "$project_dir"
# 检测并激活虚拟环境
if;n
source .venv/bin/activate || return 2;fi
bash
bash
bash
bash
bash
bash
setup_git_config {
local git_email=$(
if;n # 工作电脑配置 echo "";else # 其他设备配置 echo "";fi )
local git_user=$
git config user.email "$git_email"
setup_git_config
{
local git_email=$" = "work-laptop.example.com" ];n # 工作电脑配置 echo "";else # 其他设备配置 echo "";fi )
local git_user=$
export GIT_AUTHOR_NAME="$git_user"
export GIT_COMMITTER_NAME="$git_user"
export GIT_AUTHOR_EMAIL="$git_email"
export GIT_COMMITTER_EMAIL="$git_email"
export PROJECT_ENV_ACTIVE=true
echo " Environment setup for '$PWD' as user: '$GIT_USER_NAME <'$GIT_USER_EMAIL'>'"
}
### 在.bashrc中调用:
if ];n # 初始化一次 touch $HOME/.last_project chmod +x $HOME/.last_project fi
function project { local project_name=$1 local last_project=$ setup_project_env "$project_name" || return;if ],n direnv allow;fi,老实说,echo "$project_name">"$HOME/.last_project";
] || tmux new-session;话说回来,}
function proj { last_project=$;if ],n find .|fgrep "/src/"|less else fd --type d src;fi }
function back { cd ../.. }
function pj { cd ~/projects/$*;pwd,ls }
function open-vscode {
if ];n code-insiders . else code .
}
}
function open-vscode-root {
if ];说起来,n code-insiders / else code /
}
}
### 添加这些函数到.bashrc中:
cat < EOF>>$HOME/scripts/functions.sh &&
#!/bin/bash function setup_git_config... EOF && cat < EOF>>$HOME/scripts/project.sh &&... EOF && chmod +x ~/scripts/*.sh && cat >~/.zshrc ## Load custom functions for f in \~/scripts/\*.sh;do \. "\${f}" done unset f EOF && cat >~/.zshrcfn load_custom_functions{ for f in \~/scripts/\*.sh;do \. "\${f}" done } load_custom_functions EOF
上下文感知型别名
"我需要在不同项目中使用不同命令参数"
bash
在~/.direnvrc 中添加:
layoutpython{ if ];n export PYTHONVERSION=python3.9 elif ];n export PYTHONVERSION=python elif ];n export PYTHONVERSION=python else export PYTHON_VERSION=python fi }
layoutdocker{ unset DOCKERHOST DOCKERTLSVERIFY DOCKERCERTPATH DOCKERMACHINENAME DOCKERAPIVERSION unset COMPOSETLSVERSION COMPOSECONNECTIONTIMEOUT COMPOSERESPONSETIMEOUT unset MACHINESTORAGEPATH MACHINEDRIVER } layoutconda{ CONDAENVPATH="" eval "\$" conda deactivate conda activate base conda activate base setopt HISTIGNORESPACE setopt HISTFINDNODUPS setopt INCAPPENDHISTORY HISTFILE=/tmp/zhistory SIZE=\$\ let “SIZE -= 50” head –\$-SIZE \$HISTFILE> \$HISTFILE.tmp mv \$HISTFILE.tmp \$HISTFILE uniq!\~ /.zshrchistory> history-temp mv history-temp /.zshrchistory export CONDAPROMPT_MODIFIER="" export PSI=\u@\h:\W \\$]\]\e]]\] ]\]
setprompt{ PROMPT="'%{\u@%M:%~%'}" RPROMPT="'%❯%f'"} unsetprompt{ PROMPT="'%'"} RPROMPT="'%'"} layout_gcloud{ gcloud config configurations list --format=\"table\" gcloud config configurations activate default-source-code-project-source-repo-name-source-repo-url-service-account-email-service-account-key-file-name-gcloud-component-name-gcloud-component-version-installed-status-bucket-name-default-storage-bucket-name-default-compute-zone-default-compute-region-datastore-database-url-firestore-database-url-bigquery-dataset-id-pubsub-topic-id-cloud-build-trigger-id-container-cluster-name-container-node-pool-name-container-machine-type-container-num-nodes-container-cluster-version-container-enable-autoscaling-container-min-nodes-container-max-nodes-app-engine-service-account-email-app-engine-default-bucket-name-cloud-functions-location-cloud-scheduler-location-secret-manager-instance-id-sql-instance-connection-string-sql-instance-tier-sql-instance-size-sql-instance-cpu-count-sql-instance-memory-size-sql-instance-storage-size-sql-instance-storage-type-db-proxy-enabled-db-proxy-connection-string-db-proxy-port-number-db-proxy-user-db-proxy-password-db-proxy-address-db-proxy-installation-path-cloud-dataflow-runner cloud-dataflow-network cloud-dataflow-subnetwork cloud-dataflow-worker-machine-type cloud-dataflow-worker-machine-image cloud-dataflow-worker-boot-disk-size-gb cloud-dataflow-worker-boot-disk-type cloud-dataflow-worker-harness-dir-volume-size-gb cloud-dataflow-network-mode cloud-dataflow-subnetwork-mode pubsub-emulator-host pubsub-emulator-port datastore-emulator-host datastore-emulator-port firestore-emulator-host firestore-emulator-port bigtable-emulator-host bigtable-emulator-port spanner-emulator-host spanner-emulator-port redis-cache-tier redis-cache-memory-size-gib redis-cache-transit-in-transit-enabled redis-cache-persistence-enabled redis-cache-persistence-aof-enabled redis-cache-persistence-rdb-frequency redis-cache-persistence-aof-frequency appengine-api-server-host appengine-api-server-port appengine-api-server-usehttps memorystore-redis-tier memorystore-redis-capacity-gib memorystore-redis-transit-in-transit-enabled memorystore-redis-persistence-enabled memorystore-redis-persistence-aof-enabled memorystore-redis-persistence-rdb-frequency memorystore-redis-persistence-aof-frequency compute-quotas-list compute-quotas-limit compute-quotas-used compute-regions-list compute-zones-list sql-admin-instances-list sql-admin-backups-list sql-admin-flags-list sql-admin-maintenance-windows-list sql-admin-operations-list sql-admin-settings-get storage-classes-list storage-buckets-get storage-objects-get storage-objects-acl-set storage-objects-acl-get dataproc-jobs-create dataproc-jobs-get dataproc-jobs-update dataproc-jobs-delete dataproc-clusters-create dataproc-clusters-get dataproc-clusters-update dataproc-clusters-delete container-images-add container-images-get container-images-delete container-images-tag container-images-retag container-images-deletemany pubsub-projects-topics-create pubsub-projects-topics-update pubsub-projects-topics-delete pubsub-projects-topics-message-send pubsub-projects-topics-message-receive datafusion-instances-create datafusion-instances-update datafusion-instances-delete datafusion-instances-get datafusion-instances-environment-setup datafusion-flow-configurations-create datafusion-flow-configurations-update datafusion-flow-configurations-delete datafusion-flow-configurations-start flow-configuration-import flow-configuration-export flow-configuration-test flow-configuration-debug bigquery-jobs-create bigquery-jobs-cancel bigquery-jobs-check bigquery-jobs-wait bigquery-tables-copy bigquery-tables-emptytruncate bigquery-tables-load bigquery-tables-query bigquery-tables-upload job-template-run job-template-schedule job-template-unschedule job-template-update job-template-get job-template-delete resource-manager-folders list resource-manager-folders get resource-manager-folders create resource-manager-folders delete resource-manager-organizations list resource-manager-organizations get resource-manager-organizations create resource-manager-organizations delete secretmanager-secrets list secretmanager-secrets create secretmanager-secrets destroy secretmanager-secretversions add secretmanager-secretversions destroy artifactregistry-repositories list artifactregistry-repositories get artifactregistry-repositories create artifactregistry-repositories delete artifactregistry-packages list artifactregistry-packages get artifactregistry-packages create artifactregistry-packages delete dlpcmd jobs submit dlpcmd jobs cancel dlpcmd jobs check dlpcmd jobs wait dlpcmd datasets copy dlpcmd datasets emptrydlpcmd datasets load dlpcmd datasets query dlpcmd datasets upload run-template run run-template schedule run-template unschedule run-template update run-template get run-template delete workflow-executions list workflow-executions get workflow-executions create workflow-executions cancel workflow-executions execute taskrunner-runs create taskrunner-runs cancel taskrunner-runs execute taskrunner-taskdefinitions create taskrunner-taskdefinitions update taskrunner-taskdefinitions delete taskrunner-taskdefinitions get taskrunner-taskdefinitions list apigee-apps-key-certs apigee-apps-oauth apigee-apps-customers apigee-apps-products apigee-apps-resources apigee-asset-manifest-files apigee-asset-manifest-files-upload apigee-asset-manifest-files-download auditlogs-events filter auditlogs-events describe auditlogs-events search auditlogs-events stream billing-budgets list billing-budgets get billing-budgets create billing-budgets update billing-budgets patch billing-budgets delete billing-costreports generate billing-reservations list billing-reservations get billing-reservations create billing-reservations patch billing-reservations delete budgets-notificationsettings patch budgets-notificationsettings delete budgetsserviceusage-restrictions serviceusage-restrictions serviceusage-restrictions-enable serviceusage-restrictions-disable serviceusage-restrictions-modify serviceusage-services disable serviceusage-services enable serviceusage-services modify cbt projects instances locations clusters nodes pools nodegroups nodes pools scale cbt projects zones instancegroups instances groups machines machineimages machineimagefamilies machineimagetypes machineimagetypes machineimages diskimages disks snapshots snapshotfamilies snapshotdisktypes diskdisktypes disktiers disktiertypes disks snapshots attach detach resize extend migrate clone mirroring mirroringmirroringmirroringmirroringmirroringmirroringsnapshots attach detach resize extend migrate clone mirroring mirroringmirroringsnapshots attach detach resize extend migrate clone networking networks routers firewalls networkservices networkservices networkservices networkservices networkservices networkservices networkservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesnetworkingservicesoperations operations operations operations operations operations operations operations operationsoperationsoperationsoperationsoperationsoperationsoperationsoperationsoperationsoperationstasks tasks tasks tasks tasks tasks tasks tasks tasks operationsexecute operationsexecute operationsexecute operationsexecute operationsexecute operationsexecute operationsexecutepackages packages packages packages packages packages packageinstalls packageinstalls packageinstalls packageinstalls packageinstalls packagemanagers packagemanagers packagemanagers packagemanagers packagemanagersextensions extensions extensions extensions extensions extensions extensioninstall extensioninstall extensioninstall extensioninstall extensioninstall eventarc triggers triggers triggers triggers triggers triggerstriggers triggerstriggers triggerstriggers triggerstriggers eventarc channels channels channels channels channelschannelseventarcchannels eventarcchannels events events events events eventschannelseventschannels eventschannels channelstopicspubsubtopics topics topics topics topics topicssubscriptions subscriptions subscriptions subscriptions subscriptions subscriptionspull subscriptionspull subscriptionspush subscriptionspullacknowledge subscriptionspullmodifyackdeadline subscriptionspushsubscriptionstopicsmessages publish publish subscribe subscribe subscribe pull pull modifyackdeadline acknowledge pullmodifyackdeadline acknowledge pushtopics messages publish messages publish messages publish messages publish messagepull messagepull messagepull messagepull messagepush messagepushmessagepushmessagepushtopicsmessagessubscri娱乐opicsmessagessubscri娱乐opictopicssubscribesubscriptionstopictopicssubscriptio...
跨网站兼容性处理
"我的脚本需要在Linux和Windows都能运行"
$ is_windows {
case `uname` in CYGWIN*|MINGW*|MSYS*) return 0;,*) return 1;,esac }
case `uname` in CYGWIN*) cygwin=true;,*) cygwin=false;,esac }
uname | findstr CYGWIN MINGW MSYS>nul and set win=true or set win=false )
else win=false fi )
else win=false
命令提高与可视化输出
pre>
preh5" 安全防护与风险控制 /preh5 "
pre " ⚠️警告!⚠️< span>" "
pre " 一些危险操作可能导致数据丢失或程序损坏。务必谨慎,怎么说呢,永远不要将以下命令作为别名: rm * rm rf / dd if=/dev/random of=/dev/sdX bs=5M # 历史错误示例! yes N | rm rf / # 禁止这样的恶意命令! chmod R+x / # 绝对不要这样做!按理说,
说到预防措施。为rm创建安全封装: safe_remove{ read - p " 确认删除'$*'?" && return,
find . name " $ *"- delete- ok;} alias rm=" safe_remove "
限制sudo权限: restricted_sudo{ && echo " 权限受限!仅允许编辑和重启操作,";return,} for cmd in vim nano vi emacs shutdown reboot halt initpoweroff;do sudo - K cmd;done,
for cmd in rm cp mv chown chmod passwd useradd userdel groupadd groupdel;do sudo - R cmd;done,
禁止明文密码出现在历史记录中: alias mysql=" mysql - p "(read - sP ";password:" passwd && printf "%% %s%%n " $ passwd)" unset passwd;} " "
preh6""常用方法"/preh6 ""
ol class=" best-pratices"> ""
ol class=" best-pratices"> ""
ol class=" best-pratices"> ""

