LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-25-2020, 10:30 AM   #1
hashille
LQ Newbie
 
Registered: Jan 2020
Posts: 1

Rep: Reputation: Disabled
ZSH set behaviour when command reading


Hello everyone,
I hope i'm in the good place to start with.
Here is my question : I've been looking for a way to set a defined behaviour when zsh is reading from the command-line, i've come across Zshzle but can't find anything related to what I would like to do :
I would like to start all of my commands with a special character and if it's not there, call my "lock" alias.
Let's say I have the following command line :
"vim ~/.bashrc"
then it would call my "lock" alias and lock my computer, as the "good" input would have been "h vim ~/.bashrc".
Any suggestions ?
Thanks
 
Old 01-25-2020, 10:40 AM   #2
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 442

Rep: Reputation: 196Reputation: 196
You can do that with Hooks, but to be honest, this seems like not a good solution against anything but the most naive meddling.

Which is fine, though, maybe you want to prevent a child or a pet to trigger a command, so, yeah.

There is also 'accept-line' that you could override, but that can mess things up quite a bit since it tampers with one of the more fundamental bits of zsh.

Anyway, don't use this as a serious security measure. Checking aliases and the shell rc files are easy and obvious targets for inspection and there are most likely tricks to get around the hooks, too.
(I honestly don't know them, or I'd tell you them.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ZSH -- Apple switching BASH => ZSH, what do you think? LQParsons Linux - Newbie 2 06-06-2019 10:01 AM
LXer: Set up zsh on your Fedora system LXer Syndicated Linux News 0 05-23-2018 07:24 PM
LXer: How to Setup ZSH and Oh-my-zsh on Linux LXer Syndicated Linux News 0 11-02-2017 12:42 AM
Delete button does not work in ZSH command-line Scotteh Debian 1 02-04-2013 03:36 AM
shopt command in zsh burninGpi Linux - Software 2 05-18-2006 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration